diff --git a/ChangeLog b/ChangeLog index ae040c30a..f96332e20 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,1181 +1,1190 @@ +2010-03-10 Werner Koch + + * jnlib/: Move all code to common/. + * Makefile.am (SUBDIRS): Remove jnlib. + * configure.ac (AC_CONFIG_FILES): Remove jnlib/Makefile. + + * configure.ac (AM_PATH_LIBASSUAN): Remove double test. + * acinclude.m4 (GNUPG_CHECK_ENDIAN): Remove bogus warning. + 2010-03-09 Werner Koch * configure.ac: Add option --disable-ccid-driver. (AH_BOTTOM): Define GPG_ERR_ENABLE_GETTEXT_MACROS. 2010-02-26 Werner Koch * gl/mkdtemp.c (__set_errno) [W32CE]: Use gpg_err_set_errno. * gl/setenv.c (__set_errno) [W32CE]: Ditto. * gl/unsetenv.c (__set_errno) [W32CE]: Ditto. * configure.ac (HAVE_W32CE_SYSTEM): New ac_define and am_conditional. (signal.h, getenv): Check for them. * autogen.sh: New option --build-w32ce. Remove obsolete option --without-included-gettext. 2009-12-08 Werner Koch * configure.ac (USE_DNS_CERT): Support ADNS. 2009-12-07 Werner Koch * configure.ac: Check for ADNS before checking for the BIND resolver. (USE_ADNS): Fallback macro for PKA and CERT lookups. 2009-10-20 Marcus Brinkmann * configure.ac: Check for fusermount and encfs. 2009-10-16 Marcus Brinkmann * configure.ac: Check for libassuan instead of libassuan-pth. 2009-10-12 Werner Koch * configure.ac: Use -O3 because newer gcc versions require that for uninitialized variable warnings. 2009-09-23 Werner Koch * configure.ac (HAVE_ASSUAN_SET_IO_MONITOR): Remove test. (_ASSUAN_ONLY_GPG_ERRORS): Remove. 2009-09-23 Marcus Brinkmann * configure.ac (NEED_LIBASSUAN_API, NEED_LIBASSUAN_VERSION): Update to new API (2, 1.1.0). 2009-09-21 Werner Koch Start a new development branch in the SVN trunk. The stable one is now known in the SVN as branches/GNUPG-STABLE-2-0. 2009-09-04 Werner Koch Release 2.0.13. 2009-06-29 Werner Koch * configure.ac: Take care of --without-adns. Suggested by Arfrever Frehtes Taifersar Arahesis. 2009-06-17 Werner Koch Release 2.0.12. 2009-06-05 David Shaw * configure.ac: Remove Camellia restriction. 2009-04-01 Werner Koch * configure.ac: Test for fsync. 2009-03-18 Werner Koch * configure.ac: Test for getrlimit. 2009-03-03 Werner Koch Release 2.0.11. 2009-01-12 Werner Koch Release 2.0.10. 2008-12-09 Werner Koch Release 2.0.10rc1. 2008-10-17 Werner Koch * configure.ac: Use more warning options with modern GCCs. 2008-09-29 Werner Koch * configure.ac: Require libgcrypt 1.4. 2008-08-27 David Shaw * configure.ac: Use printf for the most portable SVN version detection. * configure.ac: Darwin's /bin/sh has a builtin echo that doesn't understand '-n'. Use tr to trim the carriage return instead. 2008-04-23 Werner Koch * configure.ac: Call gl_HEADER_SYS_SOCKET and gl_TYPE_SOCKLEN_T. 2008-04-07 Werner Koch * configure.ac (ADNSLIBS): Test for adns. (GPGKEYS_KDNS): New. 2008-04-01 Werner Koch * configure.ac: Require curl 7.10 (Oct 1 2002) or later as we use curl_version_info(). (AC_INIT): Fix quoting. 2008-03-27 Werner Koch * Makefile.am (dist_doc_DATA): New. Install README. 2008-03-26 Werner Koch Release 2.0.9. 2008-02-19 Werner Koch * configure.ac: Remove --with-pkits-tests. 2008-02-15 Werner Koch * gl/allocsa.h, gl/m4/allocsa.m4: Replace HAVE_LONG_LONG by HAVE_LONG_LONG_INT. 2008-02-15 gettextize * configure.ac (AM_GNU_GETTEXT_VERSION): Bump to 0.17. 2007-12-20 Werner Koch Released 2.0.8. 2007-12-17 Werner Koch * configure.ac: Add treatment for HAVE_LDAP_START_TLS_SA. 2007-12-14 Werner Koch Released 2.0.8rc1. 2007-12-12 Werner Koch * configure.ac (USE_CAMELLIA): Define by new option --enable-camellia. 2007-12-03 Werner Koch * configure.ac: Add test gt_LC_MESSAGES.. 2007-10-01 Werner Koch * configure.ac: Require assuan 1.0.4. 2007-09-14 Werner Koch * configure.ac (GNUPG_LIBASSUAN_VERSION): New. 2007-09-10 Werner Koch Released 2.0.7. 2007-08-27 Werner Koch * configure.ac: Remove remaining support for internal regex. Define DISABLE_REGEX automake conditional. Add option --with-regex. * autogen.sh [--build-w32]: Remove --disable-regex. Use --with-regex. 2007-08-16 Werner Koch Released 2.0.6. 2007-08-08 Werner Koch * configure.ac: Use AC_CANONICAL_HOST and not AC_CANONICAL_TARGET. 2007-07-09 Werner Koch * configure.ac (AM_ICONV): Check for it even when building without NLS. 2007-07-05 Werner Koch Released 2.0.5. * configure.ac: Require libassuan 1.0.2. 2007-07-05 Marcus Brinkmann * configure.ac: Invoke AM_LANGINFO_CODESET. 2007-07-04 Werner Koch * Makefile.am (AUTOMAKE_OPTIONS): Add no-dist-gzip. Switched entire package to GPLv3+. * configure.ac: Require libksba 1.0.2. * COPYING: Updated to GPLv3. * COPYING.LIB: New as jnlib/ uses this license. * gl/: Switched to GPLv3+. * intl/ Removed. * configure.ac (AM_GNU_GETTEXT): Add external flag. (AM_ICONV): New. 2007-07-03 Werner Koch * configure.ac [W32]: Use ws2_32 instead of wsock32. 2007-06-25 Werner Koch * gl/mkdtemp.c (gen_tempname) [MKDIR_TAKES_ONE_ARG]: Avoid compiler warning by using the proper config macro. 2007-06-15 Werner Koch * configure.ac: Call AM_PO_SUBDIRS. (W32SOCKLIBS): New. * autogen.sh: Use = and not == in test to be POSIXly correct. : Disable use of regex. 2007-06-14 Werner Koch * configure.ac [AH_BOTTOM]: Remove the hardwired names of modules. 2007-06-12 Werner Koch * configure.ac [AH_BOTTOM]: Define HTTP_NO_WSASTARTUP. 2007-06-11 Werner Koch * am/cmacros.am (libcommonstd, libcommonpth, libcommonstd_ldadd) (libcommonpth_ldadd): Add macros. 2007-06-06 Werner Koch * configure.ac: Add a few notices message so make browsing of the log file easier. (CC_FOR_BUILD): New. 2007-05-30 Werner Koch * configure.ac [W32]: Do not create a symlink to w32-pth.h. Require the installation of the w32pth package. 2007-05-29 Werner Koch * gl/: Updated to a newer version. 2007-05-24 Werner Koch * configure.ac: Use -Wpointer-arith is possible. 2007-05-15 Werner Koch * configure.ac: Renamed the estream macros. Remove -Wformat-nonliteral. * configure.ac: Call ESTREAM_INIT and define the memory allocators for estream_asprintf. (gl_MODULES): Remove vasprintf. 2007-05-09 Werner Koch Released 2.0.4. 2007-05-07 Werner Koch * configure.ac: Require libgcrypt 1.2.2 to avoid compiler warnings. 2007-05-07 gettextize * configure.ac (AM_GNU_GETTEXT_VERSION): Bump to 0.16.1. 2007-05-07 Werner Koch * configure.ac: Bail out if no C-89 compiler has been found. 2007-05-04 Werner Koch * Makefile.am (DISTCHECK_CONFIGURE_FLAGS): Add --enable-mailto * configure.ac: Require automake 1.10 (AC_CONFIG_FILES): Rename gpgkeys_ to gpg2keys_. (AM_PROG_CC_C_O): New. 2007-03-08 Werner Koch Released 2.0.3. * autogen.sh: Add option --force. 2007-01-31 Werner Koch Released 2.0.2. 2006-11-30 Werner Koch * configure.ac: Save original LIBS when testing for dlopen. 2006-11-28 Werner Koch Released 2.0.1. 2006-11-23 Werner Koch Released 2.0.1rc1. 2006-11-21 Werner Koch * configure.ac [AH_BOTTOM]: Disable PTH soft mapping. (AC_CHECK_SIZEOF): Check for time_t. (BUILD_INCLUDED_LIBINTL): Remove AM_PO_SUBDIRS as it is not required for C. 2006-11-15 Werner Koch * autogen.sh: Add convenience option --build-amd64. 2006-11-14 Werner Koch * configure.ac (HAVE_ASSUAN_SET_IO_MONITOR): Test for it. 2006-11-11 Werner Koch Released 2.0.0. 2006-11-06 Werner Koch Released 1.9.95. 2006-11-03 Werner Koch * configure.ac: Test for pty.h. From Gentoo. 2006-10-24 Werner Koch Released 1.9.94. 2006-10-20 Werner Koch * Makefile.am (stowinstall): Add convenience target. 2006-10-18 Werner Koch * configure.ac: svn revison magic fixes for old bashs. Suggested by Alain Guibert. 2006-10-18 Werner Koch Released 1.9.93. 2006-10-17 Werner Koch * autogen.sh <--build-w32>: Test also for a host "mingw32". * configure.ac: Removed W32LIBS. Use NETLIBS instead. 2006-10-11 Werner Koch Released 1.9.92. * configure.ac: Require libassuan 0.9.3. 2006-10-09 Werner Koch * acinclude.m4: Moved pth check to m4/gnupg-pth.m4. 2006-10-06 Werner Koch * configure.ac: Also check for libassuan's pth version. 2006-10-04 Werner Koch Released 1.9.91. * configure.ac: Require libassuan 0.9.1 which fixes a problem with gpgsm. 2006-09-27 Werner Koch * gl/strsep.h, gl/strsep.c, gl/m4/strsep.m4: Removed. * gl/strpbrk.h, gl/strpbrk.c, gl/m4/strpbrk.m4: Removed. * gl/Makefile.am: Removed module strsep and strpbrk. * configure.ac: Check for strsep in the context of jnlib. Remove check from gl_MODULES. Moved check for timegm into the jnlib context. 2006-09-27 Marcus Brinkmann * Makefile.am: Fix cut & paste error. 2006-09-25 Werner Koch Released 1.9.90. 2006-09-22 Werner Koch * AUTHORS: Add information about used licenses. 2006-09-20 Werner Koch * Makefile.am (dist-hook): Removed distfiles cruft. (SUBDIRS): Added include 2006-09-18 Werner Koch Released 1.9.23. * configure.ac (--enable-agent-only): Donot build tools and doc (--disable-tools,--disable-doc): New. * Makefile.am (SUBDIRS): Allow to conditional build tools and doc. 2006-09-14 Werner Koch Replaced all call gpg_error_from_errno(errno) by gpg_error_from_syserror(). * configure.ac: Build gpg by default. (GNUPG_SYS_SO_PEERCRED): Removed. 2006-09-13 Werner Koch * autogen.sh: Better detection of the cross compiler kit. 2006-09-06 Marcus Brinkmann * configure.ac: New automake conditional RUN_GPG_TESTS. 2006-09-06 Werner Koch * configure.ac: Define _ASSUAN_ONLY_GPG_ERRORS. Require Assuan 0.9 and libgpg-error 1.4. 2006-08-31 Werner Koch * configure.ac: Require libksba 1.0 and added API check for it. (GPG_ERR_LOCKED): Removed DECL check as we require 1.2 anyway. (have_libusb): New to give a feedback about CCID support 2006-08-21 Werner Koch * configure.ac: Removed docbook tests. (AC_CONFIG_FILES): Added gpgkeys_test and gpgkeys_mailto. * Makefile.am (DISTCHECK_CONFIGURE_FLAGS): Enable gpg. 2006-08-17 Werner Koch * THANKS: Merged with the 1.4 one. 2006-08-16 Werner Koch * configure.ac: Removed test for capabilities and mlock. 2006-08-15 Werner Koch * Makefile.am (keyserver): Enable building of keyserver helpers. * configure.ac: Merged with the current configure from 1.4.5. Require libgpg-error 1.2 and libksba 0.9.16. 2006-07-29 Marcus Brinkmann * README: Spelling fixes. 2006-07-27 Werner Koch Released 1.9.22. * configure.ac: Call AB_INIT. 2006-07-03 Werner Koch * configure.ac: Test for ksba_dn_teststr. 2006-06-30 Werner Koch * keyserver/: New. Taken from 1.4.4 * Makefile.am (SUBDIRS): Include keyserver/. * configure.ac: Include keyserver/. (FAKE_CURL, GPGKEYS_CURL): New. 2006-06-20 Werner Koch Released 1.9.21. 2006-06-08 Marcus Brinkmann * configure.ac (PTH_LIBS): Add --all to pth-config invocation. 2006-05-24 Werner Koch * configure.ac: New option --disable-optimization taked from 1.4.3. 2006-05-23 Werner Koch * configure.ac (ZLIBS): New for zlib link commands. Add bzip2 support. 2006-05-22 Werner Koch * configure.ac (EXEEXT): New. 2006-04-18 Werner Koch * configure.ac (PK_UID_CACHE_SIZE): New. 2006-04-07 Werner Koch * configure.ac: Use new method to include the SVN revison. Now it is the actual global revision number. 2005-12-20 Werner Koch Released 1.9.20. 2005-11-28 Werner Koch * configure.ac: Append the revision to the version string. 2005-11-13 Werner Koch * am/cmacros.am (-DGNUPG_SYSCONFDIR): Define it. 2005-11-11 Werner Koch * configure.ac (NEED_KSBA_VERSION: Require 0.9.13. 2005-09-12 Werner Koch Released 1.9.19. 2005-08-01 Werner Koch Released 1.9.18. * configure.ac: Require libksba 0.9.12 to match new features in gpgsm. 2005-06-20 Werner Koch Released 1.9.17. 2005-06-02 Werner Koch * configure.ac (HAVE_PTH): Define as alias for USE_GNU_PTH. It is used by common/estream.c. 2005-06-01 Werner Koch * configure.ac (gl_INIT): Add gnulib stuff. (fseeko, ftello, ttyname, isascii): Replaced the AC_REPLACE_FUNCS by a simple check. (putc_unlocked): Removed check. Not used. (strsep, mkdtemp, asprintf): Replaced checks by gnulib checks. (xsize): Added will probably come handy soon. (CFLAGS): Use -Wformat-security instead of -Wformat-nonliteral. Add --Wno-format-y2k. * gl/, gl/m4/: New. 2005-05-15 Werner Koch * configure.ac: Remove option --disable-threads; require the use of GNU Pth. 2005-04-27 Werner Koch * configure.ac: Removed OpenSC detection and options. * acinclude.m4: Ditto. 2005-04-21 Werner Koch Released 1.9.16. * configure.ac: Do not build gpg by default. 2005-04-20 Werner Koch * configure.ac: Test whether GPG_ERR_LOCKED is declared and provide a replacement if not. 2005-04-15 Werner Koch * configure.ac: Require libksba 0.9.11. 2005-04-15 Marcus Brinkmann * configure.ac: Check for /usr/bin/shred and define SHRED. * configure.ac: Add --enable-symcryptrun, disabled by default. Define automake variable BUILD_SYMCRYPTRUN. Check for openpty -lutil, define LIBUTIL_LIBS. 2005-03-03 Werner Koch * acinclude.m4 (GNUPG_PTH_VERSION_CHECK): Accidently used --ldflags instead of --cflags. Reported by Kazu Yamamoto. 2005-02-03 Werner Koch * AUTHORS: Copied from 1.4 and edited to refelct the changes in 1.9. 2005-01-17 Werner Koch * configure.ac: Make --without-included-regex work as expected. Fixed FTP location info for some libraries. 2005-01-13 Werner Koch Released 1.9.15. * acinclude.m4 (GNUPG_PTH_VERSION_CHECK): Link a simple test program to see whether the installation is sane. 2005-01-07 Werner Koch * configure.ac: Require gpg-error 1.0. 2005-01-04 Werner Koch * configure.ac: Remove hack not to build gpg2 for W32. * autogen.sh : Pass option --disable-gpg instead. 2004-12-22 Werner Koch Released 1.9.14. 2004-12-20 Werner Koch * configure.ac: Add PATHSEP_C and PATHSEP_S. For W32 let all directories default to c:/gnupg. Require libassuan 0.6.9. 2004-12-18 Werner Koch * configure.ac (AH_BOTTOM): Define EXEEXT_S. * autogen.sh: Updated --build-w32 feature. 2004-12-15 Werner Koch * Makefile.am (SUBDIRS) [W32]: Do not build in tests/. * acinclude.m4: Add proper macro name quoting for use with automake 1.9. * configure.ac: Add replacement check for ttyname. Removed support for a included zlib. 2004-12-06 Werner Koch * configure.ac (have_w32_system): New. Disable Pth checks for W32. Link jnlib/w32-pth.h to pth.h. 2004-12-03 Werner Koch Released 1.9.13. 2004-11-26 Werner Koch * configure.ac: Replace strsep. Replaced use of "target" by "host". 2004-10-22 Werner Koch Released 1.9.12. * Makefile.am (AUTOMAKE_OPTIONS): Set option to create bzip2 tarball. 2004-10-01 Werner Koch Released 1.9.11. 2004-09-30 Werner Koch * README: Minor updates. 2004-09-30 gettextize * configure.ac (AM_GNU_GETTEXT_VERSION): Bump to 0.14.1. 2004-08-16 Werner Koch * configure.ac: Build Makefile for tests/pkits. New option --with-pkits-tests. 2004-08-05 Werner Koch * configure.ac: Changed tests for libusb to also suuport the stable version 0.1.x. 2004-07-22 Werner Koch Released 1.9.10. * configure.ac: Define AM conditional HAVE_OPENSC. 2004-07-21 Werner Koch * configure.ac: Don't set DIE to no after it might has been set to yes. 2004-07-20 Werner Koch * Makefile.am (sm): Build kbx only if gpgsm is to be build. 2004-07-20 Werner Koch * configure.ac: New option --enable-agent-only. 2004-06-08 Werner Koch Released 1.9.9. 2004-06-06 Werner Koch * configure.ac: Require libksba 0.9.7. 2004-04-29 Werner Koch Released 1.9.8. 2004-04-20 Werner Koch * configure.ac: Remove the fopencookie test. We don't need the dummy function because we conditionally use fopencookie, fpencookie or a replacement at place. 2004-04-02 Thomas Schwinge * autogen.sh: Added ACLOCAL_FLAGS. 2004-04-06 Werner Koch Released 1.9.7. * configure.ac: Require libgcrypt 1.1.94. Introduce PACKAGE_GT and set it to gnupg2. 2004-03-23 Werner Koch * configure.ac: Define SAFE_VERSION_DASH and SAFE_VERSION_DOT. 2004-03-09 Werner Koch * configure.ac (NEED_GPG_ERROR_VERSION): Set to 0.7. 2004-03-06 Werner Koch Released 1.9.6. * configure.ac: Check the Libgcrypt API. 2004-02-25 Werner Koch * configure.ac: New option --disable-threads to inhibit unintentional builds without Pth. 2004-02-21 Werner Koch Released 1.9.5. 2004-02-20 Werner Koch * configure.ac: Fixed URLs in the notice messages. 2004-02-18 Werner Koch * acinclude.m4: Removed macros to detect gpg-error, libgcrypt, libassuan and ksba as they are now distributed in m4/. 2004-02-13 Werner Koch * configure.ac: Require libksba 0.9.4 and libgcrypt 1.1.92. 2004-02-12 Werner Koch * autogen.sh: Removed cruft from debugging. * am/cmacros.am: New. 2004-02-11 Werner Koch * configure.ac: Removed the need for g10defs.h. Reworked the --with-foo-pgm stuff. * autogen.sh (check_version): Removed bashism and simplified. * acinclude.m4 (AM_PATH_OPENSC): Kludge to avoid error output for a bad opensc-config. 2004-01-30 Werner Koch Released 1.9.4. * configure.ac: Require libksba 0.9.3 due to another bug fix there. 2004-01-29 Werner Koch * README: Updated. * configure.ac: Require libksba 0.9.2 due to bug fixes. 2004-01-24 Werner Koch * configure.ac: Now requires libassuan 0.6.3. 2003-12-23 Werner Koch Released 1.9.3. * README-alpha: Removed. * configure.ac, Makefile.am: Add the tests and tools directories. 2003-12-19 Werner Koch * configure.ac: Now require libgcrypt 1.1.91 to help testing the latest libgcrypt changes. Requires libksab 0.9.1. 2003-12-17 Werner Koch * configure.ac: Requires now libassuan 0.6.2. (CFLAGS): Add --Wformat-noliteral in gcc mode. 2003-12-16 Werner Koch * configure.ac: Check for funopen and fopencookie as part of the jnlib checks. 2003-12-09 Werner Koch * configure.ac: Add a min_automake_version. * README.CVS: New. * autogen.sh: Revamped except for the --build-w32 hack. * Makefile.am: Add README.CVS 2003-11-17 Werner Koch Release 1.9.2. * configure.ac: Requires now libassuan 0.6.1. 2003-10-31 Werner Koch * configure.ac (NEED_KSBA_VERSION): Set to 0.9.0 due the changed time interface. 2003-10-21 Werner Koch * configure.ac (PRINTABLE_OS_NAME): Remove special case for The Hurd; Robert Millan reported that the uname test is now sufficient. 2003-10-01 Werner Koch * configure.ac (AH_BOTTOM): Define GNUPG_MAJOR_VERSION. 2003-09-23 Werner Koch Merged most of David Shaw's changes in 1.3 since 2003-06-03. * configure.ac: Drop all TIGER/192 support. (uint64_t): Check for UINT64_C to go along with uint64_t. (getaddrinfo): Check for it. (sigset_t): Check for sigset_t and struct sigaction. This is for Forte c89 on Solaris which seems to define only the function call half of the two pairs by default. (W32LIBS): Include wsock32 in W32LIBS. This is different from NETLIBS so we don't need to force other platforms to pull in the netlibs when they aren't actually needed. 2003-09-06 Werner Koch Released 1.9.1. * configure.ac: Require newer versions of some libraries. 2003-09-02 Werner Koch * configure.ac (HAVE_LIBUSB): Added a simple test for libusb. 2003-08-19 Marcus Brinkmann * configure.ac (AM_PATH_GPG_ERROR): Add missing comma in invocation. 2003-08-06 Werner Koch * configure.ac: Check for libgpg-error. Print infos about missing libraries more nicely. * acinclude.m4 (AM_PATH_GPG_ERROR): Added. 2003-08-05 Werner Koch Released 1.9.0. * configure.ac (GNUPG_DEFAULT_HONMEDIR): Changed back to ~/.gnupg. 2003-07-31 Werner Koch * Makefile.am (DISTCLEANFILES): Add g10defs.h 2003-06-18 Werner Koch * configure.ac (GNUPG_DEFAULT_HOMEDIR): Changed temporary to .gnupg2 to avoid accidential use with production keys. 2003-06-11 Werner Koch * configure.ac: Merged all stuff from current 1.3 version in. * acinclude.m4: Merged required macros from current 1.2 version in. 2003-06-04 Werner Koch * configure.ac, Makefile.am: Enable building of gpg. 2003-04-29 Werner Koch * configure.ac: Build a limited version of scdaemon if libopensc is not available. * configure.ac (ALL_LINUGAS): Removed. * Makefile.am (ACLOCAL_AMFLAGS): New. * configure.ac (AM_GNU_GETTEXT_VERSION): New. Set to 0.11.5. 2003-04-29 gettextize * Makefile.am (SUBDIRS): Add m4. (ACLOCAL_AMFLAGS): New variable. (EXTRA_DIST): Add scripts/config.rpath. * configure.ac (AC_CONFIG_FILES): Add m4/Makefile. 2003-04-29 Werner Koch * assuan/ : Removed. We now use libassuan. * Makefile.am (SUBDIRS): Removed assuan * configure.ac: Check for libassuan. 2003-01-09 Werner Koch * configure.ac (GNUPG_PROTECT_TOOL): New option --with-protect-tool. (NEED_KSBA_VERSION): Does now require 0.4.6. * README: Noted where to find gpg-protect-tool. 2002-10-31 Neal H. Walfield * configure.ac: Check for flockfile and funlockfile. Check for isascii and putc_unlocked replacing them if not found. * configure.ac (PTH_LIBS): If pth is found, add the output of `$PTH_CONFIG --ldflags`, not just `$PTH_CONFIG --libs`. 2002-10-19 Werner Koch * configure.ac: Bumped version number to 1.9.0-cvs. NewPG (Aegypten project) to GnuPG merge. 2002-09-20 Werner Koch Released 0.9.2. 2002-09-05 Neal H. Walfield * configure.ac: Check for makeinfo. 2002-09-03 Neal H. Walfield * autogen.sh (have_version): New function. Generalize and simplify logic for finding and determining the versions of GNU programs. Use it. 2002-08-23 Werner Koch Released 0.9.1. * acinclude.m4 (AM_PATH_LIBGCRYPT): Updated from Libgcrypt. (AM_PATH_OPENSC): Strip non-digits from the micro version. 2002-08-21 Werner Koch Released 0.9.0. * configure.ac: Changed the default homedir to .gnupg. * README-alpha: Removed. 2002-08-19 Werner Koch * acinclude.m4: Removed -lpcsclite from KSBA_LIBS; copy+paste bug. 2002-08-13 Werner Koch * acinclude.m4 (AM_PATH_OPENSC, AM_PATH_KSBA): New. * configure.ac: Use them. 2002-08-10 Werner Koch Released 0.3.10. * configure.ac (NEED_LIBKSBA_VERSION): Require 0.4.4. Add support for gettext. 2002-07-22 Werner Koch * configure.ac: Check for ftello and provide a replacement. 2002-07-01 Werner Koch Released 0.3.9. * README: Short note on how to export in pkcs-12 format. 2002-06-29 Werner Koch * configure.ac: Define --with options to set the default location of the agent, scdaemon, pinentry and dirmngr. 2002-06-27 Werner Koch * README: Short blurb on how to import a PKCS-12 file. * configure.ac (AH_BOTTOM): New to define some constants. 2002-06-25 Werner Koch Released 0.3.8. * configure.ac (NEED_LIBGCRYPT_VERSION): Set to 1.1.8. 2002-06-12 Werner Koch * configure.ac (NEED_LIBKSBA_VERSION): We need 0.4.3 now. 2002-06-04 Werner Koch Released 0.3.7. 2002-05-21 Werner Koch * configure.ac: We now require libgcrypt 1.1.7 and libksba 0.4.2. 2002-05-14 Werner Koch * doc/: New * configure.ac, Makefile.am: Added doc/. 2002-05-03 Werner Koch Released 0.3.6. 2002-04-25 Werner Koch * configure.ac: Check for setlocale. 2002-04-24 Marcus Brinkmann * configure.ac: Check for locale.h. 2002-04-15 Werner Koch Released 0.3.5. * NEWS: Started to describe release notes. * configure.ac (NEED_LIBKSBA_VERSION, NEED_LIBGCRYPT_VERSION): Defined 2002-04-01 Werner Koch Released 0.3.4. 2002-03-18 Werner Koch Released 0.3.3. 2002-03-08 Werner Koch * README: Add some explanation on how to specify a user ID. 2002-03-06 Werner Koch Released 0.3.2. 2002-03-04 Werner Koch Released 0.3.1. * README: Explained some options and files. 2002-02-14 Werner Koch * configure.ac: Fixed status messages related to presence of Pth. 2002-02-13 Werner Koch * acinclude.m4 (GNUPG_SYS_SO_PEERCRED): New. * configure.ac: use it. 2002-02-12 Werner Koch * configure.ac: Check for PTH. Provide replacement fucntions for apsrintf and fopencookie. * acinclude.m4 (GNUPG_PTH_VERSION_CHECK): New. 2002-02-07 Werner Koch Released 0.3.0. * configure.ac: Require libgcrypt 1.1.6. 2002-02-01 Marcus Brinkmann * configure.ac (KSBA_CONFIG): Remove superfluous x in front of variable. 2002-01-26 Werner Koch * configure.ac: Add options to disable the build of some programs and print a configure status at the end. * acinclude.m4 (GNUPG_BUILD_PROGRAM): New. * scd/ : New. Added to Makefile and configure. * configure.ac: Check for libopensc * Makefile.am: Build scd only when libopensc is available 2002-01-23 Werner Koch * configure.ac (mkdtemp): See whether we have to provide a replacement. 2001-12-18 Werner Koch Released 0.0.0. 2001-12-17 Werner Koch * acinclude.m4: Add AM_PATH_LIBGCRYPT macro. * configure.ac: and use it here. Figure out the location of libksba 2001-12-15 Werner Koch * configure.ac (missing_dir): Bail out if asprintf and fopencookie are not available. 2001-12-04 Werner Koch * configure.ac (HAVE_JNLIB_LOGGING): always define it. Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007. 2010 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/Makefile.am b/Makefile.am index 0579d0591..59e8226c5 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,91 +1,91 @@ # Makefile.am - main makefile for NewPG/GnuPG # Copyright (C) 2001, 2004 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 3 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, see . ## Process this file with automake to produce Makefile.in ACLOCAL_AMFLAGS = -I m4 -I gl/m4 AUTOMAKE_OPTIONS = dist-bzip2 no-dist-gzip DISTCHECK_CONFIGURE_FLAGS = --enable-symcryptrun --enable-mailto EXTRA_DIST = scripts/config.rpath autogen.sh README.SVN DISTCLEANFILES = g10defs.h if BUILD_GPGSM kbx = kbx else kbx = endif if BUILD_GPG gpg = g10 keyserver = keyserver else gpg = keyserver = endif if BUILD_GPGSM sm = sm else sm = endif if BUILD_AGENT agent = agent else agent = endif if BUILD_SCDAEMON scd = scd else scd = endif if BUILD_G13 g13 = g13 else g13 = endif if BUILD_TOOLS tools = tools else tools = endif if BUILD_DOC doc = doc else doc = endif if HAVE_W32_SYSTEM tests = else tests = tests endif -SUBDIRS = m4 gl include jnlib common ${kbx} \ +SUBDIRS = m4 gl include common ${kbx} \ ${gpg} ${keyserver} ${sm} ${agent} ${scd} ${g13} ${tools} po ${doc} ${tests} dist_doc_DATA = README dist-hook: echo "$(VERSION)" > $(distdir)/VERSION stowinstall: $(MAKE) $(AM_MAKEFLAGS) install prefix=/usr/local/stow/gnupg diff --git a/acinclude.m4 b/acinclude.m4 index d8f2e174b..28366ee38 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -1,308 +1,309 @@ dnl macros to configure gnupg dnl Copyright (C) 1998, 1999, 2000, 2001, 2003 Free Software Foundation, Inc. dnl dnl This file is part of GnuPG. dnl dnl GnuPG is free software; you can redistribute it and/or modify dnl it under the terms of the GNU General Public License as published by dnl the Free Software Foundation; either version 3 of the License, or dnl (at your option) any later version. dnl dnl GnuPG 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 dnl GNU General Public License for more details. dnl dnl You should have received a copy of the GNU General Public License dnl along with this program; if not, see . dnl GNUPG_CHECK_TYPEDEF(TYPE, HAVE_NAME) dnl Check whether a typedef exists and create a #define $2 if it exists dnl AC_DEFUN([GNUPG_CHECK_TYPEDEF], [ AC_MSG_CHECKING(for $1 typedef) AC_CACHE_VAL(gnupg_cv_typedef_$1, [AC_TRY_COMPILE([#define _GNU_SOURCE 1 #include #include ], [ #undef $1 int a = sizeof($1); ], gnupg_cv_typedef_$1=yes, gnupg_cv_typedef_$1=no )]) AC_MSG_RESULT($gnupg_cv_typedef_$1) if test "$gnupg_cv_typedef_$1" = yes; then AC_DEFINE($2,1,[Defined if a `]$1[' is typedef'd]) fi ]) dnl GNUPG_CHECK_GNUMAKE dnl AC_DEFUN([GNUPG_CHECK_GNUMAKE], [ if ${MAKE-make} --version 2>/dev/null | grep '^GNU ' >/dev/null 2>&1; then : else AC_MSG_WARN([[ *** *** It seems that you are not using GNU make. Some make tools have serious *** flaws and you may not be able to build this software at all. Before you *** complain, please try GNU make: GNU make is easy to build and available *** at all GNU archives. It is always available from ftp.gnu.org:/gnu/make. ***]]) fi ]) dnl GNUPG_CHECK_FAQPROG dnl AC_DEFUN([GNUPG_CHECK_FAQPROG], [ AC_MSG_CHECKING(for faqprog.pl) if faqprog.pl -V 2>/dev/null | grep '^faqprog.pl ' >/dev/null 2>&1; then working_faqprog=yes FAQPROG="faqprog.pl" else working_faqprog=no FAQPROG=": " fi AC_MSG_RESULT($working_faqprog) AC_SUBST(FAQPROG) AM_CONDITIONAL(WORKING_FAQPROG, test "$working_faqprog" = "yes" ) dnl if test $working_faqprog = no; then dnl AC_MSG_WARN([[ dnl *** dnl *** It seems that the faqprog.pl program is not installed; dnl *** however it is only needed if you want to change the FAQ. dnl *** (faqprog.pl should be available at: dnl *** ftp://ftp.gnupg.org/gcrypt/contrib/faqprog.pl ) dnl *** No need to worry about this warning. dnl ***]]) dnl fi ]) dnl GNUPG_CHECK_DOCBOOK_TO_TEXI dnl AC_DEFUN([GNUPG_CHECK_DOCBOOK_TO_TEXI], [ AC_CHECK_PROG(DOCBOOK_TO_TEXI, docbook2texi, yes, no) AC_MSG_CHECKING(for sgml to texi tools) working_sgmltotexi=no if test "$ac_cv_prog_DOCBOOK_TO_TEXI" = yes; then if sgml2xml -v /dev/null 2>&1 | grep 'SP version' >/dev/null 2>&1 ; then working_sgmltotexi=yes fi fi AC_MSG_RESULT($working_sgmltotexi) AM_CONDITIONAL(HAVE_DOCBOOK_TO_TEXI, test "$working_sgmltotexi" = "yes" ) ]) dnl GNUPG_CHECK_ENDIAN dnl define either LITTLE_ENDIAN_HOST or BIG_ENDIAN_HOST dnl AC_DEFUN([GNUPG_CHECK_ENDIAN], [ tmp_assumed_endian=big + tmp_assume_warn="" if test "$cross_compiling" = yes; then case "$host_cpu" in i@<:@345678@:>@* ) tmp_assumed_endian=little ;; *) ;; esac - AC_MSG_WARN(cross compiling; assuming $tmp_assumed_endian endianess) fi AC_MSG_CHECKING(endianess) AC_CACHE_VAL(gnupg_cv_c_endian, [ gnupg_cv_c_endian=unknown # See if sys/param.h defines the BYTE_ORDER macro. AC_TRY_COMPILE([#include #include ], [ #if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN bogus endian macros #endif], [# It does; now see whether it defined to BIG_ENDIAN or not. AC_TRY_COMPILE([#include #include ], [ #if BYTE_ORDER != BIG_ENDIAN not big endian #endif], gnupg_cv_c_endian=big, gnupg_cv_c_endian=little)]) if test "$gnupg_cv_c_endian" = unknown; then AC_TRY_RUN([main () { /* Are we little or big endian? From Harbison&Steele. */ union { long l; char c[sizeof (long)]; } u; u.l = 1; exit (u.c[sizeof (long) - 1] == 1); }], gnupg_cv_c_endian=little, gnupg_cv_c_endian=big, gnupg_cv_c_endian=$tmp_assumed_endian + tmp_assumed_warn=" (assumed)" ) fi ]) - AC_MSG_RESULT([$gnupg_cv_c_endian]) + AC_MSG_RESULT([${gnupg_cv_c_endian}${tmp_assumed_warn}]) if test "$gnupg_cv_c_endian" = little; then AC_DEFINE(LITTLE_ENDIAN_HOST,1, [Defined if the host has little endian byte ordering]) else AC_DEFINE(BIG_ENDIAN_HOST,1, [Defined if the host has big endian byte ordering]) fi ]) # GNUPG_BUILD_PROGRAM(NAME,DEFAULT) # Add a --enable-NAME option to configure an set the # shell variable build_NAME either to "yes" or "no". DEFAULT must # either be "yes" or "no" and decided on the default value for # build_NAME and whether --enable-NAME or --disable-NAME is shown with # ./configure --help AC_DEFUN([GNUPG_BUILD_PROGRAM], [build_$1=$2 m4_if([$2],[yes],[ AC_ARG_ENABLE([$1], AC_HELP_STRING([--disable-$1], [do not build the $1 program]), build_$1=$enableval, build_$1=$2) ],[ AC_ARG_ENABLE([$1], AC_HELP_STRING([--enable-$1], [build the $1 program]), build_$1=$enableval, build_$1=$2) ]) case "$build_$1" in no|yes) ;; *) AC_MSG_ERROR([only yes or no allowed for feature --enable-$1]) ;; esac ]) # Check whether mlock is broken (hpux 10.20 raises a SIGBUS if mlock # is not called from uid 0 (not tested whether uid 0 works) # For DECs Tru64 we have also to check whether mlock is in librt # mlock is there a macro using memlk() dnl GNUPG_CHECK_MLOCK dnl AC_DEFUN([GNUPG_CHECK_MLOCK], [ AC_CHECK_FUNCS(mlock) if test "$ac_cv_func_mlock" = "no"; then AC_CHECK_HEADERS(sys/mman.h) if test "$ac_cv_header_sys_mman_h" = "yes"; then # Add librt to LIBS: AC_CHECK_LIB(rt, memlk) AC_CACHE_CHECK([whether mlock is in sys/mman.h], gnupg_cv_mlock_is_in_sys_mman, [AC_TRY_LINK([ #include #ifdef HAVE_SYS_MMAN_H #include #endif ], [ int i; /* glibc defines this for functions which it implements * to always fail with ENOSYS. Some functions are actually * named something starting with __ and the normal name * is an alias. */ #if defined (__stub_mlock) || defined (__stub___mlock) choke me #else mlock(&i, 4); #endif ; return 0; ], gnupg_cv_mlock_is_in_sys_mman=yes, gnupg_cv_mlock_is_in_sys_mman=no)]) if test "$gnupg_cv_mlock_is_in_sys_mman" = "yes"; then AC_DEFINE(HAVE_MLOCK,1, [Defined if the system supports an mlock() call]) fi fi fi if test "$ac_cv_func_mlock" = "yes"; then AC_MSG_CHECKING(whether mlock is broken) AC_CACHE_VAL(gnupg_cv_have_broken_mlock, AC_TRY_RUN([ #include #include #include #include #include #include int main() { char *pool; int err; long int pgsize = getpagesize(); pool = malloc( 4096 + pgsize ); if( !pool ) return 2; pool += (pgsize - ((long int)pool % pgsize)); err = mlock( pool, 4096 ); if( !err || errno == EPERM ) return 0; /* okay */ return 1; /* hmmm */ } ], gnupg_cv_have_broken_mlock="no", gnupg_cv_have_broken_mlock="yes", gnupg_cv_have_broken_mlock="assume-no" ) ) if test "$gnupg_cv_have_broken_mlock" = "yes"; then AC_DEFINE(HAVE_BROKEN_MLOCK,1, [Defined if the mlock() call does not work]) AC_MSG_RESULT(yes) AC_CHECK_FUNCS(plock) else if test "$gnupg_cv_have_broken_mlock" = "no"; then AC_MSG_RESULT(no) else AC_MSG_RESULT(assuming no) fi fi fi ]) dnl Stolen from gcc dnl Define MKDIR_TAKES_ONE_ARG if mkdir accepts only one argument instead dnl of the usual 2. AC_DEFUN([GNUPG_FUNC_MKDIR_TAKES_ONE_ARG], [AC_CHECK_HEADERS(sys/stat.h unistd.h direct.h) AC_CACHE_CHECK([if mkdir takes one argument], gnupg_cv_mkdir_takes_one_arg, [AC_TRY_COMPILE([ #include #ifdef HAVE_SYS_STAT_H # include #endif #ifdef HAVE_UNISTD_H # include #endif #ifdef HAVE_DIRECT_H # include #endif], [mkdir ("foo", 0);], gnupg_cv_mkdir_takes_one_arg=no, gnupg_cv_mkdir_takes_one_arg=yes)]) if test $gnupg_cv_mkdir_takes_one_arg = yes ; then AC_DEFINE(MKDIR_TAKES_ONE_ARG,1, [Defined if mkdir() does not take permission flags]) fi ]) diff --git a/agent/ChangeLog b/agent/ChangeLog index 0c68c1436..e4fbe073b 100644 --- a/agent/ChangeLog +++ b/agent/ChangeLog @@ -1,2544 +1,2550 @@ +2010-03-10 Werner Koch + + * Makefile.am (common_libs): Remove libjnlib.a. + + * trustlist.c, protect-tool.c, command-ssh.c: Remove estream.h. + 2010-02-17 Werner Koch * call-pinentry.c (start_pinentry): Always free OPTSTR. Send default-xxx strings. 2010-01-26 Werner Koch * protect.c (do_encryption): Encode the s2kcount and no not use a static value of 96. 2009-12-21 Werner Koch * command.c (cmd_getinfo): Add sub-command s2k_count. 2009-12-14 Werner Koch * protect.c (agent_unprotect): Decode the S2K count here and take care of the new unencoded values. Add a lower limit sanity check. (hash_passphrase): Do not decode here. (get_standard_s2k_count, calibrate_s2k_count): New. (calibrate_get_time, calibrate_elapsed_time): New. (do_encryption): Use get_standard_s2k_count. 2009-12-08 Werner Koch * protect.c (agent_unprotect): Avoid compiler warning. 2009-12-08 Marcus Brinkmann * call-pinentry.c (start_pinentry): Convert posix fd to assuan fd. * call-scd.c (start_scd): Likewise. 2009-12-03 Werner Koch * gpg-agent.c (set_debug): Allow for numerical debug leveles. Print active debug flags. 2009-12-02 Werner Koch * trustlist.c (read_trustfiles): Store the pointer returned from shrinking the memory and not the orginal one. Fixes bug#1163. Reported by TAKAHASHI Tamotsu. Also return correct error after memory failure. 2009-11-27 Marcus Brinkmann * command.c (start_command_handler): Do not call assuan_set_log_stream anymore. * gpg-agent.c (main): But call assuan_set_assuan_log_stream here. 2009-11-25 Marcus Brinkmann * command.c (start_command_handler): Use assuan_fd_t and assuan_fdopen on fds. 2009-11-05 Marcus Brinkmann * call-pinentry.c (start_pinentry): Call assuan_pipe_connect, not assuan_pipe_connect_ext. * command.c (start_command_handler): Change assuan_init_socket_server_ext into assuan_init_socket_server. * call-scd.c (start_scd): Update use of assuan_socket_connect and assuan_pipe_connect. * gpg-agent.c (check_own_socket_thread, check_for_running_agent): Update use of assuan_socket_connect. 2009-11-04 Werner Koch * command.c (register_commands): Add help arg to assuan_register_command. Convert all command comments to help strings. 2009-11-02 Marcus Brinkmann * command.c (reset_notify): Take LINE arg and return error. (register_commands): Use assuan_handler_t type. 2009-10-16 Marcus Brinkmann * gpg_agent_CFLAGS, gpg_agent_LDADD: Use libassuan instead of libassuan-pth. * gpg-agent.c: Invoke ASSUAN_SYSTEM_PTH_IMPL. (main): Call assuan_set_system_hooks and assuan_sock_init. Fix invocation of assuan_socket_connect. 2009-09-23 Werner Koch * command.c (register_commands) [HAVE_ASSUAN_SET_IO_MONITOR]: Remove cpp condition. (start_command_handler) [HAVE_ASSUAN_SET_IO_MONITOR]: Ditto. 2009-09-23 Marcus Brinkmann * gpg-agent.c (parse_rereadable_options): Don't set global assuan log file (there ain't one anymore). (main): Update to new API. (check_own_socket_pid_cb): Return gpg_error_t instead of int. (check_own_socket_thread, check_for_running_agent): Create assuan context before connecting to server. * command.c: Include "scdaemon.h" before because of GPG_ERR_SOURCE_DEFAULT check. (write_and_clear_outbuf): Use gpg_error_t instead of assuan_error_t. (cmd_geteventcounter, cmd_istrusted, cmd_listtrusted) (cmd_marktrusted, cmd_havekey, cmd_sigkey, cmd_setkeydesc) (cmd_sethash, cmd_pksign, cmd_pkdecrypt, cmd_genkey, cmd_readkey) (cmd_keyinfo, cmd_get_passphrase, cmd_clear_passphrase) (cmd_get_confirmation, cmd_learn, cmd_passwd) (cmd_preset_passphrase, cmd_scd, cmd_getval, cmd_putval) (cmd_updatestartuptty, cmd_killagent, cmd_reloadagent) (cmd_getinfo, option_handler): Return gpg_error_t instead of int. (post_cmd_notify): Change type of ERR to gpg_error_t from int. (io_monitor): Add hook argument. Use symbols for constants. (register_commands): Change return type of HANDLER to gpg_error_t. (start_command_handler): Allocate assuan context before starting server. * call-pinentry.c: Include "scdaemon.h" before because of GPG_ERR_SOURCE_DEFAULT check. (unlock_pinentry): Call assuan_release instead of assuan_disconnect. (getinfo_pid_cb, getpin_cb): Return gpg_error_t instead of int. (start_pinentry): Allocate assuan context before connecting to server. * call-scd.c (membuf_data_cb, learn_status_cb, get_serialno_cb) (membuf_data_cb, inq_needpin, card_getattr_cb, pass_status_thru) (pass_data_thru): Change return type to gpg_error_t. (start_scd): Allocate assuan context before connecting to server. 2009-09-04 Marcus Brinkmann * command.c (start_command_handler): Add comment about gap in implementation (in dead code), for future reference. 2009-08-11 Werner Koch * divert-scd.c (ask_for_card): I18n a prompt string. 2009-07-06 Werner Koch * agent.h: Include session-env.h. (opt): Replace most of the startup_xxx fields by a session_env_t. (struct server_control_s): Likewise. * gpg-agent.c (main): Rewrite setting of the startup fields. (handle_connections, main): Allocate SESSION_ENV. (agent_init_default_ctrl, agent_deinit_default_ctrl): Change accordingly. * command.c (option_handler): Ditto. (cmd_updatestartuptty): Change accordingly. Protect old values from out of core failures. * command-ssh.c (start_command_handler_ssh): Ditto. (start_command_handler_ssh): Replace strdup by xtrystrdup. * call-pinentry.c (atfork_cb): Pass new envrinmnet variables. (start_pinentry): Use session_env stuff. * protect-tool.c (main): Adjust call to gnupg_prepare_get_passphrase. 2009-06-24 Werner Koch * genkey.c (agent_protect_and_store): Return RC and not 0. * protect.c (do_encryption): Fix ignored error code from malloc. Reported by Fabian Keil. 2009-06-17 Werner Koch * call-pinentry.c (agent_get_confirmation): Add arg WITH_CANCEL. Change all callers. * trustlist.c (agent_marktrusted): Use WITH_CANCEL 2009-06-09 Werner Koch * learncard.c (send_cert_back): Ignore certain error codes. 2009-06-05 Werner Koch * protect-tool.c (store_private_key): Fix last change by appending a ".key". 2009-06-03 Werner Koch * protect-tool.c: Include estream.h. (store_private_key): Replace stdio streams by estream functions for a portable use of the "x" mode. * trustlist.c: Include estream.h. (agent_marktrusted): Replace stdio stream by estream functions. * protect-tool.c (store_private_key): Use bin2hex. 2009-06-02 Werner Koch * gpg-agent.c (main): Run pth_kill after fork. Fixes bug#1066. 2009-05-19 Werner Koch * gpg-agent.c (JNLIB_NEED_AFLOCAL): Define. (create_server_socket): Use SUN_LEN macro. 2009-05-15 Werner Koch Fix bug #1053. * agent.h (lookup_ttl_t): New. * findkey.c (unprotect): Add arg LOOKUP_TTL. (agent_key_from_file): Ditto. * pksign.c (agent_pksign_do): Ditto. * command-ssh.c (ttl_from_sshcontrol): New. (data_sign): Pass new function to agent_pksign_do. (search_control_file): Add new arg R_TTL. 2009-05-14 Werner Koch * command.c (cmd_get_passphrase): Add option --qualitybar. * call-pinentry.c (agent_askpin): Factor some code out to ... (setup_qualitybar): .. new. (agent_get_passphrase): Add arg WITH_QUALITYBAR and implement it. 2009-04-14 Marcus Brinkmann * call-pinentry.c (agent_get_confirmation): Try SETNOTOK command with pinentry. 2009-04-01 Werner Koch * protect-tool.c (pe_opt): New. (opts): Add option --agent-program. Use ARGPARSE macros. (get_new_passphrase): Remove. (get_passphrase): Use gpg-agent directly. Remove arg OPT_CHECK and change all callers. * Makefile.am (gpg_protect_tool_LDADD): Replace pwquery_libs by LIBASSUAN_LIBS. (gpg_protect_tool_CFLAGS): New. * command.c (percent_plus_unescape): Remove. (cmd_putval): Use percent_plus_unescape_inplace. * call-scd.c (unescape_status_string): Remove. (card_getattr_cb): Use percent_plus_unescape. * protect-tool.c (main): Use percent_plus_unescape from common/. (percent_plus_unescape, percent_plus_unescape_string): Remove. 2009-03-27 Werner Koch * learncard.c (agent_handle_learn): Add new certtype 111. 2009-03-26 Werner Koch * agent.h (MAX_DIGEST_LEN): Change to 64. * command.c (cmd_sethash): Allow digest length of 48 and 64. (cmd_sethash): Allow more hash algos. * trustlist.c (reformat_name): New. (agent_marktrusted): Use a reformatted name. Reload the table before the update and always reload it at the end. (agent_istrusted): Check early for the disabled flag. 2009-03-25 Werner Koch * pkdecrypt.c (agent_pkdecrypt): Return a specific error message if the key is not available. * gpg-agent.c (main): Print a started message to show the real pid. 2009-03-20 Werner Koch * learncard.c (struct kpinfo_cp_parm_s): Add field CTRL. (struct certinfo_cb_parm_s): Ditto. (agent_handle_learn): Set CTRL field. (kpinfo_cb, certinfo_cb): Send progress status. * agent.h (agent_write_status): Flag with GNUPG_GCC_A_SENTINEL. 2009-03-19 Werner Koch * trustlist.c (struct trustitem_s): Add field DISABLED. (read_one_trustfile): Parse the '!' flag. (agent_istrusted, agent_listtrusted): Check flag. (agent_istrusted): Add arg R_DISABLED. Change all callers. (agent_marktrusted): Do not ask if flagged as disabled. Reverse the order of the questions. Store the disabled flag. * gpg-agent.c (main): Save signal mask and open fds. Restore mask and close all fds prior to the exec. Fixes bug#1013. 2009-03-17 Werner Koch * command.c (cmd_get_passphrase): Break repeat loop on error. Show error message. (cmd_getinfo): Add subcommand "cmd_has_option". (command_has_option): New. 2009-03-17 Daiki Ueno * command.c (option_value): New function. (cmd_get_passphrase): Accept new option --repeat, which makes gpg-agent to ask passphrase several times. 2009-03-06 Werner Koch * command.c (cmd_keyinfo): New command. (register_commands): Register it. (agent_write_status): Make sure not to print LR or CR. * divert-scd.c (ask_for_card): Factor shadow info parsing out to ... * protect.c (parse_shadow_info): New. * findkey.c (agent_key_from_file): Use make_canon_sexp. (agent_write_private_key, unprotect, read_key_file) (agent_key_available): Use bin2hex. (agent_key_info_from_file): New. (read_key_file): Log no error message for ENOENT. 2009-03-05 Werner Koch * divert-scd.c (getpin_cb): Support flag 'P'. Change max_digits from 8 to 16. Append a message about keypads. * findkey.c (unprotect): Change max digits to 16. 2009-03-02 Werner Koch * command.c (cmd_getinfo): Add subcommand "scd_running". * call-scd.c (agent_scd_check_running): New. * gpg-agent.c: Add missing option strings for "--batch" and "--homedir". Reported by Petr Uzel. * protect-tool.c (import_p12_file): Take care of canceled passphrase entry. Fixes bug#1003. (export_p12_file): Ditto. 2008-12-17 Werner Koch * gpg-agent.c (handle_connections): Set action of all pth event handled signals to SIG_IGN. Use a different pth_sigmask strategy. 2008-12-10 Werner Koch * command.c (cmd_get_passphrase): Implement option --no-ask. 2008-12-09 Werner Koch * gpg-agent.c (main): Call i18n_init before init_common_subsystems. * preset-passphrase.c (main): Ditto. * protect-tool.c (main): Ditto. * command.c (cmd_preset_passphrase): Allow an arbitrary string for the cache id. 2008-12-08 Werner Koch * gpg-agent.c (handle_connections): Sync the ticker to the next full second. This is bug#871. 2008-12-05 Werner Koch * minip12.c (decrypt_block): Fix const modified of CHARSETS. * learncard.c (sinfo_cb_parm_s): Remove superflous semicolon. Reported by Stoyan Angelov. 2008-11-18 Werner Koch * gpg-agent.c (make_libversion): New. (my_strusage): Print libgcrypt version 2008-11-11 Werner Koch * call-scd.c (membuf_data_cb): Change return type to assuan_error_t to avoid warnings with newer libassuan versions. 2008-11-04 Werner Koch * command.c (cmd_killagent): Stop the agent immediately. (start_command_handler): Take care of GPG_ERR_EOF. 2008-10-29 Werner Koch * gpg-agent.c (main): Move USE_STANDARD_SOCKET to the outer scope. (create_socket_name): Remove arg USE_STANDARD_SOCKET. Change all callers. (create_server_socket): Remove IS_STANDARD_NAME and replace it by USE_STANDARD_SOCKET. Change all callers. (check_own_socket_running): New. (check_own_socket, check_own_socket_thread): New. (handle_tick): Check server socket once a minute. (handle_connections): Remove the extra pth_wait in the shutdown case. 2008-10-20 Werner Koch * command.c (cmd_geteventcounter): Mark unused arg. (cmd_listtrusted, cmd_pksign, cmd_pkdecrypt, cmd_genkey): Ditto. (cmd_updatestartuptty, post_cmd_notify): Ditto. * command-ssh.c (add_control_entry) (ssh_handler_request_identities, ssh_handler_remove_identity) (ssh_handler_remove_all_identities, ssh_handler_lock) (ssh_handler_unlock): Ditto. * call-pinentry.c (pinentry_active_p, popup_message_thread) (agent_popup_message_stop): Ditto. * findkey.c (agent_public_key_from_file): Ditto. * genkey.c (check_passphrase_pattern): Ditto. * call-scd.c (atfork_cb): Ditto. * protect-tool.c (import_p12_cert_cb): Ditto. * t-protect.c (main): Ditto. 2008-10-17 Werner Koch * call-scd.c (start_scd) [W32]: Use snprintf again because we now always use the estream variant. 2008-10-15 Werner Koch * call-scd.c (start_scd): Enable assuan loggging if requested. (agent_scd_check_aliveness) [W32]: Fix use of GetExitCodeProcess. 2008-10-14 Werner Koch * gpg-agent.c (get_agent_scd_notify_event): Need to use a manual reset event. 2008-09-29 Werner Koch * agent.h (GCRY_MD_USER): Rename to GCRY_MODULE_ID_USER. (GCRY_MD_USER_TLS_MD5SHA1): Rename to MD_USER_TLS_MD5SHA1 and change all users. 2008-09-25 Werner Koch * divert-scd.c (getpin_cb): Support a Reset Code style PINs.. 2008-09-03 Werner Koch * command.c (parse_keygrip): Use hex2bin. (cmd_preset_passphrase): Decode the passphrase. Reported by Kiss Gabor. Fixes #679 again. * preset-passphrase.c (make_hexstring): Remove. (preset_passphrase): Use bin2hex. 2008-05-27 Werner Koch * trustlist.c (insert_colons): Fix stupidly wrong allocation size computation. 2008-05-26 Werner Koch * gpg-agent.c (main): Re-initialize default assuan log stream if a log file is used. * trustlist.c (agent_marktrusted): Use xtryasprintf and xfree. * gpg-agent.c (main, agent_deinit_default_ctrl): Always use xfree because our asprintf is mapped to an xmalloc style function in util.h. Replace xstrdup by xtrystrdup. * w32main.c (build_argv): Ditto. * preset-passphrase.c (preset_passphrase): Ditto. * divert-scd.c (ask_for_card): Ditto. * command.c (option_handler): Ditto. * command-ssh.c (ssh_handler_request_identities): Ditto. * call-pinentry.c (start_pinentry): Ditto. * gpg-agent.c (start_connection_thread) (start_connection_thread_ssh): Use pth_thread_id for useful output under W32. (pth_thread_id) [!PTH_HAVE_PTH_THREAD_ID]: New. 2008-03-17 Werner Koch * agent.h (agent_inq_pinentry_launched): New prototype. * call-pinentry.c: Include sys/types.h and signal.h. 2008-02-14 Werner Koch * command.c (agent_inq_pinentry_launched): New. (option_handler): Add option allow-pinentry-notify. * call-pinentry.c (getinfo_pid_cb): New. (start_pinentry): Ask for the PID and notify the client. 2008-01-15 Marcus Brinkmann * call-pinentry.c (start_pinentry): Start pinentry in detached mode. 2007-12-04 Werner Koch * call-pinentry.c (agent_askpin): Use gnupg_get_help_string. 2007-12-03 Werner Koch * gpg-agent.c (main): s/standard_socket/use_standard_socket/ for clarity. (create_server_socket): New arg IS_SSH to avoid testing with assuan commands. 2007-11-20 Werner Koch * gpg-agent.c (get_agent_scd_notify_event): New. (handle_signal): Factor SIGUSR2 code out to: (agent_sigusr2_action): .. New. (agent_sighup_action): Print info message here and not in handle_signal. (handle_connections) [PTH_EVENT_HANDLE]: Call agent_sigusr2_action. * call-scd.c (agent_scd_check_aliveness) [W32]: Implemented. (start_scd) [W32]: Send event-signal option. 2007-11-19 Werner Koch * call-pinentry.c (agent_askpin): Set the tooltip for the quality bar. 2007-11-15 Werner Koch * agent.h (struct server_control_s): Add XAUTHORITY and PINENTRY_USER_DATA. * gpg-agent.c: New option --xauthority. (main, agent_init_default_ctrl) (agent_deinit_default_ctrl): Implemented * command.c (cmd_updatestartuptty): Ditto. * command-ssh.c (start_command_handler_ssh): Ditto. * call-pinentry.c (atfork_cb): Set the environment. (start_pinentry): Pass CTRL as arg to atfork_cb. 2007-11-14 Werner Koch * call-scd.c (start_scd) [W32]: Take care of fflush peculiarities. 2007-11-07 Werner Koch * agent.h: Remove errors.h. 2007-10-24 Werner Koch * genkey.c (check_passphrase_constraints): Changed the wording of the warning messages. 2007-10-19 Werner Koch * protect-tool.c (get_passphrase): Use new utf8 switch fucntions. 2007-10-15 Daiki Ueno (wk) * command-ssh.c (reenter_compare_cb): New function; imported from genkey.c. (ssh_identity_register): Ask initial passphrase twice. 2007-10-02 Werner Koch * command.c (cmd_getinfo): Add "pid" subcommand. 2007-10-01 Werner Koch * agent.h (struct server_control_s): Remove unused CONNECTION_FD. * gpg-agent.c: Remove w32-afunix.h. Include mkdtemp.h. (socket_nonce, socket_nonce_ssh): New. (create_server_socket): Use assuan socket wrappers. Remove W32 specific stuff. Save the server nonce. (check_nonce): New. (start_connection_thread, start_connection_thread_ssh): Call it. (handle_connections): Change args to gnupg_fd_t. * command.c (start_command_handler): Change LISTEN_FD to gnupg_fd_t. * command-ssh.c (start_command_handler_ssh): Ditto. 2007-09-18 Werner Koch * agent.h (struct pin_entry_info_s): Add element WITH_QUALITYBAR. * genkey.c (check_passphrase_constraints): New arg SILENT. Changed all callers. (agent_protect_and_store, agent_genkey): Enable qualitybar. * call-pinentry.c (agent_askpin): Send that option. (unescape_passphrase_string): New. (inq_quality): New. (estimate_passphrase_quality): New. 2007-09-14 Marcus Brinkmann * call-pinentry.c (agent_popup_message_stop): Implement kill for Windows. 2007-08-28 Werner Koch * gpg-agent.c (main): Add option --faked-system-time. * protect-tool.c (read_and_unprotect): Print the protected-at date. * agent.h (struct server_control_s): Add member IN_PASSWD. * command.c (cmd_passwd): Set it. * findkey.c (try_unprotect_cb): Use it. * protect.c (do_encryption): Replace asprintf by xtryasprint. (agent_protect): Create the protected-at item. (agent_unprotect): Add optional arg PROTECTED_AT. (merge_lists): Add args CUTOFF and CUTLEN. (agent_unprotect): Use them. * findkey.c (try_unprotect_cb): Add code to test for expired keys. (unprotect): Allow changing the passphrase. 2007-08-27 Werner Koch * gpg-agent.c: Add options --min-passphrase-nonalpha, --check-passphrase-pattern and --enforce-passphrase-constraints. (MIN_PASSPHRASE_NONALPHA): Init nonalpha option to 1. (main): Declare options for gpgconf. * agent.h (struct): Add members MIN_PASSPHRASE_NONALPHA, ENFORCE_PASSPHRASE_CONSTRAINTS and CHECK_PASSPHRASE_PATTERN. * genkey.c (nonalpha_charcount): New. (check_passphrase_pattern): New. (check_passphrase_constraints): Implement. Factor some code out... (take_this_one_anyway, take_this_one_anyway2): .. New. * call-pinentry.c (agent_show_message): New. (agent_askpin): We better reset the pin buffer before asking. * trustlist.c (insert_colons): New. (agent_marktrusted): Pretty print the fpr. 2007-08-22 Werner Koch * findkey.c (O_BINARY): Make sure it is defined. (agent_write_private_key): Use O_BINARY * protect-tool.c (import_p12_file): Add hack to allow importing of gnupg 2.0.4 generated files. 2007-08-06 Werner Koch * trustlist.c (read_one_trustfile): Add flag "cm". (agent_istrusted): Ditto. 2007-08-02 Werner Koch * gpg-agent.c: Include gc-opt-flags.h and remove their definition here. 2007-07-13 Werner Koch * genkey.c (check_passphrase_constraints): Require a confirmation for an empty passphrase. (agent_genkey, agent_protect_and_store): No need to repeat an empty passphrase. 2007-07-05 Werner Koch * call-scd.c (struct inq_needpin_s): New. (inq_needpin): Pass unknown inquiries up. 2007-07-04 Werner Koch * gpg-agent.c (TIMERTICK_INTERVAL): New. (fixed_gcry_pth_init, main): Kludge to fix Pth initialization. 2007-07-03 Werner Koch * gpg-agent.c (handle_connections): Do not use FD_SETSIZE for select but compute the correct number. 2007-07-02 Werner Koch * command.c (cmd_reloadagent) [W32]: New. (register_commands) [W32]: New command RELOADAGENT. * Makefile.am (gpg_agent_SOURCES): Remove w32main.c and w32main.h. (gpg_agent_res_ldflags): Remove icon file as we don't have a proper icon yet. * gpg-agent.c (main): do not include w32main.h. Remove all calls to w32main.c. (agent_sighup_action): New. (handle_signal): Use it. 2007-06-26 Werner Koch * gpg-agent.c (create_directories) [W32]: Made it work. 2007-06-21 Werner Koch * agent.h (ctrl_t): Remove. It is now declared in ../common/util.h. * gpg-agent.c (check_for_running_agent): New arg SILENT. Changed all callers. (create_server_socket): If the standard socket is in use check whether a agent is running and avoid starting another one. 2007-06-18 Marcus Brinkmann * gpg-agent.c (main): Percent escape pathname in --gpgconf-list output. 2007-06-18 Werner Koch * w32main.c (build_argv): New. (WinMain): Use it. * command.c (cmd_killagent) [W32]: New. (cmd_getinfo): New. * gpg-agent.c (get_agent_ssh_socket_name): New. (no_force_standard_socket) New. (create_server_socket): Use it. * Makefile.am (gpg_agent_res_ldflags): Pass windows option to ld. 2007-06-14 Werner Koch * protect-tool.c (main): Setup default socket name for simple-pwquery. (MAP_SPWQ_ERROR_IMPL): New. Use map_spwq_error for spqw related error codes. * preset-passphrase.c (main): Setup default socket name for simple-pwquery. (map_spwq_error): Remove. (MAP_SPWQ_ERROR_IMPL): New. * call-pinentry.c (start_pinentry): Use gnupg_module_name. * call-scd.c (start_scd): Ditto. 2007-06-12 Werner Koch * taskbar.c: New. * trustlist.c (read_one_trustfile): Replace GNUPG_SYSCONFDIR by a function call. (read_trustfiles): Ditto. * gpg-agent.c (main): Replace some calls by init_common_subsystems. * preset-passphrase.c (main): Ditto. * protect-tool.c (main): Ditto. 2007-06-11 Werner Koch * Makefile.am (common_libs): Use libcommonstd macro. (commonpth_libs): Use libcommonpth macro. * protect-tool.c (main) [W32]: Call pth_init. * preset-passphrase.c (main) [W32]: Replace the explicit Winsocket init by a call to pth_init. * trustlist.c (initialize_module_trustlist): New. * gpg-agent.c (main): Call it. * call-pinentry.c (initialize_module_query): Rename to initialize_module_call_pinentry. * minip12.c: Remove iconv.h. Add utf8conf.h. Changed all iconv calss to use these jnlib wrappers. 2007-06-06 Werner Koch * minip12.c (enum): Rename CONTEXT to ASNCONTEXT as winnt.h defines such a symbol to access the process context. * call-pinentry.c (dump_mutex_state) [W32]: Handle the W32Pth case. * call-scd.c (dump_mutex_state): Ditto. * protect-tool.c (i18n_init): Remove. * preset-passphrase.c (i18n_init): Remove. * gpg-agent.c (i18n_init): Remove. 2007-05-19 Marcus Brinkmann * protect-tool.c (get_passphrase): Free ORIG_CODESET on error. 2007-05-14 Werner Koch * protect.c (make_shadow_info): Replace sprintf by smklen. 2007-04-20 Werner Koch * gpg-agent.c (my_gcry_logger, my_gcry_outofcore_handler): Removed. (main): Call the setup_libgcrypt_logging helper. * protect-tool.c (my_gcry_logger): Removed. (main): Call the setup_libgcrypt_logging helper. 2007-04-03 Werner Koch * trustlist.c (read_trustfiles): Take a missing trustlist as an empty one. 2007-03-20 Werner Koch * protect-tool.c: New option --p12-charset. * minip12.c (p12_build): Implement it. 2007-03-19 Werner Koch * minip12.c: Include iconv.h. (decrypt_block): New. (parse_bag_encrypted_data, parse_bag_data): Use it here. (bag_data_p, bag_decrypted_data_p): New helpers. 2007-03-06 Werner Koch * gpg-agent.c (main) : Add entries for all ttl options. 2007-02-20 Werner Koch * call-pinentry.c (start_pinentry): Fix for OS X to allow loading of the bundle. Tested by Benjamin Donnachie. 2007-02-14 Werner Koch * gpg-agent.c: New option --pinentry-touch-file. (get_agent_socket_name): New. * agent.h (opt): Add pinentry_touch_file. * call-pinentry.c (start_pinentry): Send new option to the pinentry. 2007-01-31 Moritz Schulte (wk) * command-ssh.c (stream_read_string): Initialize LENGTH to zero. (start_command_handler_ssh): Use es_fgetc/es_ungetc to check if EOF has been reached before trying to process another request. 2007-01-31 Werner Koch * command-ssh.c (start_command_handler_ssh): * Makefile.am (t_common_ldadd): Add LIBICONV. 2007-01-25 Werner Koch * genkey.c (check_passphrase_constraints): Get ngettext call right and use UTF-8 aware strlen. * protect-tool.c (get_passphrase): New arg OPT_CHECK. (get_new_passphrase): Enable OPT_CHECK on the first call. * command.c (cmd_get_passphrase): Implement option --check. 2007-01-24 Werner Koch * gpg-agent.c (MIN_PASSPHRASE_LEN): New (parse_rereadable_options): New option --min-passphrase-len. * genkey.c (check_passphrase_constraints): New. (agent_genkey, agent_protect_and_store): Call new function. Fix memory leak. * call-pinentry.c (agent_askpin): Allow translation of the displayed error message. (agent_popup_message_start): Remove arg CANCEL_BTN. (popup_message_thread): Use --one-button option. * command.c (cmd_passwd): Now that we don't distinguish between assuan and regular error codes we can jump to the end on error. 2006-12-07 David Shaw * Makefile.am: Link to iconv for jnlib dependency. 2006-11-20 Werner Koch * call-pinentry.c (agent_popup_message_stop): Use SIGKILL. * call-scd.c (inq_needpin): Implement POPUPKEYPADPROMPT and DISMISSKEYPADPROMPT. 2006-11-15 Werner Koch * protect.c (make_shadow_info): Cast printf arg to unsigned int. * minip12.c (parse_bag_encrypted_data): Ditto. (parse_bag_data, p12_parse): Ditto. * command-ssh.c (ssh_identity_register): Changed buffer_n to size_t. * agent.h (struct server_control_s): New field thread_startup. * command.c (start_command_handler): Moved CTRL init code to .. * gpg-agent.c (start_connection_thread): .. here. (agent_deinit_default_ctrl): New. (agent_init_default_ctrl): Made static. (handle_connections): Allocate CTRL and pass it pth_spawn. * command-ssh.c (start_command_handler_ssh): Moved CTRL init code to .. * gpg-agent.c (start_connection_thread_ssh): .. here. 2006-11-14 Werner Koch * command.c (bump_key_eventcounter): New. (bump_card_eventcounter): New. (cmd_geteventcounter): New command. * gpg-agent.c (handle_signal): Call bump_card_eventcounter. * findkey.c (agent_write_private_key): Call bump_key_eventcounter. * trustlist.c (agent_reload_trustlist): Ditto. * command.c (post_cmd_notify, io_monitor): New. (register_commands, start_command_handler): Register them. 2006-11-09 Werner Koch * gpg-agent.c (main): In detached mode connect standard descriptors to /dev/null. * trustlist.c (read_trustfiles): Make sure not to pass a zero size to realloc as the C standards says that this behaves like free. 2006-11-06 Werner Koch * protect-tool.c (my_strusage): Fixed typo. 2006-10-23 Werner Koch * gpg-agent.c (main): New command --gpgconf-test. * minip12.c (parse_bag_encrypted_data, parse_bag_data): Allow for a salt of 20 bytes. 2006-10-20 Werner Koch * Makefile.am (t_common_ldadd): Use GPG_ERROR_LIBS instead -o just -l 2006-10-19 Werner Koch * findkey.c (unprotect): Use it to avoid unnecessary calls to agent_askpin. * call-pinentry.c (pinentry_active_p): New. 2006-10-17 Werner Koch * Makefile.am (gpg_agent_LDADD): Link to libcommonpth. (gpg_agent_CFLAGS): New. This allows to only link this with Pth. 2006-10-16 Werner Koch * call-pinentry.c (agent_get_confirmation): Map Cancel code here too. * trustlist.c (agent_marktrusted): Return Cancel instead of Not_Confirmed for the first question. 2006-10-12 Werner Koch * protect-tool.c (get_passphrase): Fix if !HAVE_LANGINFO_CODESET. 2006-10-06 Werner Koch * Makefile.am (AM_CFLAGS): Use PTH version of libassuan. (gpg_agent_LDADD): Ditto. * divert-scd.c (divert_pksign): Use PKAUTH for the TLS algo. 2006-10-05 Werner Koch * command.c (has_option_name): New. (cmd_sethash): New --hash option. * pksign.c (do_encode_raw_pkcs1): New. (agent_pksign_do): Use it here for the TLS algo. * agent.h (GCRY_MD_USER_TLS_MD5SHA1): New. * divert-scd.c (pksign): Add case for tls-md5sha1. * divert-scd.c (encode_md_for_card): Check that the algo is valid. 2006-10-04 Werner Koch * call-pinentry.c (agent_get_passphrase): Changed to return the unencoded passphrase. (agent_askpin, agent_get_passphrase, agent_get_confirmation): Need to map the cancel error. * command.c (send_back_passphrase): New. (cmd_get_passphrase): Use it here. Also implement --data option. (skip_options): New. 2006-09-26 Werner Koch * learncard.c (agent_handle_learn): Send back the keypair information. 2006-09-25 Werner Koch * trustlist.c (read_one_trustfile): Allow extra flags. (struct trustitem_s): Replaced KEYFLAGS by a FLAGS struct. Changed all code to use this. (agent_istrusted): New arg CTRL. Changed all callers. Send back flags. * command.c (agent_write_status): New. 2006-09-20 Werner Koch * Makefile.am: Changes to allow parallel make runs. 2006-09-15 Werner Koch * trustlist.c: Entirely rewritten. (agent_trustlist_housekeeping): Removed and removed all calls. 2006-09-14 Werner Koch Replaced all call gpg_error_from_errno(errno) by gpg_error_from_syserror(). * call-pinentry.c (start_pinentry): Replaced pipe_connect2 by pipe_connect_ext. * call-scd.c (start_scd): Ditto. * command.c (start_command_handler): Replaced init_connected_socket_server by init_socket_server_ext. 2006-09-13 Werner Koch * preset-passphrase.c (main) [W32]: Check for WSAStartup error. 2006-09-08 Werner Koch * call-scd.c: Add signal.h as we are referencing SIGUSR2. 2006-09-06 Marcus Brinkmann * Makefile.am (AM_CFLAGS): Add $(GPG_ERR_CFLAGS). (gpg_agent_LDADD): Replace -lgpg-error with $(GPG_ERROR_LIBS). 2006-09-06 Werner Koch * query.c: Renamed to .. * call-pinentry.c: .. this. * agent.h (out_of_core): Removed. (CTRL): Removed and changed everywhere to ctrl_t. Replaced all Assuan error codes by libgpg-error codes. Removed all map_to_assuan_status and map_assuan_err. * gpg-agent.c (main): Call assuan_set_assuan_err_source to have Assuan switch to gpg-error codes. * command.c (set_error): Adjusted. 2006-09-04 Werner Koch * command.c (percent_plus_unescape): New. (cmd_get_val, cmd_putval): New. 2006-08-29 Werner Koch * command-ssh.c (stream_read_mpi): Sanity check for early detecting of too large keys. * gpg-agent.c (my_gcry_outofcore_handler): New. (main): Register it. (main): No allocate 32k secure memory (was 16k). 2006-07-31 Werner Koch * preset-passphrase.c (make_hexstring): For consistency use xtrymalloc and changed caller to use xfree. Fixed function comment. 2006-07-29 Marcus Brinkmann * preset-passphrase.c (preset_passphrase): Do not strip off last character of passphrase. (make_hexstring): New function. * command.c (cmd_preset_passphrase): Use parse_hexstring to syntax check passphrase argument. Truncate passphrase at delimiter. 2006-07-24 Werner Koch * minip12.c (build_key_bag): New args SHA1HASH and KEYIDSTR. Append bag Attributes if these args are given. (build_cert_sequence): ditto. (p12_build): Calculate certificate hash and pass to build functions. 2006-07-21 Werner Koch * minip12.c (oid_pkcs_12_keyBag): New. (parse_bag_encrypted_data): New arg R_RESULT. Support keybags and return the key object. (p12_parse): Take new arg into account. Free RESULT on error. 2006-06-26 Werner Koch * gpg-agent.c (handle_signal): Print info for SIGUSR2 only in verbose mode. 2006-06-22 Werner Koch * command-ssh.c (make_cstring): Use memcpy instead of strncpy. (ssh_receive_mpint_list, sexp_key_extract, data_sign): Use xtrycalloc instead of xtrymalloc followed by memset. 2006-06-20 Werner Koch * minip12.c (create_final): New arg PW. Add code to calculate the MAC. 2006-06-09 Marcus Brinkmann * Makefile.am (gpg_agent_LDADD): Add $(NETLIBS). (gpg_protect_tool_LDADD): Likewise. (gpg_preset_passphrase_LDADD): Likewise. 2006-04-09 Moritz Schulte * command-ssh.c (ssh_request_process): Removed FIXME mentioning a possible DoS attack. 2006-04-01 Moritz Schulte * command-ssh.c (ssh_identity_register): Make KEY_GRIP_RAW be 20 instead of 21 bytes long; do not fill KEY_GRIP_RAW[20] with NUL byte - KEY_GRIP_RAW is a raw binary string anyway. 2006-02-09 Werner Koch * call-scd.c (struct scd_local_s): New field next_local. (scd_local_list): New. (start_scd): Put new local into list. (agent_reset_scd): Remove it from the list. (agent_scd_check_aliveness): Here is the actual reason why we need all this stuff. (agent_reset_scd): Send the new command RESTART instead of RESET. 2005-12-16 Werner Koch * minip12.c (cram_octet_string): New (p12_parse): Use it for NDEFed bags. (parse_bag_data): Ditto. (string_to_key, set_key_iv, crypt_block): New arg SALTLEN. (p12_build): Use old value 8 for new arg. (parse_bag_encrypted_data, parse_bag_data): Allow for salts of 8 to 16 bytes. Add new arg R_CONSUMED. 2005-11-24 Werner Koch * minip12.c (p12_parse): Fixed for case that the key object comes prior to the certificate. 2005-10-19 Werner Koch * divert-scd.c (getpin_cb): Hack to use it for a keypad message. * call-scd.c (inq_needpin): Reworked to support the new KEYPADINFO. * query.c (start_pinentry): Keep track of the owner. (popup_message_thread, agent_popup_message_start) (agent_popup_message_stop, agent_reset_query): New. * command.c (start_command_handler): Make sure a popup window gets closed. 2005-10-08 Marcus Brinkmann * Makefile.am (gpg_protect_tool_LDADD): Add ../gl/libgnu.a. (gpg_preset_passphrase_LDADD, t_common_ldadd): Likewise. (gpg_agent_LDADD): Add ../gl/libgnu.a after ../common/libcommon.a. 2005-09-16 Werner Koch * minip12.c (build_key_sequence, build_cert_sequence): Fixed padding. 2005-09-15 Moritz Schulte * t-protect.c (test_agent_protect): Implemented. (main): Disable use of secure memory. 2005-09-09 Werner Koch * minip12.c (p12_build): Oops, array needs to be larger for the certificate. (build_cert_bag): Fixed yesterdays change. * command-ssh.c (card_key_available): Let the card handler decide whether the card is supported here. Also get a short serial number to return from the card handler. 2005-09-08 Werner Koch * minip12.c (build_cert_bag): Use a non constructed object. i.e. 0x80 and not 0xa0. 2005-08-16 Werner Koch * gpg-agent.c (main): Use a default file name for --write-env-file. 2005-07-25 Werner Koch * findkey.c (agent_public_key_from_file): Fixed array assignment. This was the cause for random segvs. 2005-06-29 Werner Koch * command-ssh.c (data_sign): Removed empty statement. 2005-06-21 Werner Koch * minip12.c (create_final): Cast size_t to ulong for printf. (build_key_bag, build_cert_bag, build_cert_sequence): Ditto. 2005-06-16 Werner Koch * protect-tool.c (make_advanced): Makde RESULT a plain char. * call-scd.c (unescape_status_string): Need to cast unsigned char* for strcpy. (agent_card_pksign): Made arg R_BUF an unsigned char**. * divert-scd.c (divert_pksign): Made SIGVAL unsigned char*. (encode_md_for_card): Initialize R_VAL and R_LEN. * genkey.c (store_key): Made BUF unsigned. * protect.c (do_encryption): Ditto. (do_encryption): Made arg PROTBEGIN unsigned. Initialize RESULT and RESULTLEN even on error. (merge_lists): Need to cast unsigned char * for strcpy. Initialize RESULTand RESULTLEN even on error. (agent_unprotect): Likewise for strtoul. (make_shadow_info): Made P and INFO plain char. (agent_shadow_key): Made P plain char. 2005-06-15 Werner Koch * query.c (agent_get_passphrase): Made HEXSTRING a char*. * command-ssh.c (ssh_key_grip): Made arg BUFFER unsigned. (ssh_key_grip): Simplified. (data_sign): Initialize variables with the definition. (ssh_convert_key_to_blob): Make sure that BLOB and BLOB_SIZE are set to NULL on error. Cool, gcc-4 detects uninitialized stuff beyond function boundaries; well it can't know that we do error proper error handling so that this was not a real error. (file_to_buffer): Likewise for BUFFER and BUFFER_N. (data_sign): Likewise for SIG and SIG_N. (stream_read_byte): Set B to a value even on error. * command.c (cmd_genkey): Changed VALUE to char. (cmd_readkey): Cast arg for gcry_sexp_sprint. * agent.h (struct server_control_s): Made KEYGRIP unsigned. 2005-06-13 Werner Koch * command-ssh.c (start_command_handler_ssh): Reset the SCD. 2005-06-09 Werner Koch * gpg-agent.c (create_socket_name): New option --max-cache-ttl-ssh. * cache.c (housekeeping): Use it. (agent_put_cache): Use a switch to get the default ttl so that it is easier to add more cases. 2005-06-06 Werner Koch * gpg-agent.c: New option --default-cache-ttl-ssh. * agent.h (cache_mode_t): New. * pksign.c (agent_pksign_do): New arg CACHE_MODE to replace the ARG IGNORE_CACHE. Changed all callers. (agent_pksign): Ditto. * findkey.c (agent_key_from_file): Ditto. Canged all callers. (unprotect): Ditto. * command-ssh.c (data_sign): Use CACHE_MODE_SSH. * cache.c (agent_get_cache): New arg CACHE_MODE. (agent_put_cache): Ditto. Store it in the cache. * query.c (agent_query_dump_state, dump_mutex_state): New. (unlock_pinentry): Reset the global context before releasing the mutex. * gpg-agent.c (handle_signal): Dump query.c info on SIGUSR1. * call-scd.c (agent_scd_check_aliveness): Always do a waitpid and add a timeout to the locking. 2005-06-03 Werner Koch * command.c (cmd_updatestartuptty): New. * gpg-agent.c: New option --write-env-file. * gpg-agent.c (handle_connections): Make sure that the signals we are handling are not blocked.Block signals while creating new threads. 2005-06-02 Werner Koch * call-scd.c (agent_scd_dump_state, dump_mutex_state): New. * gpg-agent.c (handle_signal): Print it on SIGUSR1. (handle_connections): Include the file descriptor into the threadnames. 2005-06-01 Werner Koch * gpg-agent.c: Include setenv.h. 2005-05-31 Werner Koch * agent.h (out_of_core): s/__inline__/inine. Noted by Ray Link. 2005-05-25 Werner Koch * gpg-agent.c (main): Do not unset the DISPLAY when we are continuing as child. 2005-05-24 Werner Koch * call-scd.c (inq_needpin): Skip leading spaces in of PIN description. * divert-scd.c (getpin_cb): Enhanced to cope with description flags. * query.c (agent_askpin): Add arg PROMPT_TEXT. Changed all callers. 2005-05-21 Werner Koch * call-scd.c (start_scd): Don't test for an alive scdaemon here. (agent_scd_check_aliveness): New. * gpg-agent.c (handle_tick): Test for an alive scdaemon. (handle_signal): Print thread info on SIGUSR1. 2005-05-20 Werner Koch * protect-tool.c: New option --canonical. (show_file): Implement it. * keyformat.txt: Define the created-at attribute for keys. 2005-05-18 Werner Koch * divert-scd.c (ask_for_card): Removed the card reset kludge. 2005-05-17 Werner Koch * call-scd.c (unlock_scd): Add new arg CTRL. Changed all callers. (start_scd): Reoworked to allow for additional connections. * agent.h (ctrl_t): Add local data for the SCdaemon. * command.c (start_command_handler): Release SERVER_LOCAL. * gpg-agent.c (create_server_socket): Use xmalloc. (main): Removed option --disable-pth a dummy. Removed non-pth code path. (cleanup_sh): Removed. Not needed anymore. 2005-05-05 Moritz Schulte * command-ssh.c (ssh_key_to_buffer): Rename to ... (ssh_key_to_protected_buffer): ... this; change callers. Improved documentation. Use ssh_key_grip(), where gcry_pk_get_keygrip() has been used before. (ssh_handler_sign_request): Removed unusued variable P. 2005-04-20 Moritz Schulte * command-ssh.c (ssh_handler_request_identities): Removed debugging code (sleep call), which was commited unintenionally. 2005-04-20 Werner Koch * minip12.c (parse_bag_encrypted_data): Fix the unpadding hack. * gpg-agent.c: New option --disable-scdaemon. (handle_connections): Add time event to drive ... (handle_tick): New function. (main): Record the parent PID. Fixed segv when using ssh and a command. * call-scd.c (start_scd): Take care of this option. 2005-04-03 Moritz Schulte * command-ssh.c (ssh_request_spec): New member: secret_input. (REQUEST_SPEC_DEFINE): New argument: secret_input. (request_specs): Add secret_input flag. (request_spec_lookup): New function ... (ssh_request_process): ... use it here; depending on secret_input flag allocate secure or non-secure memory. 2005-03-02 Moritz Schulte * command-ssh.c (sexp_key_extract): Removed FIXME, since xtrymallos does set errno correctly by now. (sexp_extract_identifier): Remove const attribute from identifier. (ssh_handler_request_identities): Remove const attribute from key_type; removes ugly casts and FIXME. (sexp_key_extract): Remove const attribute from comment. (ssh_send_key_public): Remove const attribute from key_type/comment; removes ugly cast. (data_sign): Remove const attribute from identifier; removes ugly cast. (key_secret_to_public): Remove const attribute from comment; removes ugly cast. (ssh_handler_sign_request): Remove const attribute from p. (sexp_key_extract): Use make_cstring(). (ssh_key_extract_comment): Likewise. (ssh_key_to_buffer): Use secure memory for memory area to hold the key S-Expression. Added more comments. 2005-02-25 Werner Koch * findkey.c (modify_description): Keep invalid % escapes, so that %0A may pass through. * agent.h (server_control_s): New field USE_AUTH_CALL. * call-scd.c (agent_card_pksign): Make use of it. * command-ssh.c (data_sign): Set the flag. (ssh_send_key_public): New arg OVERRIDE_COMMENT. (card_key_available): Add new arg CARDSN. (ssh_handler_request_identities): Use the card s/n as comment. (sexp_key_extract): Use GCRYMPI_FMT_STD. (data_sign): Ditto. * learncard.c (make_shadow_info): Moved to .. * protect.c (make_shadow_info): .. here. Return NULL on malloc failure. Made global. * agent.h: Add prototype. 2005-02-24 Werner Koch * call-scd.c (unescape_status_string): New. Actual a copy of ../g10/call-agent.c (card_getattr_cb, agent_card_getattr): New. * command-ssh.c (card_key_available): New. (ssh_handler_request_identities): First see whether a card key is available. * gpg-agent.c (handle_connections): Need to check for events if select returns with -1. 2005-02-23 Werner Koch * command-ssh.c (get_passphrase): Removed. (ssh_identity_register): Partly rewritten. (open_control_file, search_control_file, add_control_entry): New. (ssh_handler_request_identities): Return only files listed in our control file. * findkey.c (unprotect): Check for allocation error. * agent.h (opt): Add fields to record the startup terminal settings. * gpg-agent.c (main): Record them and do not force keep display with --enable-ssh-support. * command-ssh.c (start_command_handler_ssh): Use them here. * gpg-agent.c: Renamed option --ssh-support to --enable-ssh-support. * command.c (cmd_readkey): New. (register_commands): Register new command "READKEY". * command-ssh.c (ssh_request_process): Improved logging. * findkey.c (agent_write_private_key): Always use plain open. Don't depend on an umask for permissions. (agent_key_from_file): Factored file reading code out to .. (read_key_file): .. new function. (agent_public_key_from_file): New. 2005-02-22 Werner Koch * command-ssh.c (stream_read_string): Removed call to abort on memory error because the CVS version of libgcrypt makes sure that ERRNO gets always set on error even with a faulty user supplied function. 2005-02-19 Moritz Schulte * command-ssh.c (ssh_receive_mpint_list): Slightly rewritten, do not use elems_secret member of key_spec. (ssh_key_type_spec): Removed member: elems_secret. (ssh_key_types): Removed elems_secret data. (ssh_sexp_construct): Renamed to ... (sexp_key_construct): ... this; changed callers. (ssh_sexp_extract): Renamed to ... (sexp_key_extract): ... this; changed callers. (ssh_sexp_extract_key_type): Renamed to ... (sexp_extract_identifier): ... this; changed callers; use make_cstring(). Added more comments. 2005-02-18 Moritz Schulte * command-ssh.c (ssh_sexp_construct): Rewritten generation of sexp template, clarified. (ssh_sexp_extract): Support shadowed-private-key-sexp; treat protected-private key and shadowed-private-key as public keys. (key_secret_to_public): Rewritten: simply use ssh_sexp_extract() and ssh_sexp_construct(). 2005-02-15 Werner Koch * findkey.c (modify_description): Don't increment OUT_LEN during the second pass. 2005-02-14 Moritz Schulte * command-ssh.c (es_read_byte): Renamed to ... (stream_es_read_byte): ... this; changed callers. (es_write_byte): Renamed to ... (stream_write_byte): ... this; changed callers. (es_read_uint32): Renamed to ... (stream_read_uint32): ... this; changed callers. (es_write_uint32): Renamed to ... (stream_write_uint32): ... this; changed callers. (es_read_data): Renamed to ... (stream_read_data): ... this; changed callers. (es_write_data): Renamed to ... (stream_write_data): ... this; changed callers. (es_read_string): Renamed to ... (stream_read_string): ... this; changed callers. (es_read_cstring): Renamed to ... (stream_read_cstring): ... this; changed callers. (es_write_string): Renamed to ... (stream_write_string): ... this; changed callers. (es_write_cstring): Renamed to ... (stream_write_cstring): ... this; changed callers. (es_read_mpi): Renamed to ... (stream_read_mpi): ... this; changed callers. (es_write_mpi): Renamed to ... (stream_write_mpi): ... this; changed callers. (es_copy): Renamed to ... (stream_copy): ... this; changed callers. (es_read_file): Renamed to ... (file_to_buffer): ... this; changed callers. (ssh_identity_register): Removed variable description_length; changed code to use asprintf for description. (stream_write_uint32): Do not filter out the last byte of shift expression. (uint32_construct): New macro ... (stream_read_uint32): ... use it; removed unnecessary cast. 2005-02-03 Werner Koch * agent.h (agent_exit): Add JNLIB_GCC_A_NR to indicate that this function won't return. * gpg-agent.c (check_for_running_agent): Initialize pid to a default value if not needed. * command-ssh.c: Removed stdint.h. s/byte_t/unsigned char/, s/uint32/u32/ becuase that is what we have always used in GnuPG. (ssh_request_specs): Moved to top of file. (ssh_key_types): Ditto. (make_cstring): Ditto. (data_sign): Don't use a variable for the passphrase prompt, make it translatable. (ssh_request_process): * findkey.c (modify_description): Renamed arguments for clarity, polished documentation. Make comment a C-string. Fixed case of DESCRIPTION being just "%". (agent_key_from_file): Make sure comment string to a C-string. * gpg-agent.c (create_socket_name): Cleanup the implemntation, use DIMof, agent_exit, removed superflous args and return the allocated string as value. Documented. Changed callers. (create_server_socket): Cleanups similar to above. Changed callers. (cleanup_do): Renamed to .. (remove_socket): .. this. Changed caller. (handle_connections): The signals are to be handled in the select and not in the accept. Test all FDs after returning from a select. Remove the event tests from the accept calls. The select already assured that the accept won't block. 2005-01-29 Moritz Schulte * command-ssh.c (ssh_handler_request_identities) (ssh_handler_sign_request, ssh_handler_add_identity) (ssh_handler_remove_identity, ssh_handler_remove_all_identities) (ssh_handler_lock, ssh_handler_unlock): Changed to return an error code instead of a boolean. (ssh_request_process): Changed to return a boolean instead of an error; adjust caller. (ssh_request_handle_t): Adjusted type. (ssh_request_spec): New member: identifier. (REQUEST_SPEC_DEFINE): New macro; use it for initialization of request_specs[]. (ssh_request_process): In debugging mode, log identifier of handler to execute. (start_command_handler_ssh): Moved most of the stream handling code ... (ssh_request_process): ... here. 2005-01-28 Moritz Schulte * command-ssh.c (ssh_handler_add_identity): Pass ctrl to ssh_identity_register(). (ssh_identity_register): New argument: ctrl; pass ctrl to get_passphrase(). (get_passphrase): Pass ctrl instead of NULL to agent_askpin(). (start_command_handler_ssh): Use agent_init_default_ctrl(); deallocate structure members, which might be dynamically allocated. (lifetime_default): Removed variable. (ssh_handler_add_identity): Fix ttl handling; renamed variable `death' to `ttl'. (ssh_identity_register): Fix key grip handling. 2005-01-26 Moritz Schulte * command-ssh.c (ssh_handler_sign_request): Confirm to agent protocol in case of failure. * command-ssh.c: New file. * Makefile.am (gpg_agent_SOURCES): New source file: command-ssh.c. * findkey.c (modify_description): New function. (agent_key_from_file): Support comment field in key s-expressions. * gpg-agent.c (enum cmd_and_opt_values): New item: oSSHSupport. (opts) New entry for oSSHSupport. New variable: socket_name_ssh. (cleanup_do): New function based on cleanup(). (cleanup): Use cleanup_do() for socket_name and socket_name_ssh. (main): New switch case for oSSHSupport. (main): Move socket name creation code to ... (create_socket_name): ... this new function. (main): Use create_socket_name() for creating socket names for socket_name and for socket_name_ssh in case ssh support is enabled. Move socket creation code to ... (create_server_socket): ... this new function. (main): Use create_server_socket() for creating sockets. In case standard_socket is set, do not only store a socket name in socket_name, but also in socket_name_ssh. Generate additional environment info strings for ssh support. Pass additional ssh socket argument to handle_connections. (start_connection_thread_ssh): New function. (handle_connections): Use select to multiplex between gpg-agent and ssh-agent protocol. * agent.h (struct opt): New member: ssh_support. (start_command_handler_ssh): Add prototype. 2005-01-04 Werner Koch * trustlist.c (agent_marktrusted): Use "Cancel" for the first confirmation and made the strings translatable. * cache.c (agent_put_cache): Fix the test for using the default TTL. 2004-12-21 Werner Koch * preset-passphrase.c (preset_passphrase): Handle --passphrase. * Makefile.am (gpg_preset_passphrase_LDADD): Reorder libs so that pwquery may use stuff from jnlib. Conditionally add -lwsock2 (gpg_protect_tool_LDADD): Ditto. * preset-passphrase.c (main): Use default_homedir(). (main) [W32]: Initialize sockets. 2004-12-21 Marcus Brinkmann * Makefile.am (libexec_PROGRAMS): Add gpg-preset-passphrase. (gpg_preset_passphrase_SOURCES, gpg_preset_passphrase_LDADD): New targets. * agent.h (opt): New member allow_cache_passphrase. * cache.c (housekeeping): Check if R->ttl is not negative. (agent_put_cache): Allow ttl to be negative. * command.c (parse_hexstring): Allow something to follow the hexstring. (cmd_cache_passphrase): New function. (register_commands): Add it. * gpg-agent.c: Handle --allow-preset-passphrase. * preset-passphrase.c: New file. 2004-12-21 Werner Koch * gpg-agent.c (main): Use default_homedir(). * protect-tool.c (main): Ditto. 2004-12-20 Werner Koch * gpg-agent.c (main) [W32]: Now that Mutexes work we can remove the pth_init kludge. (main): Add new options --[no-]use-standard-socket. (check_for_running_agent): Check whether it is running on the standard socket. * call-scd.c (init_membuf, put_membuf, get_membuf): Removed. We now use the identical implementation from ../common/membuf.c. * pksign.c (agent_pksign): Changed arg OUTFP to OUTBUF and use membuf functions to return the value. * pkdecrypt.c (agent_pkdecrypt): Ditto. * genkey.c (agent_genkey): Ditto. * command.c (cmd_pksign, cmd_pkdecrypt, cmd_genkey): Replaced assuan_get_data_fp() by a the membuf scheme. (clear_outbuf, write_and_clear_outbuf): New. 2004-12-19 Werner Koch * query.c (initialize_module_query): New. * call-scd.c (initialize_module_call_scd): New. * gpg-agent.c (main): Call them. 2004-12-18 Werner Koch * gpg-agent.c (main): Remove special Pth initialize. * agent.h (map_assuan_err): Define in terms of map_assuan_err_with_source. 2004-12-17 Moritz Schulte * query.c: Undo change from 2004-12-05. 2004-12-15 Werner Koch * gpg-agent.c [W32]: Various hacks to make it work. * findkey.c (agent_write_private_key) [W32]: Adjust open call. * call-scd.c (start_scd) [W32]: Don't check whether the daemon didn't died. To hard to do under Windows. (start_scd) [W32]: Disable sending of the event signal option. * protect-tool.c (read_file, export_p12_file) [W32]: Use setmode to get stdout and stin into binary mode. 2004-12-05 Moritz Schulte * query.c (start_pinentry): Allow CTRL be NULL. 2004-10-22 Werner Koch * gpg-agent.c (parse_rereadable_options): Return "not handled" when the log file has not beend hadled. This is will let the main option processing continue. Fixed a bug introduced on 2004-09-4 resulting in logging to stderr until a HUP has been given. (main): Don't close the listen FD. 2004-09-30 Werner Koch * Makefile.am: Adjusted from gettext 1.14. 2004-09-29 Werner Koch * minip12.c (parse_bag_encrypted_data): Print error if a bad passphrase has been given. 2004-09-28 Werner Koch * protect.c (agent_unprotect): Fixed wiping of CLEARTEXT. Thanks to Moritz for pointing this out. 2004-09-25 Moritz Schulte * agent.h: Declare: agent_pksign_do. (struct server_control_s): New member: raw_value. * pksign.c (do_encode_md): New argument: raw_value; support generation of raw (non-pkcs1) data objects; adjust callers. (agent_pksign_do): New function, based on code ripped out from agent_pksign. (agent_pksign): Use agent_pksign_do. * command.c (start_command_handler): Set ctrl.digest.raw_value. 2004-09-09 Werner Koch * gpg-agent.c (check_for_running_agent): New. (main): The default action is now to check for an already running agent. (parse_rereadable_options): Set logfile only on reread. (main): Do not print the "is development version" note. 2004-08-20 Werner Koch * gpg-agent.c: New option --max-cache-ttl. Suggested by Alexander Belopolsky. * cache.c (housekeeping): Use it here instead of the hardwired default of 1 hour. * query.c (start_pinentry): Use a timeout for the pinentry lock. 2004-08-18 Werner Koch * protect-tool.c (get_passphrase): Make sure that the default prompts passed to gpg-agent are utf-8 encoded. Add new prompt values. (import_p12_file, import_p12_file, export_p12_file): Changed calls to get_passphrase so that better prompts are displayed. (get_new_passphrase): New. 2004-07-22 Werner Koch * trustlist.c (read_list): Allow colons in the fingerprint. (headerblurb): Rephrased. * gpg-agent.c (handle_connections): Increase the stack size ot 256k. 2004-06-20 Moritz Schulte * gpg-agent.c: Include (build fix for BSD). 2004-05-11 Werner Koch * gpg-agent.c (handle_signal): Reload the trustlist on SIGHUP. (start_connection_thread): Hack to simulate a ticker. * trustlist.c (agent_trustlist_housekeeping) (agent_reload_trustlist): New. Protected all global functions here with a simple counter which is sufficient for Pth. 2004-05-03 Werner Koch * gpg-agent.c: Remove help texts for options lile --lc-ctype. (main): New option --allow-mark-trusted. * trustlist.c (agent_marktrusted): Use it here. 2004-04-30 Werner Koch * protect-tool.c: New option --enable-status-msg. (store_private_key): Print status messages for imported keys. (read_and_unprotect): Ditto for bad passphrase. * gpg-agent.c (parse_rereadable_options): New arg REREAD. Allow changing oLogFile. (current_logfile): New. 2004-04-26 Werner Koch * call-scd.c (start_scd): Do not register an event signal if we are running as a pipe server. 2004-04-21 Werner Koch * call-scd.c (start_scd): Send event-signal option. Always check that the scdaemon is still running. * gpg-agent.c (handle_signal): Do not use SIGUSR{1,2} anymore for changing the verbosity. 2004-04-16 Werner Koch * gpg-agent.c (main): Tell the logging code that we are running detached. 2004-04-06 Werner Koch * gpg-agent.c (main): Use new libgcrypt thread library register scheme. 2004-03-23 Marcus Brinkmann * gpg-agent.c (main): For now, always print the default config file name for --gpgconf-list. 2004-03-17 Werner Koch * gpg-agent.c (main) : Fixed default value quoting. 2004-03-16 Werner Koch * gpg-agent.c (parse_rereadable_options): Use the new DEFAULT_CACHE_TTL macro. (main): Updated --gpgconf-list output. 2004-02-21 Werner Koch * command.c (cmd_passwd): Take acount of a key description. * genkey.c (reenter_compare_cb): Do not set the error text. (agent_protect_and_store, agent_genkey): Force a re-enter after a non-matching passphrase. * query.c (agent_askpin): Add new arg INITIAL_ERRTEXT; changed all callers. 2004-02-19 Werner Koch * protect-tool.c: New options --have-cert and --prompt. (export_p12_file): Read a certificate from STDIN and pass it to p12_build. Detect a keygrip and construct the filename in that case. Unprotcet a key if needed. Print error messages for key formats we can't handle. (release_passphrase): New. (get_passphrase): New arg PROMPTNO. Return the allocated string. Changed all callers. * minip12.c: Revamped the build part. (p12_build): New args CERT and CERTLEN. 2004-02-18 Werner Koch * protect-tool.c (main): Setup the used character set. * gpg-agent.c (main): Ditto. * gpg-agent.c (set_debug): New. New option --debug-level. (main): New option --gpgconf-list. 2004-02-17 Werner Koch * pksign.c (do_encode_md): Cleaned up by using gcry_sexp_build. * Makefile.am (gpg_protect_tool_SOURCES): Removed simple-pwquery.[ch], as we once moved it to ../common. 2004-02-13 Werner Koch * command.c (cmd_setkeydesc): New. (register_commands): Add command SETKEYDESC. (cmd_pksign, cmd_pkdecrypt): Use the key description. (reset_notify): Reset the description. * findkey.c (unprotect): Add arg DESC_TEXT. (agent_key_from_file): Ditto. * pksign.c (agent_pksign): Ditto. * pkdecrypt.c (agent_pkdecrypt): Ditto. Made CIPHERTEXT an unsigned char*. * protect-tool.c (main): New options --no-fail-on-exist, --homedir. (store_private_key): Use them here. 2004-02-12 Werner Koch * protect-tool.c (read_file, main): Allow reading from stdin. * Makefile.am: Include cmacros.am for common flags. (libexec_PROGRAMS): Put gpg-protect-tool there. 2004-02-10 Werner Koch * minip12.c (parse_bag_encrypted_data): Finished implementation. (p12_parse): Add callback args. * protect-tool.c (import_p12_cert_cb): New. (import_p12_file): Use it. 2004-02-06 Werner Koch * minip12.c (crypt_block): Add arg CIPHER_ALGO; changed all callers. (set_key_iv): Add arg KEYBYTES; changed caller. 2004-02-03 Werner Koch * findkey.c (agent_key_from_file): Extra paranoid wipe. * protect.c (agent_unprotect): Ditto. (merge_lists): Ditto. Add arg RESULTLEN. * pkdecrypt.c (agent_pkdecrypt): Don't show the secret key even in debug mode. * protect.c: Add DSA and Elgamal description. 2004-01-29 Werner Koch * agent.h (server_control_s): Add connection_fd field. * command.c (start_command_handler): Init it here. * gpg-agent.c (agent_init_default_ctrl): and here. * call-scd.c: Add the CTRL arg to all functions calling start_scd and pass it to start_scd. Changed all callers (start_scd): Keep track of the current active connection. (agent_reset_scd): New. * command.c (start_command_handler): Call it here. * learncard.c (agent_handle_learn): Add arg CTRL; changed caller. (send_cert_back): Ditto. 2004-01-28 Werner Koch * trustlist.c (agent_marktrusted): Check whether the trustlist is writable. 2004-01-27 Werner Koch * sexp-parse.h: Moved to ../common. 2004-01-24 Werner Koch * call-scd.c (atfork_cb): New. (start_scd): Make sure secmem gets cleared. * query.c (atfork_cb): New. (start_pinentry): Make sure secmem gets cleared. 2004-01-16 Werner Koch * findkey.c (agent_key_from_file): Now return an error code so that we have more detailed error messages in the upper layers. This fixes the handling of pinentry's cancel button. * pksign.c (agent_pksign): Changed accordingly. * pkdecrypt.c (agent_pkdecrypt): Ditto. * command.c (cmd_passwd): Ditto. 2003-12-16 Werner Koch * gpg-agent.c (main): Set the prefixes for assuan logging. 2003-12-15 Werner Koch * protect.c (do_encryption): Use gcry_create_nonce instad of the obsolete WEAK_RANDOM. 2003-11-20 Werner Koch * sexp-parse.h (snext): Don't use atoi_1 and digitp macros, so that this file is useful by other applications too. 2003-10-27 Werner Koch * command.c (cmd_get_confirmation): New command. 2003-08-20 Timo Schulz * pksign.c (do_encode_md): Allocate enough space. Cast md byte to unsigned char to prevent sign extension. 2003-08-14 Timo Schulz * pksign.c (do_encode_md): Due to the fact pkcs#1 padding is now in Libgcrypt, use the new interface. 2003-07-31 Werner Koch * Makefile.am (gpg_agent_LDADD): Added INTLLIBS. (gpg_protect_tool_SOURCES): Added simple-pwquery.[ch] 2003-07-27 Werner Koch Adjusted for gcry_mpi_print and gcry_mpi_scan API change. 2003-07-15 Werner Koch * simple-pwquery.c, simple-pwquery.h: Moved to ../common. * Makefile.am (gpg_protect_tool_LDADD): Add simple-pwquery.o. Removed it from xx_SOURCES. 2003-07-04 Werner Koch * gpg-agent.c (handle_connections): Kludge to allow use of Pth 1 and 2. 2003-06-30 Werner Koch * call-scd.c (learn_status_cb): Store the serialno in PARM. 2003-06-26 Werner Koch * call-scd.c (agent_card_serialno): Don't do a RESET anymore. 2003-06-25 Werner Koch * command.c (cmd_scd): New. * call-scd.c (agent_card_scd): New. * divert-scd.c (divert_generic_cmd): New * call-scd.c (agent_card_learn): New callback args SINFO. (learn_status_cb): Pass all other status lines to the sinfo callback. * learncard.c (release_sinfo, sinfo_cb): New. (agent_handle_learn): Pass the new cb to the learn function and pass the collected information back to the client's assuan connection. * gpg-agent.c (main): Moved pth_init before gcry_check_version. 2003-06-24 Werner Koch * gpg-agent.c (handle_connections): Adjusted for Pth 2.0 Adjusted for changes in the libgcrypt API. Some more fixes for the libgpg-error stuff. 2003-06-04 Werner Koch Renamed error codes from INVALID to INV and removed _ERROR suffixes. 2003-06-03 Werner Koch Changed all error codes in all files to the new libgpg-error scheme. * agent.h: Include gpg-error.h and errno.h * Makefile.am: Link with libgpg-error * query.c: assuan.h is now a system header. * genkey.c (agent_genkey): Fixed silly use of xmalloc by xtrymalloc. 2003-04-29 Werner Koch * command.c (register_commands): Adjusted for new Assuan semantics. * Makefile.am: Don't override LDFLAGS. 2002-12-04 Werner Koch * gpg-agent.c: New variable config_filename. (parse_rereadable_options): New. (main): Use it here. Add setting of default values, set config_filename. (reread_configuration): Filled with actual code. 2002-12-03 Werner Koch * protect-tool.c (read_key): Don't run make_canonical on a NULL buffer. * command.c (parse_hexstring): New. (cmd_sethash): Use it. (parse_keygrip): New. (cmd_havekey, cmd_sigkey): Use it. (cmd_passwd): New. * genkey.c (agent_protect_and_store): New. (store_key): Add arg FORCE. (agent_genkey): Pass false to this force of store_key. 2002-11-13 Werner Koch * gpg-agent.c (main): Switch all messages to utf-8. * simple-pwquery.c (agent_send_all_options): Use $GPG_TTY and stdin with ttyname. * cache.c (new_data): Uiih - /sizeof d/sizeof *d/. 2002-11-10 Werner Koch * command.c (option_handler): Fix keep_tty check. 2002-11-06 Werner Koch * gpg-agent.c (main): Make sure we have a default ttyname. * command.c (option_handler): Check opt.keep_tty here * query.c (start_pinentry): but not anymore here. 2002-11-05 Werner Koch * agent.h (opt,server_control_s): Move display and lc_ variables to the control struct so that they are per connection. * gpg-agent.c (agent_init_default_ctrl): New. (main): Assign those command line options to new default_* variables. Reset DISPLAY in server mode so that tehre is no implicit default. * command.c (start_command_handler): Initialize and deinitialize the control values. (option_handler): Work on the ctrl values and not on the opt. * query.c (start_pinentry): New argument CTRL to set the display connection specific. Changed all callers to pass this value. (agent_askpin,agent_get_passphrase,agent_get_confirmation): Add CTRL arg and pass it ot start_pinentry. * command.c (cmd_get_passphrase): Pass CTRL argument. * trustlist.c (agent_marktrusted): Add CTRL argument * command.c (cmd_marktrusted): Pass CTRL argument * divert-scd.c (ask_for_card): Add CTRL arg. (divert_pksign,divert_pkdecrypt): Ditto. Changed caller. (getpin_cb): Use OPAQUE to pass the CTRL variable. Changed both users. * findkey.c (unprotect): Add CTRL arg. (agent_key_from_file): Ditto. * query.c (unlock_pinentry): Disconnect the pinentry so that we start a new one for each request. This is required to support clients with different environments (e.g. X magic cookies). 2002-09-05 Neal H. Walfield * gpg-agent.c (main) [USE_GNU_PTH]: No need to call assuan_set_io_func as assuan is smart. 2002-09-25 Werner Koch * gpg-agent.c (handle_signal): Flush cache on SIGHUP. * cache.c (agent_flush_cache): New. * gpg-agent.c, agent.h: Add --keep-display and --keep-tty. * query.c (start_pinentry): Implement them. The option passing needs more thoughts. 2002-09-09 Werner Koch * gpg-agent.c (create_private_keys_directory) (create_directories): New. (main): Try to create a home directory. 2002-09-04 Neal H. Walfield * gpg-agent.c (main): Use sigaction, not signal. 2002-09-03 Neal H. Walfield * findkey.c: Include . (agent_write_private_key): Prefer POSIX compatibity, open and fdopen, over the simplicity of GNU extensions, fopen(file, "x"). 2002-08-22 Werner Koch * query.c (agent_askpin): Provide the default desc text depending on the pininfo. Do the basic PIN verification only when min_digits is set. 2002-08-21 Werner Koch * query.c (agent_askpin): Hack to show the right default prompt. (agent_get_passphrase): Ditto. * trans.c: Removed and replaced all usages with standard _() * divert-scd.c (getpin_cb): Pass a more descritive text to the pinentry. * Makefile.am: Renamed the binary protect-tool to gpg-protect-tool. * protect-tool.c: Removed the note about internal use only. * gpg-agent.c (main): New option --daemon so that the program is not accidently started in the background. 2002-08-16 Werner Koch * call-scd.c (learn_status_cb): Handle CERTINFO status. (agent_card_learn): Add args for certinfo cb. * learncard.c (release_certinfo,certinfo_cb): New. (send_cert_back): New. With factored out code from .. (agent_handle_learn): here. Return certinfo stuff. 2002-07-26 Werner Koch * gpg-agent.c (main): New option --ignore-cache-for-signing. * command.c (option_handler): New server option use-cache-for-signing defaulting to true. (cmd_pksign): handle global and per session option. * findkey.c (agent_key_from_file, unprotect): New arg ignore_cache. Changed all callers. * pksign.c (agent_pksign): Likewise. 2002-06-29 Werner Koch * query.c (start_pinentry): Use GNUPG_DERAULT_PINENTRY. * call-scd.c (start_scd): Use GNUPG_DEFAULT_SCDAEMON. 2002-06-28 Werner Koch * protect-tool.c (export_p12_file): New. (main): New command --p12-export. * minip12.c (create_final,p12_build,compute_tag_length): New. (store_tag_length): New. 2002-06-27 Werner Koch * minip12.c (crypt_block): Renamed from decrypt_block, add arg to allow encryption. * Makefile.am (pkglib_PROGRAMS): Put protect-tool there. * findkey.c (agent_write_private_key,agent_key_from_file) (agent_key_available): Use GNUPG_PRIVATE_KEYS_DIR constant. * gpg-agent.c (main): Use GNUPG_DEFAULT_HOMEDIR constant. * protect-tool.c (store_private_key): New. (import_p12_file): Store the new file if requested. (main): New options --force and --store. * gpg-agent.c (main): Set a global flag when running detached. * query.c (start_pinentry): Pass the list of FD to keep in the child when not running detached. * call-scd.c (start_scd): Ditto. 2002-06-26 Werner Koch * command.c (cmd_istrusted, cmd_listtrusted, cmd_marktrusted) (cmd_pksign, cmd_pkdecrypt, cmd_genkey, cmd_get_passphrase) (cmd_learn): Print an error message for a failed operation. * simple-pwquery.c, simple-pwquery.h: New. * protect-tool. (get_passphrase): New, used to get a passphrase from the agent if none was given on the command line. 2002-06-25 Werner Koch * protect-tool.c (rsa_key_check): New. (import_p12_file): New. (main): New command --p12-import. * minip12.c, minip12.h: New. 2002-06-24 Werner Koch * protect-tool.c (read_file): New. (read_key): Factored most code out to read_file. 2002-06-17 Werner Koch * agent.h: Add a callback function to the pin_entry_info structure. * query.c (agent_askpin): Use the callback to check for a correct PIN. Removed the start_err_text argument because it is not anymore needed; changed callers. * findkey.c (unprotect): Replace our own check loop by a callback. (try_unprotect_cb): New. * genkey.c (reenter_compare_cb): New. (agent_genkey): Use this callback here. Fixed setting of the pi2 variable and a segv in case of an empty PIN. * divert-scd.c (getpin_cb): Removed some unused stuff and explained what we still have to change. 2002-06-12 Werner Koch * gpg-agent.c (main): New option --disable-pth. 2002-06-11 Werner Koch * protect-tool.c: Add command --show-keygrip (show_keygrip): New. 2002-05-23 Werner Koch * call-scd.c: Seirialized all scdaeom access when using Pth. * cache.c: Made the cache Pth-thread-safe. (agent_unlock_cache_entry): New. * findkey.c (unprotect): Unlock the returned cache value. * command.c (cmd_get_passphrase): Ditto. * gpg-agent.c (main): Register pth_read/write with Assuan. 2002-05-22 Werner Koch * query.c: Serialized all pinentry access when using Pth. * gpg-agent.c (handle_signal,start_connection_thread) (handle_connections): New (main): Use the new Pth stuff to allow concurrent connections. * command.c (start_command_handler): Add new arg FD so that the fucntion can also be used for an already connected socket. * Makefile.am: Link with Pth. 2002-05-14 Werner Koch * cache.c (housekeeping, agent_put_cache): Use our time() wrapper. 2002-04-26 Werner Koch * cache.c (agent_put_cache): Reinitialize the creation time and the ttl when reusing a slot. * call-scd.c (start_scd): Print debug messages only with debug flags set. * query.c (start_pinentry): Ditto. 2002-04-25 Marcus Brinkmann * agent.h (agent_get_confirmation): Replace paramter prompt with two parameters ok and cancel. * query.c (agent_get_confirmation): Likewise. Implement this. * trustlist.c (agent_marktrusted): Fix invocation of agent_get_confirmation. * divert-scd.c (ask_for_card): Likewise. 2002-04-24 Marcus Brinkmann * agent.h (struct opt): Add members display, ttyname, ttytype, lc_ctype, and lc_messages. * gpg-agent.c (enum cmd_and_opt_values): Add oDisplay, oTTYname, oTTYtype, oLCctype, and LCmessages. (main): Handle these options. * command.c (option_handler): New function. (register_commands): Register option handler. * query.c (start_pinentry): Pass the various display and tty options to the pinentry. 2002-04-05 Werner Koch * protect-tool.c (show_file): New. Used as default action. 2002-03-28 Werner Koch * divert-scd.c (encode_md_for_card): Don't do the pkcs-1 padding, the scdaemon should take care of it. (ask_for_card): Hack to not display the trailing zero. 2002-03-11 Werner Koch * learncard.c (kpinfo_cb): Remove the content restrictions from the keyID. 2002-03-06 Werner Koch * learncard.c: New. * divert-scd.c (ask_for_card): The serial number is binary so convert it to hex here. * findkey.c (agent_write_private_key): New. * genkey.c (store_key): And use it here. * pkdecrypt.c (agent_pkdecrypt): Changed the way the diversion is done. * divert-scd.c (divert_pkdecrypt): Changed interface and implemented it. 2002-03-05 Werner Koch * call-scd.c (inq_needpin): New. (agent_card_pksign): Add getpin_cb args. (agent_card_pkdecrypt): New. 2002-03-04 Werner Koch * pksign.c (agent_pksign): Changed how the diversion is done. * divert-scd.c (divert_pksign): Changed interface and implemented it. (encode_md_for_card): New. * call-scd.c (agent_card_pksign): New. 2002-02-28 Werner Koch * pksign.c (agent_pksign): Detect whether a Smartcard is to be used and divert the operation in this case. * pkdecrypt.c (agent_pkdecrypt): Likewise * findkey.c (agent_key_from_file): Add optional arg shadow_info and have it return information about a shadowed key. * protect.c (agent_get_shadow_info): New. * protect.c (snext,sskip,smatch): Moved to * sexp-parse.h: New file. * divert-scd.c: New. 2002-02-27 Werner Koch * protect.c (agent_shadow_key): New. * command.c (cmd_learn): New command LEARN. * gpg-agent.c: New option --scdaemon-program. * call-scd.c (start_scd): New. Based on query.c * query.c: Add 2 more arguments to all uses of assuan_transact. 2002-02-18 Werner Koch * findkey.c (unprotect): Show an error message for a bad passphrase. * command.c (cmd_marktrusted): Implemented. * trustlist.c (agent_marktrusted): New. (open_list): Add APPEND arg. * query.c (agent_get_confirmation): New. 2002-02-06 Werner Koch * cache.c (housekeeping): Fixed linking in the remove case. 2002-02-01 Werner Koch * gpg-agent.c: New option --default-cache-ttl. * cache.c (agent_put_cache): Use it. * cache.c: Add a few debug outputs. * protect.c (agent_private_key_type): New. * agent.h: Add PRIVATE_KEY_ enums. * findkey.c (agent_key_from_file): Use it to decide whether we have to unprotect a key. (unprotect): Cache the passphrase. * findkey.c (agent_key_from_file,agent_key_available): The key files do now require a ".key" suffix to make a script's life easier. * genkey.c (store_key): Ditto. 2002-01-31 Werner Koch * genkey.c (store_key): Protect the key. (agent_genkey): Ask for the passphrase. * findkey.c (unprotect): Actually unprotect the key. * query.c (agent_askpin): Add an optional start_err_text. 2002-01-30 Werner Koch * protect.c: New. (hash_passphrase): Based on the GnuPG 1.0.6 version. * protect-tool.c: New 2002-01-29 Werner Koch * findkey.c (agent_key_available): New. * command.c (cmd_havekey): New. (register_commands): And register new command. 2002-01-20 Werner Koch * command.c (cmd_get_passphrase): Remove the plus signs. * query.c (start_pinentry): Send no-grab option to pinentry * gpg-agent.c (main): Move variable grab as no_grab to agent.h. 2002-01-19 Werner Koch * gpg-agent.c (main): Disable core dumps. * cache.c: New. * command.c (cmd_get_passphrase): Use the cache. (cmd_clear_passphrase): Ditto. * gpg-agent.c: Removed unused cruft and implement the socket based server. (my_strusage): Take bug report address from configure.ac. * command.c (start_command_handler): Add an argument to start as regular server. (start_command_handler): Enable Assuan logging. 2002-01-15 Werner Koch * trustlist.c: New. * command.c (cmd_istrusted, cmd_listtrusted, cmd_marktrusted): New. 2002-01-07 Werner Koch * genkey.c: Store the secret part and return the public part. 2002-01-03 Werner Koch * command.c (cmd_get_passphrase): New. (cmd_clear_passphrase): New. * query.c (agent_get_passphrase): New. 2002-01-02 Werner Koch * genkey.c: New. * command.c (cmd_genkey): New. * command.c (rc_to_assuan_status): Removed and changed all callers to use map_to_assuan_status. 2001-12-19 Werner Koch * keyformat.txt: New. 2001-12-19 Marcus Brinkmann * query.c (start_pinentry): Add new argument to assuan_pipe_connect. 2001-12-18 Werner Koch * Makefile.am: Use LIBGCRYPT macros 2001-12-14 Werner Koch * gpg-agent.c (main): New option --batch. New option --debug-wait n, so that it is possible to attach gdb when used in server mode. * query.c (agent_askpin): Don't ask in batch mode. * command.c: Removed the conversion macros as they are now in ../common/util.h. 2001-12-14 Marcus Brinkmann * query.c (LINELENGTH): Removed. (agent_askpin): Use ASSUAN_LINELENGTH, not LINELENGTH. 2001-11-19 Werner Koch * gpg-agent.c: Removed all GUI code, removed code for old protocol. New code to use the Assuan protocol as a server and also to communicate with a new ask-passphrase utility. 2000-11-22 Werner Koch * gpg-agent.c (main): csh support by Dan Winship, new options --sh and --csh and set default by consulting $SHELL. Mon Aug 21 17:59:17 CEST 2000 Werner Koch * gpg-agent.c (passphrase_dialog): Cleanup the window and added the user supplied text to the window. (main): Fixed segv in gtk_init when used without a command to start. * gpg-agent.c: --flush option. (req_flush): New. (req_clear_passphrase): Implemented. Fri Aug 18 14:27:14 CEST 2000 Werner Koch * gpg-agent.c: New. * Makefile.am: New. Copyright 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009 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/agent/Makefile.am b/agent/Makefile.am index 38200c1d8..4f5c08ef9 100644 --- a/agent/Makefile.am +++ b/agent/Makefile.am @@ -1,109 +1,109 @@ # Copyright (C) 2001, 2003, 2004, 2005 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 3 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, see . ## Process this file with automake to produce Makefile.in bin_PROGRAMS = gpg-agent libexec_PROGRAMS = gpg-protect-tool gpg-preset-passphrase noinst_PROGRAMS = $(TESTS) # EXTRA_DIST = gpg-agent.ico gpg-agent-resource.rc AM_CPPFLAGS = -I$(top_srcdir)/gl -I$(top_srcdir)/common -I$(top_srcdir)/intl include $(top_srcdir)/am/cmacros.am AM_CFLAGS = $(LIBGCRYPT_CFLAGS) $(GPG_ERROR_CFLAGS) gpg_agent_SOURCES = \ gpg-agent.c agent.h \ command.c command-ssh.c \ call-pinentry.c \ cache.c \ trans.c \ findkey.c \ pksign.c \ pkdecrypt.c \ genkey.c \ protect.c \ trustlist.c \ divert-scd.c \ call-scd.c \ learncard.c -common_libs = $(libcommon) ../jnlib/libjnlib.a ../gl/libgnu.a -commonpth_libs = $(libcommonpth) ../jnlib/libjnlib.a ../gl/libgnu.a +common_libs = $(libcommon) ../gl/libgnu.a +commonpth_libs = $(libcommonpth) ../gl/libgnu.a pwquery_libs = ../common/libsimple-pwquery.a #if HAVE_W32_SYSTEM #.rc.o: # $(WINDRES) `echo $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) | \ # sed -e 's/-I/--include-dir /g;s/-D/--define /g'` -i $< -o $@ # #gpg_agent_res_ldflags = -Wl,gpg-agent-resource.o -Wl,--subsystem,windows #gpg_agent_res_deps = gpg-agent-resource.o #else gpg_agent_res_ldflags = gpg_agent_res_deps = #endif gpg_agent_CFLAGS = $(AM_CFLAGS) $(LIBASSUAN_CFLAGS) $(PTH_CFLAGS) gpg_agent_LDADD = $(commonpth_libs) \ $(LIBGCRYPT_LIBS) $(LIBASSUAN_LIBS) $(PTH_LIBS) \ $(GPG_ERROR_LIBS) $(LIBINTL) $(NETLIBS) $(LIBICONV) gpg_agent_LDFLAGS = $(gpg_agent_res_ldflags) gpg_agent_DEPENDENCIES = $(gpg_agent_res_deps) gpg_protect_tool_SOURCES = \ protect-tool.c \ protect.c \ minip12.c minip12.h gpg_protect_tool_CFLAGS = $(AM_CFLAGS) $(LIBASSUAN_CFLAGS) gpg_protect_tool_LDADD = $(common_libs) $(LIBGCRYPT_LIBS) $(LIBASSUAN_LIBS) \ $(GPG_ERROR_LIBS) $(LIBINTL) $(NETLIBS) $(LIBICONV) gpg_preset_passphrase_SOURCES = \ preset-passphrase.c # Needs $(NETLIBS) for libsimple-pwquery.la. gpg_preset_passphrase_LDADD = \ $(pwquery_libs) $(common_libs) \ $(LIBGCRYPT_LIBS) $(GPG_ERROR_LIBS) $(LIBINTL) $(NETLIBS) $(LIBICONV) # Make sure that all libs are build before we use them. This is # important for things like make -j2. $(PROGRAMS): $(common_libs) $(commonpth_libs) $(pwquery_libs) # # Module tests # TESTS = t-protect t_common_ldadd = $(common_libs) \ $(LIBGCRYPT_LIBS) $(GPG_ERROR_LIBS) $(LIBINTL) $(LIBICONV) t_protect_SOURCES = t-protect.c protect.c t_protect_LDADD = $(t_common_ldadd) diff --git a/agent/command-ssh.c b/agent/command-ssh.c index 12fe60a15..077d93209 100644 --- a/agent/command-ssh.c +++ b/agent/command-ssh.c @@ -1,2984 +1,2983 @@ /* command-ssh.c - gpg-agent's ssh-agent emulation layer * Copyright (C) 2004, 2005, 2006, 2009 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 3 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, see . */ /* Only v2 of the ssh-agent protocol is implemented. */ #include #include #include #include #include #include #include #include #include #include "agent.h" -#include "estream.h" #include "i18n.h" /* Request types. */ #define SSH_REQUEST_REQUEST_IDENTITIES 11 #define SSH_REQUEST_SIGN_REQUEST 13 #define SSH_REQUEST_ADD_IDENTITY 17 #define SSH_REQUEST_REMOVE_IDENTITY 18 #define SSH_REQUEST_REMOVE_ALL_IDENTITIES 19 #define SSH_REQUEST_LOCK 22 #define SSH_REQUEST_UNLOCK 23 #define SSH_REQUEST_ADD_ID_CONSTRAINED 25 /* Options. */ #define SSH_OPT_CONSTRAIN_LIFETIME 1 #define SSH_OPT_CONSTRAIN_CONFIRM 2 /* Response types. */ #define SSH_RESPONSE_SUCCESS 6 #define SSH_RESPONSE_FAILURE 5 #define SSH_RESPONSE_IDENTITIES_ANSWER 12 #define SSH_RESPONSE_SIGN_RESPONSE 14 /* Other constants. */ #define SSH_DSA_SIGNATURE_PADDING 20 #define SSH_DSA_SIGNATURE_ELEMS 2 #define SPEC_FLAG_USE_PKCS1V2 (1 << 0) /* The blurb we put into the header of a newly created control file. */ static const char sshcontrolblurb[] = "# List of allowed ssh keys. Only keys present in this file are used\n" "# in the SSH protocol. The ssh-add tool may add new entries to this\n" "# file to enable them; you may also add them manually. Comment\n" "# lines, like this one, as well as empty lines are ignored. Lines do\n" "# have a certain length limit but this is not serious limitation as\n" "# the format of the entries is fixed and checked by gpg-agent. A\n" "# non-comment line starts with optional white spaces, followed by the\n" "# keygrip of the key given as 40 hex digits, optionally followed by a\n" "# the caching TTL in seconds and another optional field for arbitrary\n" "# flags. Prepend the keygrip with an '!' mark to disable it.\n" "\n"; /* Macros. */ /* Return a new uint32 with b0 being the most significant byte and b3 being the least significant byte. */ #define uint32_construct(b0, b1, b2, b3) \ ((b0 << 24) | (b1 << 16) | (b2 << 8) | b3) /* * Basic types. */ /* Type for a request handler. */ typedef gpg_error_t (*ssh_request_handler_t) (ctrl_t ctrl, estream_t request, estream_t response); /* Type, which is used for associating request handlers with the appropriate request IDs. */ typedef struct ssh_request_spec { unsigned char type; ssh_request_handler_t handler; const char *identifier; unsigned int secret_input; } ssh_request_spec_t; /* Type for "key modifier functions", which are necessary since OpenSSH and GnuPG treat key material slightly different. A key modifier is called right after a new key identity has been received in order to "sanitize" the material. */ typedef gpg_error_t (*ssh_key_modifier_t) (const char *elems, gcry_mpi_t *mpis); /* The encoding of a generated signature is dependent on the algorithm; therefore algorithm specific signature encoding functions are necessary. */ typedef gpg_error_t (*ssh_signature_encoder_t) (estream_t signature_blob, gcry_mpi_t *mpis); /* Type, which is used for boundling all the algorithm specific information together in a single object. */ typedef struct ssh_key_type_spec { /* Algorithm identifier as used by OpenSSH. */ const char *ssh_identifier; /* Algorithm identifier as used by GnuPG. */ const char *identifier; /* List of MPI names for secret keys; order matches the one of the agent protocol. */ const char *elems_key_secret; /* List of MPI names for public keys; order matches the one of the agent protocol. */ const char *elems_key_public; /* List of MPI names for signature data. */ const char *elems_signature; /* List of MPI names for secret keys; order matches the one, which is required by gpg-agent's key access layer. */ const char *elems_sexp_order; /* Key modifier function. Key modifier functions are necessary in order to fix any inconsistencies between the representation of keys on the SSH and on the GnuPG side. */ ssh_key_modifier_t key_modifier; /* Signature encoder function. Signature encoder functions are necessary since the encoding of signatures depends on the used algorithm. */ ssh_signature_encoder_t signature_encoder; /* Misc flags. */ unsigned int flags; } ssh_key_type_spec_t; /* Prototypes. */ static gpg_error_t ssh_handler_request_identities (ctrl_t ctrl, estream_t request, estream_t response); static gpg_error_t ssh_handler_sign_request (ctrl_t ctrl, estream_t request, estream_t response); static gpg_error_t ssh_handler_add_identity (ctrl_t ctrl, estream_t request, estream_t response); static gpg_error_t ssh_handler_remove_identity (ctrl_t ctrl, estream_t request, estream_t response); static gpg_error_t ssh_handler_remove_all_identities (ctrl_t ctrl, estream_t request, estream_t response); static gpg_error_t ssh_handler_lock (ctrl_t ctrl, estream_t request, estream_t response); static gpg_error_t ssh_handler_unlock (ctrl_t ctrl, estream_t request, estream_t response); static gpg_error_t ssh_key_modifier_rsa (const char *elems, gcry_mpi_t *mpis); static gpg_error_t ssh_signature_encoder_rsa (estream_t signature_blob, gcry_mpi_t *mpis); static gpg_error_t ssh_signature_encoder_dsa (estream_t signature_blob, gcry_mpi_t *mpis); /* Global variables. */ /* Associating request types with the corresponding request handlers. */ static ssh_request_spec_t request_specs[] = { #define REQUEST_SPEC_DEFINE(id, name, secret_input) \ { SSH_REQUEST_##id, ssh_handler_##name, #name, secret_input } REQUEST_SPEC_DEFINE (REQUEST_IDENTITIES, request_identities, 1), REQUEST_SPEC_DEFINE (SIGN_REQUEST, sign_request, 0), REQUEST_SPEC_DEFINE (ADD_IDENTITY, add_identity, 1), REQUEST_SPEC_DEFINE (ADD_ID_CONSTRAINED, add_identity, 1), REQUEST_SPEC_DEFINE (REMOVE_IDENTITY, remove_identity, 0), REQUEST_SPEC_DEFINE (REMOVE_ALL_IDENTITIES, remove_all_identities, 0), REQUEST_SPEC_DEFINE (LOCK, lock, 0), REQUEST_SPEC_DEFINE (UNLOCK, unlock, 0) #undef REQUEST_SPEC_DEFINE }; /* Table holding key type specifications. */ static ssh_key_type_spec_t ssh_key_types[] = { { "ssh-rsa", "rsa", "nedupq", "en", "s", "nedpqu", ssh_key_modifier_rsa, ssh_signature_encoder_rsa, SPEC_FLAG_USE_PKCS1V2 }, { "ssh-dss", "dsa", "pqgyx", "pqgy", "rs", "pqgyx", NULL, ssh_signature_encoder_dsa, 0 }, }; /* General utility functions. */ /* A secure realloc, i.e. it makes sure to allocate secure memory if A is NULL. This is required because the standard gcry_realloc does not know whether to allocate secure or normal if NULL is passed as existing buffer. */ static void * realloc_secure (void *a, size_t n) { void *p; if (a) p = gcry_realloc (a, n); else p = gcry_malloc_secure (n); return p; } /* Create and return a new C-string from DATA/DATA_N (i.e.: add NUL-termination); return NULL on OOM. */ static char * make_cstring (const char *data, size_t data_n) { char *s; s = xtrymalloc (data_n + 1); if (s) { memcpy (s, data, data_n); s[data_n] = 0; } return s; } /* Primitive I/O functions. */ /* Read a byte from STREAM, store it in B. */ static gpg_error_t stream_read_byte (estream_t stream, unsigned char *b) { gpg_error_t err; int ret; ret = es_fgetc (stream); if (ret == EOF) { if (es_ferror (stream)) err = gpg_error_from_syserror (); else err = gpg_error (GPG_ERR_EOF); *b = 0; } else { *b = ret & 0xFF; err = 0; } return err; } /* Write the byte contained in B to STREAM. */ static gpg_error_t stream_write_byte (estream_t stream, unsigned char b) { gpg_error_t err; int ret; ret = es_fputc (b, stream); if (ret == EOF) err = gpg_error_from_syserror (); else err = 0; return err; } /* Read a uint32 from STREAM, store it in UINT32. */ static gpg_error_t stream_read_uint32 (estream_t stream, u32 *uint32) { unsigned char buffer[4]; size_t bytes_read; gpg_error_t err; int ret; ret = es_read (stream, buffer, sizeof (buffer), &bytes_read); if (ret) err = gpg_error_from_syserror (); else { if (bytes_read != sizeof (buffer)) err = gpg_error (GPG_ERR_EOF); else { u32 n; n = uint32_construct (buffer[0], buffer[1], buffer[2], buffer[3]); *uint32 = n; err = 0; } } return err; } /* Write the uint32 contained in UINT32 to STREAM. */ static gpg_error_t stream_write_uint32 (estream_t stream, u32 uint32) { unsigned char buffer[4]; gpg_error_t err; int ret; buffer[0] = uint32 >> 24; buffer[1] = uint32 >> 16; buffer[2] = uint32 >> 8; buffer[3] = uint32 >> 0; ret = es_write (stream, buffer, sizeof (buffer), NULL); if (ret) err = gpg_error_from_syserror (); else err = 0; return err; } /* Read SIZE bytes from STREAM into BUFFER. */ static gpg_error_t stream_read_data (estream_t stream, unsigned char *buffer, size_t size) { gpg_error_t err; size_t bytes_read; int ret; ret = es_read (stream, buffer, size, &bytes_read); if (ret) err = gpg_error_from_syserror (); else { if (bytes_read != size) err = gpg_error (GPG_ERR_EOF); else err = 0; } return err; } /* Write SIZE bytes from BUFFER to STREAM. */ static gpg_error_t stream_write_data (estream_t stream, const unsigned char *buffer, size_t size) { gpg_error_t err; int ret; ret = es_write (stream, buffer, size, NULL); if (ret) err = gpg_error_from_syserror (); else err = 0; return err; } /* Read a binary string from STREAM into STRING, store size of string in STRING_SIZE; depending on SECURE use secure memory for string. */ static gpg_error_t stream_read_string (estream_t stream, unsigned int secure, unsigned char **string, u32 *string_size) { gpg_error_t err; unsigned char *buffer = NULL; u32 length = 0; /* Read string length. */ err = stream_read_uint32 (stream, &length); if (err) goto out; /* Allocate space. */ if (secure) buffer = xtrymalloc_secure (length + 1); else buffer = xtrymalloc (length + 1); if (! buffer) { err = gpg_error_from_syserror (); goto out; } /* Read data. */ err = stream_read_data (stream, buffer, length); if (err) goto out; /* Finalize string object. */ buffer[length] = 0; *string = buffer; if (string_size) *string_size = length; out: if (err) xfree (buffer); return err; } /* Read a C-string from STREAM, store copy in STRING. */ static gpg_error_t stream_read_cstring (estream_t stream, char **string) { unsigned char *buffer; gpg_error_t err; err = stream_read_string (stream, 0, &buffer, NULL); if (err) goto out; *string = (char *) buffer; out: return err; } /* Write a binary string from STRING of size STRING_N to STREAM. */ static gpg_error_t stream_write_string (estream_t stream, const unsigned char *string, u32 string_n) { gpg_error_t err; err = stream_write_uint32 (stream, string_n); if (err) goto out; err = stream_write_data (stream, string, string_n); out: return err; } /* Write a C-string from STRING to STREAM. */ static gpg_error_t stream_write_cstring (estream_t stream, const char *string) { gpg_error_t err; err = stream_write_string (stream, (const unsigned char *) string, strlen (string)); return err; } /* Read an MPI from STREAM, store it in MPINT. Depending on SECURE use secure memory. */ static gpg_error_t stream_read_mpi (estream_t stream, unsigned int secure, gcry_mpi_t *mpint) { unsigned char *mpi_data; u32 mpi_data_size; gpg_error_t err; gcry_mpi_t mpi; mpi_data = NULL; err = stream_read_string (stream, secure, &mpi_data, &mpi_data_size); if (err) goto out; /* To avoid excessive use of secure memory we check that an MPI is not too large. */ if (mpi_data_size > 520) { log_error (_("ssh keys greater than %d bits are not supported\n"), 4096); err = GPG_ERR_TOO_LARGE; goto out; } err = gcry_mpi_scan (&mpi, GCRYMPI_FMT_STD, mpi_data, mpi_data_size, NULL); if (err) goto out; *mpint = mpi; out: xfree (mpi_data); return err; } /* Write the MPI contained in MPINT to STREAM. */ static gpg_error_t stream_write_mpi (estream_t stream, gcry_mpi_t mpint) { unsigned char *mpi_buffer; size_t mpi_buffer_n; gpg_error_t err; mpi_buffer = NULL; err = gcry_mpi_aprint (GCRYMPI_FMT_STD, &mpi_buffer, &mpi_buffer_n, mpint); if (err) goto out; err = stream_write_string (stream, mpi_buffer, mpi_buffer_n); out: xfree (mpi_buffer); return err; } /* Copy data from SRC to DST until EOF is reached. */ static gpg_error_t stream_copy (estream_t dst, estream_t src) { char buffer[BUFSIZ]; size_t bytes_read; gpg_error_t err; int ret; err = 0; while (1) { ret = es_read (src, buffer, sizeof (buffer), &bytes_read); if (ret || (! bytes_read)) { if (ret) err = gpg_error_from_syserror (); break; } ret = es_write (dst, buffer, bytes_read, NULL); if (ret) { err = gpg_error_from_syserror (); break; } } return err; } /* Read the content of the file specified by FILENAME into a newly create buffer, which is to be stored in BUFFER; store length of buffer in BUFFER_N. */ static gpg_error_t file_to_buffer (const char *filename, unsigned char **buffer, size_t *buffer_n) { unsigned char *buffer_new; struct stat statbuf; estream_t stream; gpg_error_t err; int ret; *buffer = NULL; *buffer_n = 0; buffer_new = NULL; err = 0; stream = es_fopen (filename, "r"); if (! stream) { err = gpg_error_from_syserror (); goto out; } ret = fstat (es_fileno (stream), &statbuf); if (ret) { err = gpg_error_from_syserror (); goto out; } buffer_new = xtrymalloc (statbuf.st_size); if (! buffer_new) { err = gpg_error_from_syserror (); goto out; } err = stream_read_data (stream, buffer_new, statbuf.st_size); if (err) goto out; *buffer = buffer_new; *buffer_n = statbuf.st_size; out: if (stream) es_fclose (stream); if (err) xfree (buffer_new); return err; } /* Open the ssh control file and create it if not available. With APPEND passed as true the file will be opened in append mode, otherwise in read only mode. On success a file pointer is stored at the address of R_FP. */ static gpg_error_t open_control_file (FILE **r_fp, int append) { gpg_error_t err; char *fname; FILE *fp; /* Note: As soon as we start to use non blocking functions here (i.e. where Pth might switch threads) we need to employ a mutex. */ *r_fp = NULL; fname = make_filename (opt.homedir, "sshcontrol", NULL); /* FIXME: With "a+" we are not able to check whether this will will be created and thus the blurb needs to be written first. */ fp = fopen (fname, append? "a+":"r"); if (!fp && errno == ENOENT) { /* Fixme: "x" is a GNU extension. We might want to use the es_ functions here. */ fp = fopen (fname, "wx"); if (!fp) { err = gpg_error (gpg_err_code_from_errno (errno)); log_error (_("can't create `%s': %s\n"), fname, gpg_strerror (err)); xfree (fname); return err; } fputs (sshcontrolblurb, fp); fclose (fp); fp = fopen (fname, append? "a+":"r"); } if (!fp) { err = gpg_error (gpg_err_code_from_errno (errno)); log_error (_("can't open `%s': %s\n"), fname, gpg_strerror (err)); xfree (fname); return err; } *r_fp = fp; return 0; } /* Search the file at stream FP from the beginning until a matching HEXGRIP is found; return success in this case and store true at DISABLED if the found key has been disabled. If R_TTL is not NULL a specified TTL for that key is stored there. */ static gpg_error_t search_control_file (FILE *fp, const char *hexgrip, int *r_disabled, int *r_ttl) { int c, i; char *p, *pend, line[256]; long ttl; assert (strlen (hexgrip) == 40 ); rewind (fp); *r_disabled = 0; next_line: do { if (!fgets (line, DIM(line)-1, fp) ) { if (feof (fp)) return gpg_error (GPG_ERR_EOF); return gpg_error (gpg_err_code_from_errno (errno)); } if (!*line || line[strlen(line)-1] != '\n') { /* Eat until end of line */ while ( (c=getc (fp)) != EOF && c != '\n') ; return gpg_error (*line? GPG_ERR_LINE_TOO_LONG : GPG_ERR_INCOMPLETE_LINE); } /* Allow for empty lines and spaces */ for (p=line; spacep (p); p++) ; } while (!*p || *p == '\n' || *p == '#'); *r_disabled = 0; if (*p == '!') { *r_disabled = 1; for (p++; spacep (p); p++) ; } for (i=0; hexdigitp (p) && i < 40; p++, i++) if (hexgrip[i] != (*p >= 'a'? (*p & 0xdf): *p)) goto next_line; if (i != 40 || !(spacep (p) || *p == '\n')) { log_error ("invalid formatted line in ssh control file\n"); return gpg_error (GPG_ERR_BAD_DATA); } ttl = strtol (p, &pend, 10); p = pend; if (!(spacep (p) || *p == '\n') || ttl < -1) { log_error ("invalid TTL value in ssh control file; assuming 0\n"); ttl = 0; } if (r_ttl) *r_ttl = ttl; /* Here is the place to parse flags if we need them. */ return 0; /* Okay: found it. */ } /* Add an entry to the control file to mark the key with the keygrip HEXGRIP as usable for SSH; i.e. it will be returned when ssh asks for it. This function is in general used to add a key received through the ssh-add function. We can assume that the user wants to allow ssh using this key. */ static gpg_error_t add_control_entry (ctrl_t ctrl, const char *hexgrip, int ttl) { gpg_error_t err; FILE *fp; int disabled; (void)ctrl; err = open_control_file (&fp, 1); if (err) return err; err = search_control_file (fp, hexgrip, &disabled, NULL); if (err && gpg_err_code(err) == GPG_ERR_EOF) { struct tm *tp; time_t atime = time (NULL); /* Not yet in the file - add it. Because the file has been opened in append mode, we simply need to write to it. */ tp = localtime (&atime); fprintf (fp, "# Key added on %04d-%02d-%02d %02d:%02d:%02d\n%s %d\n", 1900+tp->tm_year, tp->tm_mon+1, tp->tm_mday, tp->tm_hour, tp->tm_min, tp->tm_sec, hexgrip, ttl); } fclose (fp); return 0; } /* Scan the sshcontrol file and return the TTL. */ static int ttl_from_sshcontrol (const char *hexgrip) { FILE *fp; int disabled, ttl; if (!hexgrip || strlen (hexgrip) != 40) return 0; /* Wrong input: Use global default. */ if (open_control_file (&fp, 0)) return 0; /* Error: Use the global default TTL. */ if (search_control_file (fp, hexgrip, &disabled, &ttl) || disabled) ttl = 0; /* Use the global default if not found or disabled. */ fclose (fp); return ttl; } /* MPI lists. */ /* Free the list of MPIs MPI_LIST. */ static void mpint_list_free (gcry_mpi_t *mpi_list) { if (mpi_list) { unsigned int i; for (i = 0; mpi_list[i]; i++) gcry_mpi_release (mpi_list[i]); xfree (mpi_list); } } /* Receive key material MPIs from STREAM according to KEY_SPEC; depending on SECRET expect a public key or secret key. The newly allocated list of MPIs is stored in MPI_LIST. Returns usual error code. */ static gpg_error_t ssh_receive_mpint_list (estream_t stream, int secret, ssh_key_type_spec_t key_spec, gcry_mpi_t **mpi_list) { unsigned int elems_public_n; const char *elems_public; unsigned int elems_n; const char *elems; int elem_is_secret; gcry_mpi_t *mpis; gpg_error_t err; unsigned int i; mpis = NULL; err = 0; if (secret) elems = key_spec.elems_key_secret; else elems = key_spec.elems_key_public; elems_n = strlen (elems); elems_public = key_spec.elems_key_public; elems_public_n = strlen (elems_public); mpis = xtrycalloc (elems_n + 1, sizeof *mpis ); if (!mpis) { err = gpg_error_from_syserror (); goto out; } elem_is_secret = 0; for (i = 0; i < elems_n; i++) { if (secret) elem_is_secret = ! strchr (elems_public, elems[i]); err = stream_read_mpi (stream, elem_is_secret, &mpis[i]); if (err) break; } if (err) goto out; *mpi_list = mpis; out: if (err) mpint_list_free (mpis); return err; } /* Key modifier function for RSA. */ static gpg_error_t ssh_key_modifier_rsa (const char *elems, gcry_mpi_t *mpis) { gcry_mpi_t p; gcry_mpi_t q; gcry_mpi_t u; if (strcmp (elems, "nedupq")) /* Modifying only necessary for secret keys. */ goto out; u = mpis[3]; p = mpis[4]; q = mpis[5]; if (gcry_mpi_cmp (p, q) > 0) { /* P shall be smaller then Q! Swap primes. iqmp becomes u. */ gcry_mpi_t tmp; tmp = mpis[4]; mpis[4] = mpis[5]; mpis[5] = tmp; } else /* U needs to be recomputed. */ gcry_mpi_invm (u, p, q); out: return 0; } /* Signature encoder function for RSA. */ static gpg_error_t ssh_signature_encoder_rsa (estream_t signature_blob, gcry_mpi_t *mpis) { unsigned char *data; size_t data_n; gpg_error_t err; gcry_mpi_t s; s = mpis[0]; err = gcry_mpi_aprint (GCRYMPI_FMT_USG, &data, &data_n, s); if (err) goto out; err = stream_write_string (signature_blob, data, data_n); xfree (data); out: return err; } /* Signature encoder function for DSA. */ static gpg_error_t ssh_signature_encoder_dsa (estream_t signature_blob, gcry_mpi_t *mpis) { unsigned char buffer[SSH_DSA_SIGNATURE_PADDING * SSH_DSA_SIGNATURE_ELEMS]; unsigned char *data; size_t data_n; gpg_error_t err; int i; data = NULL; for (i = 0; i < 2; i++) { err = gcry_mpi_aprint (GCRYMPI_FMT_USG, &data, &data_n, mpis[i]); if (err) break; if (data_n > SSH_DSA_SIGNATURE_PADDING) { err = gpg_error (GPG_ERR_INTERNAL); /* FIXME? */ break; } memset (buffer + (i * SSH_DSA_SIGNATURE_PADDING), 0, SSH_DSA_SIGNATURE_PADDING - data_n); memcpy (buffer + (i * SSH_DSA_SIGNATURE_PADDING) + (SSH_DSA_SIGNATURE_PADDING - data_n), data, data_n); xfree (data); data = NULL; } if (err) goto out; err = stream_write_string (signature_blob, buffer, sizeof (buffer)); out: xfree (data); return err; } /* S-Expressions. */ /* This function constructs a new S-Expression for the key identified by the KEY_SPEC, SECRET, MPIS and COMMENT, which is to be stored in *SEXP. Returns usual error code. */ static gpg_error_t sexp_key_construct (gcry_sexp_t *sexp, ssh_key_type_spec_t key_spec, int secret, gcry_mpi_t *mpis, const char *comment) { const char *key_identifier[] = { "public-key", "private-key" }; gcry_sexp_t sexp_new; char *sexp_template; size_t sexp_template_n; gpg_error_t err; const char *elems; size_t elems_n; unsigned int i; unsigned int j; void **arg_list; err = 0; sexp_new = NULL; arg_list = NULL; if (secret) elems = key_spec.elems_sexp_order; else elems = key_spec.elems_key_public; elems_n = strlen (elems); /* Calculate size for sexp_template_n: "(%s(%s)(comment%s))" -> 20 + sizeof (). mpi: (X%m) -> 5. */ sexp_template_n = 20 + (elems_n * 5); sexp_template = xtrymalloc (sexp_template_n); if (! sexp_template) { err = gpg_error_from_syserror (); goto out; } /* Key identifier, algorithm identifier, mpis, comment. */ arg_list = xtrymalloc (sizeof (*arg_list) * (2 + elems_n + 1)); if (! arg_list) { err = gpg_error_from_syserror (); goto out; } i = 0; arg_list[i++] = &key_identifier[secret]; arg_list[i++] = &key_spec.identifier; *sexp_template = 0; sexp_template_n = 0; sexp_template_n = sprintf (sexp_template + sexp_template_n, "(%%s(%%s"); for (i = 0; i < elems_n; i++) { sexp_template_n += sprintf (sexp_template + sexp_template_n, "(%c%%m)", elems[i]); if (secret) { for (j = 0; j < elems_n; j++) if (key_spec.elems_key_secret[j] == elems[i]) break; } else j = i; arg_list[i + 2] = &mpis[j]; } sexp_template_n += sprintf (sexp_template + sexp_template_n, ")(comment%%s))"); arg_list[i + 2] = &comment; err = gcry_sexp_build_array (&sexp_new, NULL, sexp_template, arg_list); if (err) goto out; *sexp = sexp_new; out: xfree (arg_list); xfree (sexp_template); return err; } /* This functions breaks up the key contained in the S-Expression SEXP according to KEY_SPEC. The MPIs are bundled in a newly create list, which is to be stored in MPIS; a newly allocated string holding the comment will be stored in COMMENT; SECRET will be filled with a boolean flag specifying what kind of key it is. Returns usual error code. */ static gpg_error_t sexp_key_extract (gcry_sexp_t sexp, ssh_key_type_spec_t key_spec, int *secret, gcry_mpi_t **mpis, char **comment) { gpg_error_t err; gcry_sexp_t value_list; gcry_sexp_t value_pair; gcry_sexp_t comment_list; unsigned int i; char *comment_new; const char *data; size_t data_n; int is_secret; size_t elems_n; const char *elems; gcry_mpi_t *mpis_new; gcry_mpi_t mpi; err = 0; value_list = NULL; value_pair = NULL; comment_list = NULL; comment_new = NULL; mpis_new = NULL; data = gcry_sexp_nth_data (sexp, 0, &data_n); if (! data) { err = gpg_error (GPG_ERR_INV_SEXP); goto out; } if ((data_n == 10 && !strncmp (data, "public-key", 10)) || (data_n == 21 && !strncmp (data, "protected-private-key", 21)) || (data_n == 20 && !strncmp (data, "shadowed-private-key", 20))) { is_secret = 0; elems = key_spec.elems_key_public; } else if (data_n == 11 && !strncmp (data, "private-key", 11)) { is_secret = 1; elems = key_spec.elems_key_secret; } else { err = gpg_error (GPG_ERR_INV_SEXP); goto out; } elems_n = strlen (elems); mpis_new = xtrycalloc (elems_n + 1, sizeof *mpis_new ); if (!mpis_new) { err = gpg_error_from_syserror (); goto out; } value_list = gcry_sexp_find_token (sexp, key_spec.identifier, 0); if (! value_list) { err = gpg_error (GPG_ERR_INV_SEXP); goto out; } for (i = 0; i < elems_n; i++) { value_pair = gcry_sexp_find_token (value_list, elems + i, 1); if (! value_pair) { err = gpg_error (GPG_ERR_INV_SEXP); break; } /* Note that we need to use STD format; i.e. prepend a 0x00 to indicate a positive number if the high bit is set. */ mpi = gcry_sexp_nth_mpi (value_pair, 1, GCRYMPI_FMT_STD); if (! mpi) { err = gpg_error (GPG_ERR_INV_SEXP); break; } mpis_new[i] = mpi; gcry_sexp_release (value_pair); value_pair = NULL; } if (err) goto out; /* We do not require a comment sublist to be present here. */ data = NULL; data_n = 0; comment_list = gcry_sexp_find_token (sexp, "comment", 0); if (comment_list) data = gcry_sexp_nth_data (comment_list, 1, &data_n); if (! data) { data = "(none)"; data_n = 6; } comment_new = make_cstring (data, data_n); if (! comment_new) { err = gpg_error_from_syserror (); goto out; } if (secret) *secret = is_secret; *mpis = mpis_new; *comment = comment_new; out: gcry_sexp_release (value_list); gcry_sexp_release (value_pair); gcry_sexp_release (comment_list); if (err) { xfree (comment_new); mpint_list_free (mpis_new); } return err; } /* Extract the car from SEXP, and create a newly created C-string which is to be stored in IDENTIFIER. */ static gpg_error_t sexp_extract_identifier (gcry_sexp_t sexp, char **identifier) { char *identifier_new; gcry_sexp_t sublist; const char *data; size_t data_n; gpg_error_t err; identifier_new = NULL; err = 0; sublist = gcry_sexp_nth (sexp, 1); if (! sublist) { err = gpg_error (GPG_ERR_INV_SEXP); goto out; } data = gcry_sexp_nth_data (sublist, 0, &data_n); if (! data) { err = gpg_error (GPG_ERR_INV_SEXP); goto out; } identifier_new = make_cstring (data, data_n); if (! identifier_new) { err = gpg_err_code_from_errno (errno); goto out; } *identifier = identifier_new; out: gcry_sexp_release (sublist); return err; } /* Key I/O. */ /* Search for a key specification entry. If SSH_NAME is not NULL, search for an entry whose "ssh_name" is equal to SSH_NAME; otherwise, search for an entry whose "name" is equal to NAME. Store found entry in SPEC on success, return error otherwise. */ static gpg_error_t ssh_key_type_lookup (const char *ssh_name, const char *name, ssh_key_type_spec_t *spec) { gpg_error_t err; unsigned int i; for (i = 0; i < DIM (ssh_key_types); i++) if ((ssh_name && (! strcmp (ssh_name, ssh_key_types[i].ssh_identifier))) || (name && (! strcmp (name, ssh_key_types[i].identifier)))) break; if (i == DIM (ssh_key_types)) err = gpg_error (GPG_ERR_NOT_FOUND); else { *spec = ssh_key_types[i]; err = 0; } return err; } /* Receive a key from STREAM, according to the key specification given as KEY_SPEC. Depending on SECRET, receive a secret or a public key. If READ_COMMENT is true, receive a comment string as well. Constructs a new S-Expression from received data and stores it in KEY_NEW. Returns zero on success or an error code. */ static gpg_error_t ssh_receive_key (estream_t stream, gcry_sexp_t *key_new, int secret, int read_comment, ssh_key_type_spec_t *key_spec) { gpg_error_t err; char *key_type; char *comment; gcry_sexp_t key; ssh_key_type_spec_t spec; gcry_mpi_t *mpi_list; const char *elems; mpi_list = NULL; key_type = NULL; comment = ""; key = NULL; err = stream_read_cstring (stream, &key_type); if (err) goto out; err = ssh_key_type_lookup (key_type, NULL, &spec); if (err) goto out; err = ssh_receive_mpint_list (stream, secret, spec, &mpi_list); if (err) goto out; if (read_comment) { err = stream_read_cstring (stream, &comment); if (err) goto out; } if (secret) elems = spec.elems_key_secret; else elems = spec.elems_key_public; if (spec.key_modifier) { err = (*spec.key_modifier) (elems, mpi_list); if (err) goto out; } err = sexp_key_construct (&key, spec, secret, mpi_list, comment); if (err) goto out; if (key_spec) *key_spec = spec; *key_new = key; out: mpint_list_free (mpi_list); xfree (key_type); if (read_comment) xfree (comment); return err; } /* Converts a key of type TYPE, whose key material is given in MPIS, into a newly created binary blob, which is to be stored in BLOB/BLOB_SIZE. Returns zero on success or an error code. */ static gpg_error_t ssh_convert_key_to_blob (unsigned char **blob, size_t *blob_size, const char *type, gcry_mpi_t *mpis) { unsigned char *blob_new; long int blob_size_new; estream_t stream; gpg_error_t err; unsigned int i; *blob = NULL; *blob_size = 0; blob_new = NULL; stream = NULL; err = 0; stream = es_mopen (NULL, 0, 0, 1, NULL, NULL, "r+"); if (! stream) { err = gpg_error_from_syserror (); goto out; } err = stream_write_cstring (stream, type); if (err) goto out; for (i = 0; mpis[i] && (! err); i++) err = stream_write_mpi (stream, mpis[i]); if (err) goto out; blob_size_new = es_ftell (stream); if (blob_size_new == -1) { err = gpg_error_from_syserror (); goto out; } err = es_fseek (stream, 0, SEEK_SET); if (err) goto out; blob_new = xtrymalloc (blob_size_new); if (! blob_new) { err = gpg_error_from_syserror (); goto out; } err = stream_read_data (stream, blob_new, blob_size_new); if (err) goto out; *blob = blob_new; *blob_size = blob_size_new; out: if (stream) es_fclose (stream); if (err) xfree (blob_new); return err; } /* Write the public key KEY_PUBLIC to STREAM in SSH key format. If OVERRIDE_COMMENT is not NULL, it will be used instead of the comment stored in the key. */ static gpg_error_t ssh_send_key_public (estream_t stream, gcry_sexp_t key_public, const char *override_comment) { ssh_key_type_spec_t spec; gcry_mpi_t *mpi_list; char *key_type; char *comment; unsigned char *blob; size_t blob_n; gpg_error_t err; key_type = NULL; mpi_list = NULL; comment = NULL; blob = NULL; err = sexp_extract_identifier (key_public, &key_type); if (err) goto out; err = ssh_key_type_lookup (NULL, key_type, &spec); if (err) goto out; err = sexp_key_extract (key_public, spec, NULL, &mpi_list, &comment); if (err) goto out; err = ssh_convert_key_to_blob (&blob, &blob_n, spec.ssh_identifier, mpi_list); if (err) goto out; err = stream_write_string (stream, blob, blob_n); if (err) goto out; err = stream_write_cstring (stream, override_comment? override_comment : comment); out: mpint_list_free (mpi_list); xfree (key_type); xfree (comment); xfree (blob); return err; } /* Read a public key out of BLOB/BLOB_SIZE according to the key specification given as KEY_SPEC, storing the new key in KEY_PUBLIC. Returns zero on success or an error code. */ static gpg_error_t ssh_read_key_public_from_blob (unsigned char *blob, size_t blob_size, gcry_sexp_t *key_public, ssh_key_type_spec_t *key_spec) { estream_t blob_stream; gpg_error_t err; err = 0; blob_stream = es_mopen (NULL, 0, 0, 1, NULL, NULL, "r+"); if (! blob_stream) { err = gpg_error_from_syserror (); goto out; } err = stream_write_data (blob_stream, blob, blob_size); if (err) goto out; err = es_fseek (blob_stream, 0, SEEK_SET); if (err) goto out; err = ssh_receive_key (blob_stream, key_public, 0, 0, key_spec); out: if (blob_stream) es_fclose (blob_stream); return err; } /* This function calculates the key grip for the key contained in the S-Expression KEY and writes it to BUFFER, which must be large enough to hold it. Returns usual error code. */ static gpg_error_t ssh_key_grip (gcry_sexp_t key, unsigned char *buffer) { if (!gcry_pk_get_keygrip (key, buffer)) return gpg_error (GPG_ERR_INTERNAL); return 0; } /* Converts the secret key KEY_SECRET into a public key, storing it in KEY_PUBLIC. SPEC is the according key specification. Returns zero on success or an error code. */ static gpg_error_t key_secret_to_public (gcry_sexp_t *key_public, ssh_key_type_spec_t spec, gcry_sexp_t key_secret) { char *comment; gcry_mpi_t *mpis; gpg_error_t err; int is_secret; comment = NULL; mpis = NULL; err = sexp_key_extract (key_secret, spec, &is_secret, &mpis, &comment); if (err) goto out; err = sexp_key_construct (key_public, spec, 0, mpis, comment); out: mpint_list_free (mpis); xfree (comment); return err; } /* Check whether a smartcard is available and whether it has a usable key. Store a copy of that key at R_PK and return 0. If no key is available store NULL at R_PK and return an error code. If CARDSN is not NULL, a string with the serial number of the card will be a malloced and stored there. */ static gpg_error_t card_key_available (ctrl_t ctrl, gcry_sexp_t *r_pk, char **cardsn) { gpg_error_t err; char *authkeyid; char *serialno = NULL; unsigned char *pkbuf; size_t pkbuflen; gcry_sexp_t s_pk; unsigned char grip[20]; *r_pk = NULL; if (cardsn) *cardsn = NULL; /* First see whether a card is available and whether the application is supported. */ err = agent_card_getattr (ctrl, "$AUTHKEYID", &authkeyid); if ( gpg_err_code (err) == GPG_ERR_CARD_REMOVED ) { /* Ask for the serial number to reset the card. */ err = agent_card_serialno (ctrl, &serialno); if (err) { if (opt.verbose) log_info (_("error getting serial number of card: %s\n"), gpg_strerror (err)); return err; } log_info (_("detected card with S/N: %s\n"), serialno); err = agent_card_getattr (ctrl, "$AUTHKEYID", &authkeyid); } if (err) { log_error (_("error getting default authentication keyID of card: %s\n"), gpg_strerror (err)); xfree (serialno); return err; } /* Get the S/N if we don't have it yet. Use the fast getattr method. */ if (!serialno && (err = agent_card_getattr (ctrl, "SERIALNO", &serialno)) ) { log_error (_("error getting serial number of card: %s\n"), gpg_strerror (err)); xfree (authkeyid); return err; } /* Read the public key. */ err = agent_card_readkey (ctrl, authkeyid, &pkbuf); if (err) { if (opt.verbose) log_info (_("no suitable card key found: %s\n"), gpg_strerror (err)); xfree (serialno); xfree (authkeyid); return err; } pkbuflen = gcry_sexp_canon_len (pkbuf, 0, NULL, NULL); err = gcry_sexp_sscan (&s_pk, NULL, (char*)pkbuf, pkbuflen); if (err) { log_error ("failed to build S-Exp from received card key: %s\n", gpg_strerror (err)); xfree (pkbuf); xfree (serialno); xfree (authkeyid); return err; } err = ssh_key_grip (s_pk, grip); if (err) { log_debug ("error computing keygrip from received card key: %s\n", gcry_strerror (err)); xfree (pkbuf); gcry_sexp_release (s_pk); xfree (serialno); xfree (authkeyid); return err; } if ( agent_key_available (grip) ) { /* (Shadow)-key is not available in our key storage. */ unsigned char *shadow_info; unsigned char *tmp; shadow_info = make_shadow_info (serialno, authkeyid); if (!shadow_info) { err = gpg_error_from_syserror (); xfree (pkbuf); gcry_sexp_release (s_pk); xfree (serialno); xfree (authkeyid); return err; } err = agent_shadow_key (pkbuf, shadow_info, &tmp); xfree (shadow_info); if (err) { log_error (_("shadowing the key failed: %s\n"), gpg_strerror (err)); xfree (pkbuf); gcry_sexp_release (s_pk); xfree (serialno); xfree (authkeyid); return err; } xfree (pkbuf); pkbuf = tmp; pkbuflen = gcry_sexp_canon_len (pkbuf, 0, NULL, NULL); assert (pkbuflen); err = agent_write_private_key (grip, pkbuf, pkbuflen, 0); if (err) { log_error (_("error writing key: %s\n"), gpg_strerror (err)); xfree (pkbuf); gcry_sexp_release (s_pk); xfree (serialno); xfree (authkeyid); return err; } } if (cardsn) { char *dispsn; /* If the card handler is able to return a short serialnumber, use that one, else use the complete serialno. */ if (!agent_card_getattr (ctrl, "$DISPSERIALNO", &dispsn)) { *cardsn = xtryasprintf ("cardno:%s", dispsn); xfree (dispsn); } else *cardsn = xtryasprintf ("cardno:%s", serialno); if (!*cardsn) { err = gpg_error_from_syserror (); xfree (pkbuf); gcry_sexp_release (s_pk); xfree (serialno); xfree (authkeyid); return err; } } xfree (pkbuf); xfree (serialno); xfree (authkeyid); *r_pk = s_pk; return 0; } /* Request handler. Each handler is provided with a CTRL context, a REQUEST object and a RESPONSE object. The actual request is to be read from REQUEST, the response needs to be written to RESPONSE. */ /* Handler for the "request_identities" command. */ static gpg_error_t ssh_handler_request_identities (ctrl_t ctrl, estream_t request, estream_t response) { char *key_type; ssh_key_type_spec_t spec; struct dirent *dir_entry; char *key_directory; size_t key_directory_n; char *key_path; unsigned char *buffer; size_t buffer_n; u32 key_counter; estream_t key_blobs; gcry_sexp_t key_secret; gcry_sexp_t key_public; DIR *dir; gpg_error_t err; int ret; FILE *ctrl_fp = NULL; char *cardsn; gpg_error_t ret_err; (void)request; /* Prepare buffer stream. */ key_directory = NULL; key_secret = NULL; key_public = NULL; key_type = NULL; key_path = NULL; key_counter = 0; buffer = NULL; dir = NULL; err = 0; key_blobs = es_mopen (NULL, 0, 0, 1, NULL, NULL, "r+"); if (! key_blobs) { err = gpg_error_from_syserror (); goto out; } /* Open key directory. */ key_directory = make_filename (opt.homedir, GNUPG_PRIVATE_KEYS_DIR, NULL); if (! key_directory) { err = gpg_err_code_from_errno (errno); goto out; } key_directory_n = strlen (key_directory); key_path = xtrymalloc (key_directory_n + 46); if (! key_path) { err = gpg_err_code_from_errno (errno); goto out; } sprintf (key_path, "%s/", key_directory); sprintf (key_path + key_directory_n + 41, ".key"); dir = opendir (key_directory); if (! dir) { err = gpg_err_code_from_errno (errno); goto out; } /* First check whether a key is currently available in the card reader - this should be allowed even without being listed in sshcontrol. */ if (!card_key_available (ctrl, &key_public, &cardsn)) { err = ssh_send_key_public (key_blobs, key_public, cardsn); gcry_sexp_release (key_public); key_public = NULL; xfree (cardsn); if (err) goto out; key_counter++; } /* Then look at all the registered an allowed keys. */ /* Fixme: We should better iterate over the control file and check whether the key file is there. This is better in resepct to performance if tehre are a lot of key sin our key storage. */ /* FIXME: make sure that buffer gets deallocated properly. */ err = open_control_file (&ctrl_fp, 0); if (err) goto out; while ( (dir_entry = readdir (dir)) ) { if ((strlen (dir_entry->d_name) == 44) && (! strncmp (dir_entry->d_name + 40, ".key", 4))) { char hexgrip[41]; int disabled; /* We do only want to return keys listed in our control file. */ strncpy (hexgrip, dir_entry->d_name, 40); hexgrip[40] = 0; if ( strlen (hexgrip) != 40 ) continue; if (search_control_file (ctrl_fp, hexgrip, &disabled, NULL) || disabled) continue; strncpy (key_path + key_directory_n + 1, dir_entry->d_name, 40); /* Read file content. */ err = file_to_buffer (key_path, &buffer, &buffer_n); if (err) goto out; err = gcry_sexp_sscan (&key_secret, NULL, (char*)buffer, buffer_n); if (err) goto out; xfree (buffer); buffer = NULL; err = sexp_extract_identifier (key_secret, &key_type); if (err) goto out; err = ssh_key_type_lookup (NULL, key_type, &spec); if (err) goto out; xfree (key_type); key_type = NULL; err = key_secret_to_public (&key_public, spec, key_secret); if (err) goto out; gcry_sexp_release (key_secret); key_secret = NULL; err = ssh_send_key_public (key_blobs, key_public, NULL); if (err) goto out; gcry_sexp_release (key_public); key_public = NULL; key_counter++; } } ret = es_fseek (key_blobs, 0, SEEK_SET); if (ret) { err = gpg_error_from_syserror (); goto out; } out: /* Send response. */ gcry_sexp_release (key_secret); gcry_sexp_release (key_public); if (! err) { ret_err = stream_write_byte (response, SSH_RESPONSE_IDENTITIES_ANSWER); if (ret_err) goto leave; ret_err = stream_write_uint32 (response, key_counter); if (ret_err) goto leave; ret_err = stream_copy (response, key_blobs); if (ret_err) goto leave; } else { ret_err = stream_write_byte (response, SSH_RESPONSE_FAILURE); goto leave; }; leave: if (key_blobs) es_fclose (key_blobs); if (dir) closedir (dir); if (ctrl_fp) fclose (ctrl_fp); xfree (key_directory); xfree (key_path); xfree (buffer); xfree (key_type); return ret_err; } /* This function hashes the data contained in DATA of size DATA_N according to the message digest algorithm specified by MD_ALGORITHM and writes the message digest to HASH, which needs to large enough for the digest. */ static gpg_error_t data_hash (unsigned char *data, size_t data_n, int md_algorithm, unsigned char *hash) { gcry_md_hash_buffer (md_algorithm, hash, data, data_n); return 0; } /* This function signs the data contained in CTRL, stores the created signature in newly allocated memory in SIG and it's size in SIG_N; SIG_ENCODER is the signature encoder to use. */ static gpg_error_t data_sign (ctrl_t ctrl, ssh_signature_encoder_t sig_encoder, unsigned char **sig, size_t *sig_n) { gpg_error_t err; gcry_sexp_t signature_sexp = NULL; estream_t stream = NULL; gcry_sexp_t valuelist = NULL; gcry_sexp_t sublist = NULL; gcry_mpi_t sig_value = NULL; unsigned char *sig_blob = NULL; size_t sig_blob_n = 0; char *identifier = NULL; const char *identifier_raw; size_t identifier_n; ssh_key_type_spec_t spec; int ret; unsigned int i; const char *elems; size_t elems_n; gcry_mpi_t *mpis = NULL; *sig = NULL; *sig_n = 0; ctrl->use_auth_call = 1; err = agent_pksign_do (ctrl, _("Please enter the passphrase " "for the ssh key%0A %c"), &signature_sexp, CACHE_MODE_SSH, ttl_from_sshcontrol); ctrl->use_auth_call = 0; if (err) goto out; valuelist = gcry_sexp_nth (signature_sexp, 1); if (! valuelist) { err = gpg_error (GPG_ERR_INV_SEXP); goto out; } stream = es_mopen (NULL, 0, 0, 1, NULL, NULL, "r+"); if (! stream) { err = gpg_error_from_syserror (); goto out; } identifier_raw = gcry_sexp_nth_data (valuelist, 0, &identifier_n); if (! identifier_raw) { err = gpg_error (GPG_ERR_INV_SEXP); goto out; } identifier = make_cstring (identifier_raw, identifier_n); if (! identifier) { err = gpg_error_from_syserror (); goto out; } err = ssh_key_type_lookup (NULL, identifier, &spec); if (err) goto out; err = stream_write_cstring (stream, spec.ssh_identifier); if (err) goto out; elems = spec.elems_signature; elems_n = strlen (elems); mpis = xtrycalloc (elems_n + 1, sizeof *mpis); if (!mpis) { err = gpg_error_from_syserror (); goto out; } for (i = 0; i < elems_n; i++) { sublist = gcry_sexp_find_token (valuelist, spec.elems_signature + i, 1); if (! sublist) { err = gpg_error (GPG_ERR_INV_SEXP); break; } sig_value = gcry_sexp_nth_mpi (sublist, 1, GCRYMPI_FMT_USG); if (! sig_value) { err = gpg_error (GPG_ERR_INTERNAL); /* FIXME? */ break; } gcry_sexp_release (sublist); sublist = NULL; mpis[i] = sig_value; } if (err) goto out; err = (*sig_encoder) (stream, mpis); if (err) goto out; sig_blob_n = es_ftell (stream); if (sig_blob_n == -1) { err = gpg_error_from_syserror (); goto out; } sig_blob = xtrymalloc (sig_blob_n); if (! sig_blob) { err = gpg_error_from_syserror (); goto out; } ret = es_fseek (stream, 0, SEEK_SET); if (ret) { err = gpg_error_from_syserror (); goto out; } err = stream_read_data (stream, sig_blob, sig_blob_n); if (err) goto out; *sig = sig_blob; *sig_n = sig_blob_n; out: if (err) xfree (sig_blob); if (stream) es_fclose (stream); gcry_sexp_release (valuelist); gcry_sexp_release (signature_sexp); gcry_sexp_release (sublist); mpint_list_free (mpis); xfree (identifier); return err; } /* Handler for the "sign_request" command. */ static gpg_error_t ssh_handler_sign_request (ctrl_t ctrl, estream_t request, estream_t response) { gcry_sexp_t key; ssh_key_type_spec_t spec; unsigned char hash[MAX_DIGEST_LEN]; unsigned int hash_n; unsigned char key_grip[20]; unsigned char *key_blob; u32 key_blob_size; unsigned char *data; unsigned char *sig; size_t sig_n; u32 data_size; u32 flags; gpg_error_t err; gpg_error_t ret_err; key_blob = NULL; data = NULL; sig = NULL; key = NULL; /* Receive key. */ err = stream_read_string (request, 0, &key_blob, &key_blob_size); if (err) goto out; err = ssh_read_key_public_from_blob (key_blob, key_blob_size, &key, &spec); if (err) goto out; /* Receive data to sign. */ err = stream_read_string (request, 0, &data, &data_size); if (err) goto out; /* FIXME? */ err = stream_read_uint32 (request, &flags); if (err) goto out; /* Hash data. */ hash_n = gcry_md_get_algo_dlen (GCRY_MD_SHA1); if (! hash_n) { err = gpg_error (GPG_ERR_INTERNAL); goto out; } err = data_hash (data, data_size, GCRY_MD_SHA1, hash); if (err) goto out; /* Calculate key grip. */ err = ssh_key_grip (key, key_grip); if (err) goto out; /* Sign data. */ ctrl->digest.algo = GCRY_MD_SHA1; memcpy (ctrl->digest.value, hash, hash_n); ctrl->digest.valuelen = hash_n; ctrl->digest.raw_value = ! (spec.flags & SPEC_FLAG_USE_PKCS1V2); ctrl->have_keygrip = 1; memcpy (ctrl->keygrip, key_grip, 20); err = data_sign (ctrl, spec.signature_encoder, &sig, &sig_n); out: /* Done. */ if (! err) { ret_err = stream_write_byte (response, SSH_RESPONSE_SIGN_RESPONSE); if (ret_err) goto leave; ret_err = stream_write_string (response, sig, sig_n); if (ret_err) goto leave; } else { ret_err = stream_write_byte (response, SSH_RESPONSE_FAILURE); if (ret_err) goto leave; } leave: gcry_sexp_release (key); xfree (key_blob); xfree (data); xfree (sig); return ret_err; } /* This function extracts the comment contained in the key S-Expression KEY and stores a copy in COMMENT. Returns usual error code. */ static gpg_error_t ssh_key_extract_comment (gcry_sexp_t key, char **comment) { gcry_sexp_t comment_list; char *comment_new; const char *data; size_t data_n; gpg_error_t err; comment_list = gcry_sexp_find_token (key, "comment", 0); if (! comment_list) { err = gpg_error (GPG_ERR_INV_SEXP); goto out; } data = gcry_sexp_nth_data (comment_list, 1, &data_n); if (! data) { err = gpg_error (GPG_ERR_INV_SEXP); goto out; } comment_new = make_cstring (data, data_n); if (! comment_new) { err = gpg_error_from_syserror (); goto out; } *comment = comment_new; err = 0; out: gcry_sexp_release (comment_list); return err; } /* This function converts the key contained in the S-Expression KEY into a buffer, which is protected by the passphrase PASSPHRASE. Returns usual error code. */ static gpg_error_t ssh_key_to_protected_buffer (gcry_sexp_t key, const char *passphrase, unsigned char **buffer, size_t *buffer_n) { unsigned char *buffer_new; unsigned int buffer_new_n; gpg_error_t err; err = 0; buffer_new_n = gcry_sexp_sprint (key, GCRYSEXP_FMT_CANON, NULL, 0); buffer_new = xtrymalloc_secure (buffer_new_n); if (! buffer_new) { err = gpg_error_from_syserror (); goto out; } gcry_sexp_sprint (key, GCRYSEXP_FMT_CANON, buffer_new, buffer_new_n); /* FIXME: guarantee? */ err = agent_protect (buffer_new, passphrase, buffer, buffer_n); out: xfree (buffer_new); return err; } /* Callback function to compare the first entered PIN with the one currently being entered. */ static int reenter_compare_cb (struct pin_entry_info_s *pi) { const char *pin1 = pi->check_cb_arg; if (!strcmp (pin1, pi->pin)) return 0; /* okay */ return -1; } /* Store the ssh KEY into our local key storage and protect it after asking for a passphrase. Cache that passphrase. TTL is the maximum caching time for that key. If the key already exists in our key storage, don't do anything. When entering a new key also add an entry to the sshcontrol file. */ static gpg_error_t ssh_identity_register (ctrl_t ctrl, gcry_sexp_t key, int ttl) { gpg_error_t err; unsigned char key_grip_raw[20]; char key_grip[41]; unsigned char *buffer = NULL; size_t buffer_n; char *description = NULL; const char *description2 = _("Please re-enter this passphrase"); char *comment = NULL; const char *initial_errtext = NULL; unsigned int i; struct pin_entry_info_s *pi = NULL, *pi2; err = ssh_key_grip (key, key_grip_raw); if (err) goto out; /* Check whether the key is already in our key storage. Don't do anything then. */ if ( !agent_key_available (key_grip_raw) ) goto out; /* Yes, key is available. */ err = ssh_key_extract_comment (key, &comment); if (err) goto out; if ( asprintf (&description, _("Please enter a passphrase to protect" " the received secret key%%0A" " %s%%0A" "within gpg-agent's key storage"), comment ? comment : "?") < 0) { err = gpg_error_from_syserror (); goto out; } pi = gcry_calloc_secure (2, sizeof (*pi) + 100 + 1); if (!pi) { err = gpg_error_from_syserror (); goto out; } pi2 = pi + (sizeof *pi + 100 + 1); pi->max_length = 100; pi->max_tries = 1; pi2->max_length = 100; pi2->max_tries = 1; pi2->check_cb = reenter_compare_cb; pi2->check_cb_arg = pi->pin; next_try: err = agent_askpin (ctrl, description, NULL, initial_errtext, pi); initial_errtext = NULL; if (err) goto out; /* Unless the passphrase is empty, ask to confirm it. */ if (pi->pin && *pi->pin) { err = agent_askpin (ctrl, description2, NULL, NULL, pi2); if (err == -1) { /* The re-entered one did not match and the user did not hit cancel. */ initial_errtext = _("does not match - try again"); goto next_try; } } err = ssh_key_to_protected_buffer (key, pi->pin, &buffer, &buffer_n); if (err) goto out; /* Store this key to our key storage. */ err = agent_write_private_key (key_grip_raw, buffer, buffer_n, 0); if (err) goto out; /* Cache this passphrase. */ for (i = 0; i < 20; i++) sprintf (key_grip + 2 * i, "%02X", key_grip_raw[i]); err = agent_put_cache (key_grip, CACHE_MODE_SSH, pi->pin, ttl); if (err) goto out; /* And add an entry to the sshcontrol file. */ err = add_control_entry (ctrl, key_grip, ttl); out: if (pi && pi->max_length) wipememory (pi->pin, pi->max_length); xfree (pi); xfree (buffer); xfree (comment); xfree (description); return err; } /* This function removes the key contained in the S-Expression KEY from the local key storage, in case it exists there. Returns usual error code. FIXME: this function is a stub. */ static gpg_error_t ssh_identity_drop (gcry_sexp_t key) { unsigned char key_grip[21] = { 0 }; gpg_error_t err; err = ssh_key_grip (key, key_grip); if (err) goto out; key_grip[sizeof (key_grip) - 1] = 0; /* FIXME: What to do here - forgetting the passphrase or deleting the key from key cache? */ out: return err; } /* Handler for the "add_identity" command. */ static gpg_error_t ssh_handler_add_identity (ctrl_t ctrl, estream_t request, estream_t response) { gpg_error_t ret_err; gpg_error_t err; gcry_sexp_t key; unsigned char b; int confirm; int ttl; confirm = 0; key = NULL; ttl = 0; /* FIXME? */ err = ssh_receive_key (request, &key, 1, 1, NULL); if (err) goto out; while (1) { err = stream_read_byte (request, &b); if (gpg_err_code (err) == GPG_ERR_EOF) { err = 0; break; } switch (b) { case SSH_OPT_CONSTRAIN_LIFETIME: { u32 n = 0; err = stream_read_uint32 (request, &n); if (! err) ttl = n; break; } case SSH_OPT_CONSTRAIN_CONFIRM: { confirm = 1; break; } default: /* FIXME: log/bad? */ break; } } if (err) goto out; /* FIXME: are constraints used correctly? */ err = ssh_identity_register (ctrl, key, ttl); out: gcry_sexp_release (key); if (! err) ret_err = stream_write_byte (response, SSH_RESPONSE_SUCCESS); else ret_err = stream_write_byte (response, SSH_RESPONSE_FAILURE); return ret_err; } /* Handler for the "remove_identity" command. */ static gpg_error_t ssh_handler_remove_identity (ctrl_t ctrl, estream_t request, estream_t response) { unsigned char *key_blob; u32 key_blob_size; gcry_sexp_t key; gpg_error_t ret_err; gpg_error_t err; (void)ctrl; /* Receive key. */ key_blob = NULL; key = NULL; err = stream_read_string (request, 0, &key_blob, &key_blob_size); if (err) goto out; err = ssh_read_key_public_from_blob (key_blob, key_blob_size, &key, NULL); if (err) goto out; err = ssh_identity_drop (key); out: xfree (key_blob); gcry_sexp_release (key); if (! err) ret_err = stream_write_byte (response, SSH_RESPONSE_SUCCESS); else ret_err = stream_write_byte (response, SSH_RESPONSE_FAILURE); return ret_err; } /* FIXME: stub function. Actually useful? */ static gpg_error_t ssh_identities_remove_all (void) { gpg_error_t err; err = 0; /* FIXME: shall we remove _all_ cache entries or only those registered through the ssh emulation? */ return err; } /* Handler for the "remove_all_identities" command. */ static gpg_error_t ssh_handler_remove_all_identities (ctrl_t ctrl, estream_t request, estream_t response) { gpg_error_t ret_err; gpg_error_t err; (void)ctrl; (void)request; err = ssh_identities_remove_all (); if (! err) ret_err = stream_write_byte (response, SSH_RESPONSE_SUCCESS); else ret_err = stream_write_byte (response, SSH_RESPONSE_FAILURE); return ret_err; } /* Lock agent? FIXME: stub function. */ static gpg_error_t ssh_lock (void) { gpg_error_t err; /* FIXME */ log_error ("ssh-agent's lock command is not implemented\n"); err = 0; return err; } /* Unock agent? FIXME: stub function. */ static gpg_error_t ssh_unlock (void) { gpg_error_t err; log_error ("ssh-agent's unlock command is not implemented\n"); err = 0; return err; } /* Handler for the "lock" command. */ static gpg_error_t ssh_handler_lock (ctrl_t ctrl, estream_t request, estream_t response) { gpg_error_t ret_err; gpg_error_t err; (void)ctrl; (void)request; err = ssh_lock (); if (! err) ret_err = stream_write_byte (response, SSH_RESPONSE_SUCCESS); else ret_err = stream_write_byte (response, SSH_RESPONSE_FAILURE); return ret_err; } /* Handler for the "unlock" command. */ static gpg_error_t ssh_handler_unlock (ctrl_t ctrl, estream_t request, estream_t response) { gpg_error_t ret_err; gpg_error_t err; (void)ctrl; (void)request; err = ssh_unlock (); if (! err) ret_err = stream_write_byte (response, SSH_RESPONSE_SUCCESS); else ret_err = stream_write_byte (response, SSH_RESPONSE_FAILURE); return ret_err; } /* Return the request specification for the request identified by TYPE or NULL in case the requested request specification could not be found. */ static ssh_request_spec_t * request_spec_lookup (int type) { ssh_request_spec_t *spec; unsigned int i; for (i = 0; i < DIM (request_specs); i++) if (request_specs[i].type == type) break; if (i == DIM (request_specs)) { if (opt.verbose) log_info ("ssh request %u is not supported\n", type); spec = NULL; } else spec = request_specs + i; return spec; } /* Process a single request. The request is read from and the response is written to STREAM_SOCK. Uses CTRL as context. Returns zero in case of success, non zero in case of failure. */ static int ssh_request_process (ctrl_t ctrl, estream_t stream_sock) { ssh_request_spec_t *spec; estream_t response; estream_t request; unsigned char request_type; gpg_error_t err; int send_err; int ret; unsigned char *request_data; u32 request_data_size; u32 response_size; request_data = NULL; response = NULL; request = NULL; send_err = 0; /* Create memory streams for request/response data. The entire request will be stored in secure memory, since it might contain secret key material. The response does not have to be stored in secure memory, since we never give out secret keys. Note: we only have little secure memory, but there is NO possibility of DoS here; only trusted clients are allowed to connect to the agent. What could happen is that the agent returns out-of-secure-memory errors on requests in case the agent's owner floods his own agent with many large messages. -moritz */ /* Retrieve request. */ err = stream_read_string (stream_sock, 1, &request_data, &request_data_size); if (err) goto out; if (opt.verbose > 1) log_info ("received ssh request of length %u\n", (unsigned int)request_data_size); if (! request_data_size) { send_err = 1; goto out; /* Broken request; FIXME. */ } request_type = request_data[0]; spec = request_spec_lookup (request_type); if (! spec) { send_err = 1; goto out; /* Unknown request; FIXME. */ } if (spec->secret_input) request = es_mopen (NULL, 0, 0, 1, realloc_secure, gcry_free, "r+"); else request = es_mopen (NULL, 0, 0, 1, gcry_realloc, gcry_free, "r+"); if (! request) { err = gpg_error_from_syserror (); goto out; } ret = es_setvbuf (request, NULL, _IONBF, 0); if (ret) { err = gpg_error_from_syserror (); goto out; } err = stream_write_data (request, request_data + 1, request_data_size - 1); if (err) goto out; es_rewind (request); response = es_mopen (NULL, 0, 0, 1, NULL, NULL, "r+"); if (! response) { err = gpg_error_from_syserror (); goto out; } if (opt.verbose) log_info ("ssh request handler for %s (%u) started\n", spec->identifier, spec->type); err = (*spec->handler) (ctrl, request, response); if (opt.verbose) { if (err) log_info ("ssh request handler for %s (%u) failed: %s\n", spec->identifier, spec->type, gpg_strerror (err)); else log_info ("ssh request handler for %s (%u) ready\n", spec->identifier, spec->type); } if (err) { send_err = 1; goto out; } response_size = es_ftell (response); if (opt.verbose > 1) log_info ("sending ssh response of length %u\n", (unsigned int)response_size); err = es_fseek (response, 0, SEEK_SET); if (err) { send_err = 1; goto out; } err = stream_write_uint32 (stream_sock, response_size); if (err) { send_err = 1; goto out; } err = stream_copy (stream_sock, response); if (err) goto out; err = es_fflush (stream_sock); if (err) goto out; out: if (err && es_feof (stream_sock)) log_error ("error occured while processing request: %s\n", gpg_strerror (err)); if (send_err) { if (opt.verbose > 1) log_info ("sending ssh error response\n"); err = stream_write_uint32 (stream_sock, 1); if (err) goto leave; err = stream_write_byte (stream_sock, SSH_RESPONSE_FAILURE); if (err) goto leave; } leave: if (request) es_fclose (request); if (response) es_fclose (response); xfree (request_data); /* FIXME? */ return !!err; } /* Start serving client on SOCK_CLIENT. */ void start_command_handler_ssh (ctrl_t ctrl, gnupg_fd_t sock_client) { estream_t stream_sock = NULL; gpg_error_t err = 0; int ret; /* Because the ssh protocol does not send us information about the the current TTY setting, we resort here to use those from startup or those explictly set. */ { static const char *names[] = {"GPG_TTY", "DISPLAY", "TERM", "XAUTHORITY", "PINENTRY_USER_DATA", NULL}; int idx; const char *value; for (idx=0; !err && names[idx]; idx++) if (!session_env_getenv (ctrl->session_env, names[idx]) && (value = session_env_getenv (opt.startup_env, names[idx]))) err = session_env_setenv (ctrl->session_env, names[idx], value); if (!err && !ctrl->lc_ctype && opt.startup_lc_ctype) if (!(ctrl->lc_ctype = xtrystrdup (opt.startup_lc_ctype))) err = gpg_error_from_syserror (); if (!err && !ctrl->lc_messages && opt.startup_lc_messages) if (!(ctrl->lc_messages = xtrystrdup (opt.startup_lc_messages))) err = gpg_error_from_syserror (); if (err) { log_error ("error setting default session environment: %s\n", gpg_strerror (err)); goto out; } } /* Create stream from socket. */ stream_sock = es_fdopen (FD2INT(sock_client), "r+"); if (!stream_sock) { err = gpg_error_from_syserror (); log_error (_("failed to create stream from socket: %s\n"), gpg_strerror (err)); goto out; } /* We have to disable the estream buffering, because the estream core doesn't know about secure memory. */ ret = es_setvbuf (stream_sock, NULL, _IONBF, 0); if (ret) { err = gpg_error_from_syserror (); log_error ("failed to disable buffering " "on socket stream: %s\n", gpg_strerror (err)); goto out; } /* Main processing loop. */ while ( !ssh_request_process (ctrl, stream_sock) ) { /* Check wether we have reached EOF before trying to read another request. */ int c; c = es_fgetc (stream_sock); if (c == EOF) break; es_ungetc (c, stream_sock); } /* Reset the SCD in case it has been used. */ agent_reset_scd (ctrl); out: if (stream_sock) es_fclose (stream_sock); } diff --git a/agent/minip12.c b/agent/minip12.c index 247171773..6f512e9e5 100644 --- a/agent/minip12.c +++ b/agent/minip12.c @@ -1,2360 +1,2360 @@ /* minip12.c - A minimal pkcs-12 implementation. * Copyright (C) 2002, 2003, 2004, 2006 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 3 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, see . */ #ifdef HAVE_CONFIG_H #include #endif #include #include #include #include #include #include #ifdef TEST #include #include #endif -#include "../jnlib/logging.h" -#include "../jnlib/utf8conv.h" +#include "../common/logging.h" +#include "../common/utf8conv.h" #include "minip12.h" #ifndef DIM #define DIM(v) (sizeof(v)/sizeof((v)[0])) #endif enum { UNIVERSAL = 0, APPLICATION = 1, ASNCONTEXT = 2, PRIVATE = 3 }; enum { TAG_NONE = 0, TAG_BOOLEAN = 1, TAG_INTEGER = 2, TAG_BIT_STRING = 3, TAG_OCTET_STRING = 4, TAG_NULL = 5, TAG_OBJECT_ID = 6, TAG_OBJECT_DESCRIPTOR = 7, TAG_EXTERNAL = 8, TAG_REAL = 9, TAG_ENUMERATED = 10, TAG_EMBEDDED_PDV = 11, TAG_UTF8_STRING = 12, TAG_REALTIVE_OID = 13, TAG_SEQUENCE = 16, TAG_SET = 17, TAG_NUMERIC_STRING = 18, TAG_PRINTABLE_STRING = 19, TAG_TELETEX_STRING = 20, TAG_VIDEOTEX_STRING = 21, TAG_IA5_STRING = 22, TAG_UTC_TIME = 23, TAG_GENERALIZED_TIME = 24, TAG_GRAPHIC_STRING = 25, TAG_VISIBLE_STRING = 26, TAG_GENERAL_STRING = 27, TAG_UNIVERSAL_STRING = 28, TAG_CHARACTER_STRING = 29, TAG_BMP_STRING = 30 }; static unsigned char const oid_data[9] = { 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x07, 0x01 }; static unsigned char const oid_encryptedData[9] = { 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x07, 0x06 }; static unsigned char const oid_pkcs_12_keyBag[11] = { 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x0C, 0x0A, 0x01, 0x01 }; static unsigned char const oid_pkcs_12_pkcs_8ShroudedKeyBag[11] = { 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x0C, 0x0A, 0x01, 0x02 }; static unsigned char const oid_pkcs_12_CertBag[11] = { 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x0C, 0x0A, 0x01, 0x03 }; static unsigned char const oid_pkcs_12_CrlBag[11] = { 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x0C, 0x0A, 0x01, 0x04 }; static unsigned char const oid_pbeWithSHAAnd3_KeyTripleDES_CBC[10] = { 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x0C, 0x01, 0x03 }; static unsigned char const oid_pbeWithSHAAnd40BitRC2_CBC[10] = { 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x0C, 0x01, 0x06 }; static unsigned char const oid_x509Certificate_for_pkcs_12[10] = { 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x09, 0x16, 0x01 }; static unsigned char const oid_rsaEncryption[9] = { 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01 }; static unsigned char const data_3desiter2048[30] = { 0x30, 0x1C, 0x06, 0x0A, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x0C, 0x01, 0x03, 0x30, 0x0E, 0x04, 0x08, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x02, 0x02, 0x08, 0x00 }; #define DATA_3DESITER2048_SALT_OFF 18 static unsigned char const data_rc2iter2048[30] = { 0x30, 0x1C, 0x06, 0x0A, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x0C, 0x01, 0x06, 0x30, 0x0E, 0x04, 0x08, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x02, 0x02, 0x08, 0x00 }; #define DATA_RC2ITER2048_SALT_OFF 18 static unsigned char const data_mactemplate[51] = { 0x30, 0x31, 0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0e, 0x03, 0x02, 0x1a, 0x05, 0x00, 0x04, 0x14, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x04, 0x08, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x02, 0x02, 0x08, 0x00 }; #define DATA_MACTEMPLATE_MAC_OFF 17 #define DATA_MACTEMPLATE_SALT_OFF 39 static unsigned char const data_attrtemplate[106] = { 0x31, 0x7c, 0x30, 0x55, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x09, 0x14, 0x31, 0x48, 0x1e, 0x46, 0x00, 0x47, 0x00, 0x6e, 0x00, 0x75, 0x00, 0x50, 0x00, 0x47, 0x00, 0x20, 0x00, 0x65, 0x00, 0x78, 0x00, 0x70, 0x00, 0x6f, 0x00, 0x72, 0x00, 0x74, 0x00, 0x65, 0x00, 0x64, 0x00, 0x20, 0x00, 0x63, 0x00, 0x65, 0x00, 0x72, 0x00, 0x74, 0x00, 0x69, 0x00, 0x66, 0x00, 0x69, 0x00, 0x63, 0x00, 0x61, 0x00, 0x74, 0x00, 0x65, 0x00, 0x20, 0x00, 0x66, 0x00, 0x66, 0x00, 0x66, 0x00, 0x66, 0x00, 0x66, 0x00, 0x66, 0x00, 0x66, 0x00, 0x66, 0x30, 0x23, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x09, 0x15, 0x31, 0x16, 0x04, 0x14 }; /* Need to append SHA-1 digest. */ #define DATA_ATTRTEMPLATE_KEYID_OFF 73 struct buffer_s { unsigned char *buffer; size_t length; }; struct tag_info { int class; int is_constructed; unsigned long tag; unsigned long length; /* length part of the TLV */ int nhdr; int ndef; /* It is an indefinite length */ }; /* Parse the buffer at the address BUFFER which is of SIZE and return the tag and the length part from the TLV triplet. Update BUFFER and SIZE on success. Checks that the encoded length does not exhaust the length of the provided buffer. */ static int parse_tag (unsigned char const **buffer, size_t *size, struct tag_info *ti) { int c; unsigned long tag; const unsigned char *buf = *buffer; size_t length = *size; ti->length = 0; ti->ndef = 0; ti->nhdr = 0; /* Get the tag */ if (!length) return -1; /* premature eof */ c = *buf++; length--; ti->nhdr++; ti->class = (c & 0xc0) >> 6; ti->is_constructed = !!(c & 0x20); tag = c & 0x1f; if (tag == 0x1f) { tag = 0; do { tag <<= 7; if (!length) return -1; /* premature eof */ c = *buf++; length--; ti->nhdr++; tag |= c & 0x7f; } while (c & 0x80); } ti->tag = tag; /* Get the length */ if (!length) return -1; /* prematureeof */ c = *buf++; length--; ti->nhdr++; if ( !(c & 0x80) ) ti->length = c; else if (c == 0x80) ti->ndef = 1; else if (c == 0xff) return -1; /* forbidden length value */ else { unsigned long len = 0; int count = c & 0x7f; for (; count; count--) { len <<= 8; if (!length) return -1; /* premature_eof */ c = *buf++; length--; ti->nhdr++; len |= c & 0xff; } ti->length = len; } if (ti->class == UNIVERSAL && !ti->tag) ti->length = 0; if (ti->length > length) return -1; /* data larger than buffer. */ *buffer = buf; *size = length; return 0; } /* Given an ASN.1 chunk of a structure like: 24 NDEF: OCTET STRING -- This is not passed to us 04 1: OCTET STRING -- INPUT point s to here : 30 04 1: OCTET STRING : 80 [...] 04 2: OCTET STRING : 00 00 : } -- This denotes a Null tag and are the last -- two bytes in INPUT. Create a new buffer with the content of that octet string. INPUT is the orginal buffer with a length as stored at LENGTH. Returns NULL on error or a new malloced buffer with the length of this new buffer stored at LENGTH and the number of bytes parsed from input are added to the value stored at INPUT_CONSUMED. INPUT_CONSUMED is allowed to be passed as NULL if the caller is not interested in this value. */ static unsigned char * cram_octet_string (const unsigned char *input, size_t *length, size_t *input_consumed) { const unsigned char *s = input; size_t n = *length; unsigned char *output, *d; struct tag_info ti; /* Allocate output buf. We know that it won't be longer than the input buffer. */ d = output = gcry_malloc (n); if (!output) goto bailout; for (;;) { if (parse_tag (&s, &n, &ti)) goto bailout; if (ti.class == UNIVERSAL && ti.tag == TAG_OCTET_STRING && !ti.ndef && !ti.is_constructed) { memcpy (d, s, ti.length); s += ti.length; d += ti.length; n -= ti.length; } else if (ti.class == UNIVERSAL && !ti.tag && !ti.is_constructed) break; /* Ready */ else goto bailout; } *length = d - output; if (input_consumed) *input_consumed += s - input; return output; bailout: if (input_consumed) *input_consumed += s - input; gcry_free (output); return NULL; } static int string_to_key (int id, char *salt, size_t saltlen, int iter, const char *pw, int req_keylen, unsigned char *keybuf) { int rc, i, j; gcry_md_hd_t md; gcry_mpi_t num_b1 = NULL; int pwlen; unsigned char hash[20], buf_b[64], buf_i[128], *p; size_t cur_keylen; size_t n; cur_keylen = 0; pwlen = strlen (pw); if (pwlen > 63/2) { log_error ("password too long\n"); return -1; } if (saltlen < 8) { log_error ("salt too short\n"); return -1; } /* Store salt and password in BUF_I */ p = buf_i; for(i=0; i < 64; i++) *p++ = salt [i%saltlen]; for(i=j=0; i < 64; i += 2) { *p++ = 0; *p++ = pw[j]; if (++j > pwlen) /* Note, that we include the trailing zero */ j = 0; } for (;;) { rc = gcry_md_open (&md, GCRY_MD_SHA1, 0); if (rc) { log_error ( "gcry_md_open failed: %s\n", gpg_strerror (rc)); return rc; } for(i=0; i < 64; i++) gcry_md_putc (md, id); gcry_md_write (md, buf_i, 128); memcpy (hash, gcry_md_read (md, 0), 20); gcry_md_close (md); for (i=1; i < iter; i++) gcry_md_hash_buffer (GCRY_MD_SHA1, hash, hash, 20); for (i=0; i < 20 && cur_keylen < req_keylen; i++) keybuf[cur_keylen++] = hash[i]; if (cur_keylen == req_keylen) { gcry_mpi_release (num_b1); return 0; /* ready */ } /* need more bytes. */ for(i=0; i < 64; i++) buf_b[i] = hash[i % 20]; rc = gcry_mpi_scan (&num_b1, GCRYMPI_FMT_USG, buf_b, 64, &n); if (rc) { log_error ( "gcry_mpi_scan failed: %s\n", gpg_strerror (rc)); return -1; } gcry_mpi_add_ui (num_b1, num_b1, 1); for (i=0; i < 128; i += 64) { gcry_mpi_t num_ij; rc = gcry_mpi_scan (&num_ij, GCRYMPI_FMT_USG, buf_i + i, 64, &n); if (rc) { log_error ( "gcry_mpi_scan failed: %s\n", gpg_strerror (rc)); return -1; } gcry_mpi_add (num_ij, num_ij, num_b1); gcry_mpi_clear_highbit (num_ij, 64*8); rc = gcry_mpi_print (GCRYMPI_FMT_USG, buf_i + i, 64, &n, num_ij); if (rc) { log_error ( "gcry_mpi_print failed: %s\n", gpg_strerror (rc)); return -1; } gcry_mpi_release (num_ij); } } } static int set_key_iv (gcry_cipher_hd_t chd, char *salt, size_t saltlen, int iter, const char *pw, int keybytes) { unsigned char keybuf[24]; int rc; assert (keybytes == 5 || keybytes == 24); if (string_to_key (1, salt, saltlen, iter, pw, keybytes, keybuf)) return -1; rc = gcry_cipher_setkey (chd, keybuf, keybytes); if (rc) { log_error ( "gcry_cipher_setkey failed: %s\n", gpg_strerror (rc)); return -1; } if (string_to_key (2, salt, saltlen, iter, pw, 8, keybuf)) return -1; rc = gcry_cipher_setiv (chd, keybuf, 8); if (rc) { log_error ("gcry_cipher_setiv failed: %s\n", gpg_strerror (rc)); return -1; } return 0; } static void crypt_block (unsigned char *buffer, size_t length, char *salt, size_t saltlen, int iter, const char *pw, int cipher_algo, int encrypt) { gcry_cipher_hd_t chd; int rc; rc = gcry_cipher_open (&chd, cipher_algo, GCRY_CIPHER_MODE_CBC, 0); if (rc) { log_error ( "gcry_cipher_open failed: %s\n", gpg_strerror(rc)); wipememory (buffer, length); return; } if (set_key_iv (chd, salt, saltlen, iter, pw, cipher_algo == GCRY_CIPHER_RFC2268_40? 5:24)) { wipememory (buffer, length); goto leave; } rc = encrypt? gcry_cipher_encrypt (chd, buffer, length, NULL, 0) : gcry_cipher_decrypt (chd, buffer, length, NULL, 0); if (rc) { wipememory (buffer, length); log_error ( "en/de-crytion failed: %s\n", gpg_strerror (rc)); goto leave; } leave: gcry_cipher_close (chd); } /* Decrypt a block of data and try several encodings of the key. CIPHERTEXT is the encrypted data of size LENGTH bytes; PLAINTEXT is a buffer of the same size to receive the decryption result. SALT, SALTLEN, ITER and PW are the information required for decryption and CIPHER_ALGO is the algorithm id to use. CHECK_FNC is a function called with the plaintext and used to check whether the decryption succeeded; i.e. that a correct passphrase has been given. That function shall return true if the decryption has likely succeeded. */ static void decrypt_block (const void *ciphertext, unsigned char *plaintext, size_t length, char *salt, size_t saltlen, int iter, const char *pw, int cipher_algo, int (*check_fnc) (const void *, size_t)) { static const char * const charsets[] = { "", /* No conversion - use the UTF-8 passphrase direct. */ "ISO-8859-1", "ISO-8859-15", "ISO-8859-2", "ISO-8859-3", "ISO-8859-4", "ISO-8859-5", "ISO-8859-6", "ISO-8859-7", "ISO-8859-8", "ISO-8859-9", "KOI8-R", "IBM437", "IBM850", "EUC-JP", "BIG5", NULL }; int charsetidx = 0; char *convertedpw = NULL; /* Malloced and converted password or NULL. */ size_t convertedpwsize = 0; /* Allocated length. */ for (charsetidx=0; charsets[charsetidx]; charsetidx++) { if (*charsets[charsetidx]) { jnlib_iconv_t cd; const char *inptr; char *outptr; size_t inbytes, outbytes; if (!convertedpw) { /* We assume one byte encodings. Thus we can allocate the buffer of the same size as the original passphrase; the result will actually be shorter then. */ convertedpwsize = strlen (pw) + 1; convertedpw = gcry_malloc_secure (convertedpwsize); if (!convertedpw) { log_info ("out of secure memory while" " converting passphrase\n"); break; /* Give up. */ } } cd = jnlib_iconv_open (charsets[charsetidx], "utf-8"); if (cd == (jnlib_iconv_t)(-1)) continue; inptr = pw; inbytes = strlen (pw); outptr = convertedpw; outbytes = convertedpwsize - 1; if ( jnlib_iconv (cd, (const char **)&inptr, &inbytes, &outptr, &outbytes) == (size_t)-1) { jnlib_iconv_close (cd); continue; } *outptr = 0; jnlib_iconv_close (cd); log_info ("decryption failed; trying charset `%s'\n", charsets[charsetidx]); } memcpy (plaintext, ciphertext, length); crypt_block (plaintext, length, salt, saltlen, iter, convertedpw? convertedpw:pw, cipher_algo, 0); if (check_fnc (plaintext, length)) break; /* Decryption succeeded. */ } gcry_free (convertedpw); } /* Return true if the decryption of an bag_encrypted_data object has likely succeeded. */ static int bag_decrypted_data_p (const void *plaintext, size_t length) { struct tag_info ti; const unsigned char *p = plaintext; size_t n = length; /* { */ /* # warning debug code is enabled */ /* FILE *fp = fopen ("tmp-rc2-plain.der", "wb"); */ /* if (!fp || fwrite (p, n, 1, fp) != 1) */ /* exit (2); */ /* fclose (fp); */ /* } */ if (parse_tag (&p, &n, &ti)) return 0; if (ti.class || ti.tag != TAG_SEQUENCE) return 0; if (parse_tag (&p, &n, &ti)) return 0; return 1; } /* Note: If R_RESULT is passed as NULL, a key object as already be processed and thus we need to skip it here. */ static int parse_bag_encrypted_data (const unsigned char *buffer, size_t length, int startoffset, size_t *r_consumed, const char *pw, void (*certcb)(void*, const unsigned char*, size_t), void *certcbarg, gcry_mpi_t **r_result) { struct tag_info ti; const unsigned char *p = buffer; const unsigned char *p_start = buffer; size_t n = length; const char *where; char salt[20]; size_t saltlen; unsigned int iter; unsigned char *plain = NULL; int bad_pass = 0; unsigned char *cram_buffer = NULL; size_t consumed = 0; /* Number of bytes consumed from the orginal buffer. */ int is_3des = 0; gcry_mpi_t *result = NULL; int result_count; if (r_result) *r_result = NULL; where = "start"; if (parse_tag (&p, &n, &ti)) goto bailout; if (ti.class != ASNCONTEXT || ti.tag) goto bailout; if (parse_tag (&p, &n, &ti)) goto bailout; if (ti.tag != TAG_SEQUENCE) goto bailout; where = "bag.encryptedData.version"; if (parse_tag (&p, &n, &ti)) goto bailout; if (ti.tag != TAG_INTEGER || ti.length != 1 || *p != 0) goto bailout; p++; n--; if (parse_tag (&p, &n, &ti)) goto bailout; if (ti.tag != TAG_SEQUENCE) goto bailout; where = "bag.encryptedData.data"; if (parse_tag (&p, &n, &ti)) goto bailout; if (ti.tag != TAG_OBJECT_ID || ti.length != DIM(oid_data) || memcmp (p, oid_data, DIM(oid_data))) goto bailout; p += DIM(oid_data); n -= DIM(oid_data); where = "bag.encryptedData.keyinfo"; if (parse_tag (&p, &n, &ti)) goto bailout; if (ti.class || ti.tag != TAG_SEQUENCE) goto bailout; if (parse_tag (&p, &n, &ti)) goto bailout; if (!ti.class && ti.tag == TAG_OBJECT_ID && ti.length == DIM(oid_pbeWithSHAAnd40BitRC2_CBC) && !memcmp (p, oid_pbeWithSHAAnd40BitRC2_CBC, DIM(oid_pbeWithSHAAnd40BitRC2_CBC))) { p += DIM(oid_pbeWithSHAAnd40BitRC2_CBC); n -= DIM(oid_pbeWithSHAAnd40BitRC2_CBC); } else if (!ti.class && ti.tag == TAG_OBJECT_ID && ti.length == DIM(oid_pbeWithSHAAnd3_KeyTripleDES_CBC) && !memcmp (p, oid_pbeWithSHAAnd3_KeyTripleDES_CBC, DIM(oid_pbeWithSHAAnd3_KeyTripleDES_CBC))) { p += DIM(oid_pbeWithSHAAnd3_KeyTripleDES_CBC); n -= DIM(oid_pbeWithSHAAnd3_KeyTripleDES_CBC); is_3des = 1; } else goto bailout; where = "rc2or3des-params"; if (parse_tag (&p, &n, &ti)) goto bailout; if (ti.class || ti.tag != TAG_SEQUENCE) goto bailout; if (parse_tag (&p, &n, &ti)) goto bailout; if (ti.class || ti.tag != TAG_OCTET_STRING || ti.length < 8 || ti.length > 20 ) goto bailout; saltlen = ti.length; memcpy (salt, p, saltlen); p += saltlen; n -= saltlen; if (parse_tag (&p, &n, &ti)) goto bailout; if (ti.class || ti.tag != TAG_INTEGER || !ti.length ) goto bailout; for (iter=0; ti.length; ti.length--) { iter <<= 8; iter |= (*p++) & 0xff; n--; } where = "rc2or3des-ciphertext"; if (parse_tag (&p, &n, &ti)) goto bailout; consumed = p - p_start; if (ti.class == ASNCONTEXT && ti.tag == 0 && ti.is_constructed && ti.ndef) { /* Mozilla exported certs now come with single byte chunks of octect strings. (Mozilla Firefox 1.0.4). Arghh. */ where = "cram-rc2or3des-ciphertext"; cram_buffer = cram_octet_string ( p, &n, &consumed); if (!cram_buffer) goto bailout; p = p_start = cram_buffer; if (r_consumed) *r_consumed = consumed; r_consumed = NULL; /* Ugly hack to not update that value any further. */ ti.length = n; } else if (ti.class == ASNCONTEXT && ti.tag == 0 && ti.length ) ; else goto bailout; log_info ("%lu bytes of %s encrypted text\n",ti.length,is_3des?"3DES":"RC2"); plain = gcry_malloc_secure (ti.length); if (!plain) { log_error ("error allocating decryption buffer\n"); goto bailout; } decrypt_block (p, plain, ti.length, salt, saltlen, iter, pw, is_3des? GCRY_CIPHER_3DES : GCRY_CIPHER_RFC2268_40, bag_decrypted_data_p); n = ti.length; startoffset = 0; p_start = p = plain; where = "outer.outer.seq"; if (parse_tag (&p, &n, &ti)) { bad_pass = 1; goto bailout; } if (ti.class || ti.tag != TAG_SEQUENCE) { bad_pass = 1; goto bailout; } if (parse_tag (&p, &n, &ti)) { bad_pass = 1; goto bailout; } /* Loop over all certificates inside the bag. */ while (n) { int iscrlbag = 0; int iskeybag = 0; where = "certbag.nextcert"; if (ti.class || ti.tag != TAG_SEQUENCE) goto bailout; where = "certbag.objectidentifier"; if (parse_tag (&p, &n, &ti)) goto bailout; if (ti.class || ti.tag != TAG_OBJECT_ID) goto bailout; if ( ti.length == DIM(oid_pkcs_12_CertBag) && !memcmp (p, oid_pkcs_12_CertBag, DIM(oid_pkcs_12_CertBag))) { p += DIM(oid_pkcs_12_CertBag); n -= DIM(oid_pkcs_12_CertBag); } else if ( ti.length == DIM(oid_pkcs_12_CrlBag) && !memcmp (p, oid_pkcs_12_CrlBag, DIM(oid_pkcs_12_CrlBag))) { p += DIM(oid_pkcs_12_CrlBag); n -= DIM(oid_pkcs_12_CrlBag); iscrlbag = 1; } else if ( ti.length == DIM(oid_pkcs_12_keyBag) && !memcmp (p, oid_pkcs_12_keyBag, DIM(oid_pkcs_12_keyBag))) { /* The TrustedMIME plugin for MS Outlook started to create files with just one outer 3DES encrypted container and inside the certificates as well as the key. */ p += DIM(oid_pkcs_12_keyBag); n -= DIM(oid_pkcs_12_keyBag); iskeybag = 1; } else goto bailout; where = "certbag.before.certheader"; if (parse_tag (&p, &n, &ti)) goto bailout; if (ti.class != ASNCONTEXT || ti.tag) goto bailout; if (iscrlbag) { log_info ("skipping unsupported crlBag\n"); p += ti.length; n -= ti.length; } else if (iskeybag && (result || !r_result)) { log_info ("one keyBag already processed; skipping this one\n"); p += ti.length; n -= ti.length; } else if (iskeybag) { int len; log_info ("processing simple keyBag\n"); /* Fixme: This code is duplicated from parse_bag_data. */ if (parse_tag (&p, &n, &ti) || ti.class || ti.tag != TAG_SEQUENCE) goto bailout; if (parse_tag (&p, &n, &ti) || ti.class || ti.tag != TAG_INTEGER || ti.length != 1 || *p) goto bailout; p++; n--; if (parse_tag (&p, &n, &ti) || ti.class || ti.tag != TAG_SEQUENCE) goto bailout; len = ti.length; if (parse_tag (&p, &n, &ti)) goto bailout; if (len < ti.nhdr) goto bailout; len -= ti.nhdr; if (ti.class || ti.tag != TAG_OBJECT_ID || ti.length != DIM(oid_rsaEncryption) || memcmp (p, oid_rsaEncryption, DIM(oid_rsaEncryption))) goto bailout; p += DIM (oid_rsaEncryption); n -= DIM (oid_rsaEncryption); if (len < ti.length) goto bailout; len -= ti.length; if (n < len) goto bailout; p += len; n -= len; if ( parse_tag (&p, &n, &ti) || ti.class || ti.tag != TAG_OCTET_STRING) goto bailout; if ( parse_tag (&p, &n, &ti) || ti.class || ti.tag != TAG_SEQUENCE) goto bailout; len = ti.length; result = gcry_calloc (10, sizeof *result); if (!result) { log_error ( "error allocating result array\n"); goto bailout; } result_count = 0; where = "reading.keybag.key-parameters"; for (result_count = 0; len && result_count < 9;) { if ( parse_tag (&p, &n, &ti) || ti.class || ti.tag != TAG_INTEGER) goto bailout; if (len < ti.nhdr) goto bailout; len -= ti.nhdr; if (len < ti.length) goto bailout; len -= ti.length; if (!result_count && ti.length == 1 && !*p) ; /* ignore the very first one if it is a 0 */ else { int rc; rc = gcry_mpi_scan (result+result_count, GCRYMPI_FMT_USG, p, ti.length, NULL); if (rc) { log_error ("error parsing key parameter: %s\n", gpg_strerror (rc)); goto bailout; } result_count++; } p += ti.length; n -= ti.length; } if (len) goto bailout; } else { log_info ("processing certBag\n"); if (parse_tag (&p, &n, &ti)) goto bailout; if (ti.class || ti.tag != TAG_SEQUENCE) goto bailout; if (parse_tag (&p, &n, &ti)) goto bailout; if (ti.class || ti.tag != TAG_OBJECT_ID || ti.length != DIM(oid_x509Certificate_for_pkcs_12) || memcmp (p, oid_x509Certificate_for_pkcs_12, DIM(oid_x509Certificate_for_pkcs_12))) goto bailout; p += DIM(oid_x509Certificate_for_pkcs_12); n -= DIM(oid_x509Certificate_for_pkcs_12); where = "certbag.before.octetstring"; if (parse_tag (&p, &n, &ti)) goto bailout; if (ti.class != ASNCONTEXT || ti.tag) goto bailout; if (parse_tag (&p, &n, &ti)) goto bailout; if (ti.class || ti.tag != TAG_OCTET_STRING || ti.ndef) goto bailout; /* Return the certificate. */ if (certcb) certcb (certcbarg, p, ti.length); p += ti.length; n -= ti.length; } /* Ugly hack to cope with the padding: Forget about the rest if that is less or equal to the cipher's block length. We can reasonable assume that all valid data will be longer than just one block. */ if (n <= 8) n = 0; /* Skip the optional SET with the pkcs12 cert attributes. */ if (n) { where = "bag.attributes"; if (parse_tag (&p, &n, &ti)) goto bailout; if (!ti.class && ti.tag == TAG_SEQUENCE) ; /* No attributes. */ else if (!ti.class && ti.tag == TAG_SET && !ti.ndef) { /* The optional SET. */ p += ti.length; n -= ti.length; if (n <= 8) n = 0; if (n && parse_tag (&p, &n, &ti)) goto bailout; } else goto bailout; } } if (r_consumed) *r_consumed = consumed; gcry_free (plain); gcry_free (cram_buffer); if (r_result) *r_result = result; return 0; bailout: if (result) { int i; for (i=0; result[i]; i++) gcry_mpi_release (result[i]); gcry_free (result); } if (r_consumed) *r_consumed = consumed; gcry_free (plain); gcry_free (cram_buffer); log_error ("encryptedData error at \"%s\", offset %u\n", where, (unsigned int)((p - p_start)+startoffset)); if (bad_pass) { /* Note, that the following string might be used by other programs to check for a bad passphrase; it should therefore not be translated or changed. */ log_error ("possibly bad passphrase given\n"); } return -1; } /* Return true if the decryption of a bag_data object has likely succeeded. */ static int bag_data_p (const void *plaintext, size_t length) { struct tag_info ti; const unsigned char *p = plaintext; size_t n = length; /* { */ /* # warning debug code is enabled */ /* FILE *fp = fopen ("tmp-3des-plain-key.der", "wb"); */ /* if (!fp || fwrite (p, n, 1, fp) != 1) */ /* exit (2); */ /* fclose (fp); */ /* } */ if (parse_tag (&p, &n, &ti) || ti.class || ti.tag != TAG_SEQUENCE) return 0; if (parse_tag (&p, &n, &ti) || ti.class || ti.tag != TAG_INTEGER || ti.length != 1 || *p) return 0; return 1; } static gcry_mpi_t * parse_bag_data (const unsigned char *buffer, size_t length, int startoffset, size_t *r_consumed, const char *pw) { int rc; struct tag_info ti; const unsigned char *p = buffer; const unsigned char *p_start = buffer; size_t n = length; const char *where; char salt[20]; size_t saltlen; unsigned int iter; int len; unsigned char *plain = NULL; gcry_mpi_t *result = NULL; int result_count, i; unsigned char *cram_buffer = NULL; size_t consumed = 0; /* Number of bytes consumed from the orginal buffer. */ where = "start"; if (parse_tag (&p, &n, &ti)) goto bailout; if (ti.class != ASNCONTEXT || ti.tag) goto bailout; if (parse_tag (&p, &n, &ti)) goto bailout; if (ti.class || ti.tag != TAG_OCTET_STRING) goto bailout; consumed = p - p_start; if (ti.is_constructed && ti.ndef) { /* Mozilla exported certs now come with single byte chunks of octect strings. (Mozilla Firefox 1.0.4). Arghh. */ where = "cram-data.outersegs"; cram_buffer = cram_octet_string ( p, &n, &consumed); if (!cram_buffer) goto bailout; p = p_start = cram_buffer; if (r_consumed) *r_consumed = consumed; r_consumed = NULL; /* Ugly hack to not update that value any further. */ } where = "data.outerseqs"; if (parse_tag (&p, &n, &ti)) goto bailout; if (ti.class || ti.tag != TAG_SEQUENCE) goto bailout; if (parse_tag (&p, &n, &ti)) goto bailout; if (ti.class || ti.tag != TAG_SEQUENCE) goto bailout; where = "data.objectidentifier"; if (parse_tag (&p, &n, &ti)) goto bailout; if (ti.class || ti.tag != TAG_OBJECT_ID || ti.length != DIM(oid_pkcs_12_pkcs_8ShroudedKeyBag) || memcmp (p, oid_pkcs_12_pkcs_8ShroudedKeyBag, DIM(oid_pkcs_12_pkcs_8ShroudedKeyBag))) goto bailout; p += DIM(oid_pkcs_12_pkcs_8ShroudedKeyBag); n -= DIM(oid_pkcs_12_pkcs_8ShroudedKeyBag); where = "shrouded,outerseqs"; if (parse_tag (&p, &n, &ti)) goto bailout; if (ti.class != ASNCONTEXT || ti.tag) goto bailout; if (parse_tag (&p, &n, &ti)) goto bailout; if (ti.class || ti.tag != TAG_SEQUENCE) goto bailout; if (parse_tag (&p, &n, &ti)) goto bailout; if (ti.class || ti.tag != TAG_SEQUENCE) goto bailout; if (parse_tag (&p, &n, &ti)) goto bailout; if (ti.class || ti.tag != TAG_OBJECT_ID || ti.length != DIM(oid_pbeWithSHAAnd3_KeyTripleDES_CBC) || memcmp (p, oid_pbeWithSHAAnd3_KeyTripleDES_CBC, DIM(oid_pbeWithSHAAnd3_KeyTripleDES_CBC))) goto bailout; p += DIM(oid_pbeWithSHAAnd3_KeyTripleDES_CBC); n -= DIM(oid_pbeWithSHAAnd3_KeyTripleDES_CBC); where = "3des-params"; if (parse_tag (&p, &n, &ti)) goto bailout; if (ti.class || ti.tag != TAG_SEQUENCE) goto bailout; if (parse_tag (&p, &n, &ti)) goto bailout; if (ti.class || ti.tag != TAG_OCTET_STRING || ti.length < 8 || ti.length > 20) goto bailout; saltlen = ti.length; memcpy (salt, p, saltlen); p += saltlen; n -= saltlen; if (parse_tag (&p, &n, &ti)) goto bailout; if (ti.class || ti.tag != TAG_INTEGER || !ti.length ) goto bailout; for (iter=0; ti.length; ti.length--) { iter <<= 8; iter |= (*p++) & 0xff; n--; } where = "3des-ciphertext"; if (parse_tag (&p, &n, &ti)) goto bailout; if (ti.class || ti.tag != TAG_OCTET_STRING || !ti.length ) goto bailout; log_info ("%lu bytes of 3DES encrypted text\n", ti.length); plain = gcry_malloc_secure (ti.length); if (!plain) { log_error ("error allocating decryption buffer\n"); goto bailout; } consumed += p - p_start + ti.length; decrypt_block (p, plain, ti.length, salt, saltlen, iter, pw, GCRY_CIPHER_3DES, bag_data_p); n = ti.length; startoffset = 0; p_start = p = plain; where = "decrypted-text"; if (parse_tag (&p, &n, &ti) || ti.class || ti.tag != TAG_SEQUENCE) goto bailout; if (parse_tag (&p, &n, &ti) || ti.class || ti.tag != TAG_INTEGER || ti.length != 1 || *p) goto bailout; p++; n--; if (parse_tag (&p, &n, &ti) || ti.class || ti.tag != TAG_SEQUENCE) goto bailout; len = ti.length; if (parse_tag (&p, &n, &ti)) goto bailout; if (len < ti.nhdr) goto bailout; len -= ti.nhdr; if (ti.class || ti.tag != TAG_OBJECT_ID || ti.length != DIM(oid_rsaEncryption) || memcmp (p, oid_rsaEncryption, DIM(oid_rsaEncryption))) goto bailout; p += DIM (oid_rsaEncryption); n -= DIM (oid_rsaEncryption); if (len < ti.length) goto bailout; len -= ti.length; if (n < len) goto bailout; p += len; n -= len; if (parse_tag (&p, &n, &ti) || ti.class || ti.tag != TAG_OCTET_STRING) goto bailout; if (parse_tag (&p, &n, &ti) || ti.class || ti.tag != TAG_SEQUENCE) goto bailout; len = ti.length; result = gcry_calloc (10, sizeof *result); if (!result) { log_error ( "error allocating result array\n"); goto bailout; } result_count = 0; where = "reading.key-parameters"; for (result_count=0; len && result_count < 9;) { if (parse_tag (&p, &n, &ti) || ti.class || ti.tag != TAG_INTEGER) goto bailout; if (len < ti.nhdr) goto bailout; len -= ti.nhdr; if (len < ti.length) goto bailout; len -= ti.length; if (!result_count && ti.length == 1 && !*p) ; /* ignore the very first one if it is a 0 */ else { rc = gcry_mpi_scan (result+result_count, GCRYMPI_FMT_USG, p, ti.length, NULL); if (rc) { log_error ("error parsing key parameter: %s\n", gpg_strerror (rc)); goto bailout; } result_count++; } p += ti.length; n -= ti.length; } if (len) goto bailout; gcry_free (cram_buffer); if (r_consumed) *r_consumed = consumed; return result; bailout: gcry_free (plain); if (result) { for (i=0; result[i]; i++) gcry_mpi_release (result[i]); gcry_free (result); } gcry_free (cram_buffer); log_error ( "data error at \"%s\", offset %u\n", where, (unsigned int)((p - buffer) + startoffset)); if (r_consumed) *r_consumed = consumed; return NULL; } /* Parse a PKCS12 object and return an array of MPI representing the secret key parameters. This is a very limited implementation in that it is only able to look for 3DES encoded encryptedData and tries to extract the first private key object it finds. In case of an error NULL is returned. CERTCB and CERRTCBARG are used to pass X.509 certificates back to the caller. */ gcry_mpi_t * p12_parse (const unsigned char *buffer, size_t length, const char *pw, void (*certcb)(void*, const unsigned char*, size_t), void *certcbarg) { struct tag_info ti; const unsigned char *p = buffer; const unsigned char *p_start = buffer; size_t n = length; const char *where; int bagseqlength, len; int bagseqndef, lenndef; gcry_mpi_t *result = NULL; unsigned char *cram_buffer = NULL; where = "pfx"; if (parse_tag (&p, &n, &ti)) goto bailout; if (ti.tag != TAG_SEQUENCE) goto bailout; where = "pfxVersion"; if (parse_tag (&p, &n, &ti)) goto bailout; if (ti.tag != TAG_INTEGER || ti.length != 1 || *p != 3) goto bailout; p++; n--; where = "authSave"; if (parse_tag (&p, &n, &ti)) goto bailout; if (ti.tag != TAG_SEQUENCE) goto bailout; if (parse_tag (&p, &n, &ti)) goto bailout; if (ti.tag != TAG_OBJECT_ID || ti.length != DIM(oid_data) || memcmp (p, oid_data, DIM(oid_data))) goto bailout; p += DIM(oid_data); n -= DIM(oid_data); if (parse_tag (&p, &n, &ti)) goto bailout; if (ti.class != ASNCONTEXT || ti.tag) goto bailout; if (parse_tag (&p, &n, &ti)) goto bailout; if (ti.class != UNIVERSAL || ti.tag != TAG_OCTET_STRING) goto bailout; if (ti.is_constructed && ti.ndef) { /* Mozilla exported certs now come with single byte chunks of octect strings. (Mozilla Firefox 1.0.4). Arghh. */ where = "cram-bags"; cram_buffer = cram_octet_string ( p, &n, NULL); if (!cram_buffer) goto bailout; p = p_start = cram_buffer; } where = "bags"; if (parse_tag (&p, &n, &ti)) goto bailout; if (ti.class != UNIVERSAL || ti.tag != TAG_SEQUENCE) goto bailout; bagseqndef = ti.ndef; bagseqlength = ti.length; while (bagseqlength || bagseqndef) { /* log_debug ( "at offset %u\n", (p - p_start)); */ where = "bag-sequence"; if (parse_tag (&p, &n, &ti)) goto bailout; if (bagseqndef && ti.class == UNIVERSAL && !ti.tag && !ti.is_constructed) break; /* Ready */ if (ti.class != UNIVERSAL || ti.tag != TAG_SEQUENCE) goto bailout; if (!bagseqndef) { if (bagseqlength < ti.nhdr) goto bailout; bagseqlength -= ti.nhdr; if (bagseqlength < ti.length) goto bailout; bagseqlength -= ti.length; } lenndef = ti.ndef; len = ti.length; if (parse_tag (&p, &n, &ti)) goto bailout; if (lenndef) len = ti.nhdr; else len -= ti.nhdr; if (ti.tag == TAG_OBJECT_ID && ti.length == DIM(oid_encryptedData) && !memcmp (p, oid_encryptedData, DIM(oid_encryptedData))) { size_t consumed = 0; p += DIM(oid_encryptedData); n -= DIM(oid_encryptedData); if (!lenndef) len -= DIM(oid_encryptedData); where = "bag.encryptedData"; if (parse_bag_encrypted_data (p, n, (p - p_start), &consumed, pw, certcb, certcbarg, result? NULL : &result)) goto bailout; if (lenndef) len += consumed; } else if (ti.tag == TAG_OBJECT_ID && ti.length == DIM(oid_data) && !memcmp (p, oid_data, DIM(oid_data))) { if (result) { log_info ("already got an key object, skipping this one\n"); p += ti.length; n -= ti.length; } else { size_t consumed = 0; p += DIM(oid_data); n -= DIM(oid_data); if (!lenndef) len -= DIM(oid_data); result = parse_bag_data (p, n, (p - p_start), &consumed, pw); if (!result) goto bailout; if (lenndef) len += consumed; } } else { log_info ("unknown bag type - skipped\n"); p += ti.length; n -= ti.length; } if (len < 0 || len > n) goto bailout; p += len; n -= len; if (lenndef) { /* Need to skip the Null Tag. */ if (parse_tag (&p, &n, &ti)) goto bailout; if (!(ti.class == UNIVERSAL && !ti.tag && !ti.is_constructed)) goto bailout; } } gcry_free (cram_buffer); return result; bailout: log_error ("error at \"%s\", offset %u\n", where, (unsigned int)(p - p_start)); if (result) { int i; for (i=0; result[i]; i++) gcry_mpi_release (result[i]); gcry_free (result); } gcry_free (cram_buffer); return NULL; } static size_t compute_tag_length (size_t n) { int needed = 0; if (n < 128) needed += 2; /* tag and one length byte */ else if (n < 256) needed += 3; /* tag, number of length bytes, 1 length byte */ else if (n < 65536) needed += 4; /* tag, number of length bytes, 2 length bytes */ else { log_error ("object too larger to encode\n"); return 0; } return needed; } static unsigned char * store_tag_length (unsigned char *p, int tag, size_t n) { if (tag == TAG_SEQUENCE) tag |= 0x20; /* constructed */ *p++ = tag; if (n < 128) *p++ = n; else if (n < 256) { *p++ = 0x81; *p++ = n; } else if (n < 65536) { *p++ = 0x82; *p++ = n >> 8; *p++ = n; } return p; } /* Create the final PKCS-12 object from the sequences contained in SEQLIST. PW is the password. That array is terminated with an NULL object. */ static unsigned char * create_final (struct buffer_s *sequences, const char *pw, size_t *r_length) { int i; size_t needed = 0; size_t len[8], n; unsigned char *macstart; size_t maclen; unsigned char *result, *p; size_t resultlen; char salt[8]; unsigned char keybuf[20]; gcry_md_hd_t md; int rc; int with_mac = 1; /* 9 steps to create the pkcs#12 Krampf. */ /* 8. The MAC. */ /* We add this at step 0. */ /* 7. All the buffers. */ for (i=0; sequences[i].buffer; i++) needed += sequences[i].length; /* 6. This goes into a sequences. */ len[6] = needed; n = compute_tag_length (needed); needed += n; /* 5. Encapsulate all in an octet string. */ len[5] = needed; n = compute_tag_length (needed); needed += n; /* 4. And tag it with [0]. */ len[4] = needed; n = compute_tag_length (needed); needed += n; /* 3. Prepend an data OID. */ needed += 2 + DIM (oid_data); /* 2. Put all into a sequences. */ len[2] = needed; n = compute_tag_length (needed); needed += n; /* 1. Prepend the version integer 3. */ needed += 3; /* 0. And the final outer sequence. */ if (with_mac) needed += DIM (data_mactemplate); len[0] = needed; n = compute_tag_length (needed); needed += n; /* Allocate a buffer. */ result = gcry_malloc (needed); if (!result) { log_error ("error allocating buffer\n"); return NULL; } p = result; /* 0. Store the very outer sequence. */ p = store_tag_length (p, TAG_SEQUENCE, len[0]); /* 1. Store the version integer 3. */ *p++ = TAG_INTEGER; *p++ = 1; *p++ = 3; /* 2. Store another sequence. */ p = store_tag_length (p, TAG_SEQUENCE, len[2]); /* 3. Store the data OID. */ p = store_tag_length (p, TAG_OBJECT_ID, DIM (oid_data)); memcpy (p, oid_data, DIM (oid_data)); p += DIM (oid_data); /* 4. Next comes a context tag. */ p = store_tag_length (p, 0xa0, len[4]); /* 5. And an octet string. */ p = store_tag_length (p, TAG_OCTET_STRING, len[5]); /* 6. And the inner sequence. */ macstart = p; p = store_tag_length (p, TAG_SEQUENCE, len[6]); /* 7. Append all the buffers. */ for (i=0; sequences[i].buffer; i++) { memcpy (p, sequences[i].buffer, sequences[i].length); p += sequences[i].length; } if (with_mac) { /* Intermezzo to compute the MAC. */ maclen = p - macstart; gcry_randomize (salt, 8, GCRY_STRONG_RANDOM); if (string_to_key (3, salt, 8, 2048, pw, 20, keybuf)) { gcry_free (result); return NULL; } rc = gcry_md_open (&md, GCRY_MD_SHA1, GCRY_MD_FLAG_HMAC); if (rc) { log_error ("gcry_md_open failed: %s\n", gpg_strerror (rc)); gcry_free (result); return NULL; } rc = gcry_md_setkey (md, keybuf, 20); if (rc) { log_error ("gcry_md_setkey failed: %s\n", gpg_strerror (rc)); gcry_md_close (md); gcry_free (result); return NULL; } gcry_md_write (md, macstart, maclen); /* 8. Append the MAC template and fix it up. */ memcpy (p, data_mactemplate, DIM (data_mactemplate)); memcpy (p + DATA_MACTEMPLATE_SALT_OFF, salt, 8); memcpy (p + DATA_MACTEMPLATE_MAC_OFF, gcry_md_read (md, 0), 20); p += DIM (data_mactemplate); gcry_md_close (md); } /* Ready. */ resultlen = p - result; if (needed != resultlen) log_debug ("length mismatch: %lu, %lu\n", (unsigned long)needed, (unsigned long)resultlen); *r_length = resultlen; return result; } /* Build a DER encoded SEQUENCE with the key: SEQUENCE { INTEGER 0 SEQUENCE { OBJECT IDENTIFIER rsaEncryption (1 2 840 113549 1 1 1) NULL } OCTET STRING, encapsulates { SEQUENCE { INTEGER 0 INTEGER INTEGER INTEGER INTEGER INTEGER INTEGER INTEGER INTEGER } } } */ static unsigned char * build_key_sequence (gcry_mpi_t *kparms, size_t *r_length) { int rc, i; size_t needed, n; unsigned char *plain, *p; size_t plainlen; size_t outseqlen, oidseqlen, octstrlen, inseqlen; needed = 3; /* The version(?) integer of value 0. */ for (i=0; kparms[i]; i++) { n = 0; rc = gcry_mpi_print (GCRYMPI_FMT_STD, NULL, 0, &n, kparms[i]); if (rc) { log_error ("error formatting parameter: %s\n", gpg_strerror (rc)); return NULL; } needed += n; n = compute_tag_length (n); if (!n) return NULL; needed += n; } if (i != 8) { log_error ("invalid parameters for p12_build\n"); return NULL; } /* Now this all goes into a sequence. */ inseqlen = needed; n = compute_tag_length (needed); if (!n) return NULL; needed += n; /* Encapsulate all into an octet string. */ octstrlen = needed; n = compute_tag_length (needed); if (!n) return NULL; needed += n; /* Prepend the object identifier sequence. */ oidseqlen = 2 + DIM (oid_rsaEncryption) + 2; needed += 2 + oidseqlen; /* The version number. */ needed += 3; /* And finally put the whole thing into a sequence. */ outseqlen = needed; n = compute_tag_length (needed); if (!n) return NULL; needed += n; /* allocate 8 extra bytes for padding */ plain = gcry_malloc_secure (needed+8); if (!plain) { log_error ("error allocating encryption buffer\n"); return NULL; } /* And now fill the plaintext buffer. */ p = plain; p = store_tag_length (p, TAG_SEQUENCE, outseqlen); /* Store version. */ *p++ = TAG_INTEGER; *p++ = 1; *p++ = 0; /* Store object identifier sequence. */ p = store_tag_length (p, TAG_SEQUENCE, oidseqlen); p = store_tag_length (p, TAG_OBJECT_ID, DIM (oid_rsaEncryption)); memcpy (p, oid_rsaEncryption, DIM (oid_rsaEncryption)); p += DIM (oid_rsaEncryption); *p++ = TAG_NULL; *p++ = 0; /* Start with the octet string. */ p = store_tag_length (p, TAG_OCTET_STRING, octstrlen); p = store_tag_length (p, TAG_SEQUENCE, inseqlen); /* Store the key parameters. */ *p++ = TAG_INTEGER; *p++ = 1; *p++ = 0; for (i=0; kparms[i]; i++) { n = 0; rc = gcry_mpi_print (GCRYMPI_FMT_STD, NULL, 0, &n, kparms[i]); if (rc) { log_error ("oops: error formatting parameter: %s\n", gpg_strerror (rc)); gcry_free (plain); return NULL; } p = store_tag_length (p, TAG_INTEGER, n); n = plain + needed - p; rc = gcry_mpi_print (GCRYMPI_FMT_STD, p, n, &n, kparms[i]); if (rc) { log_error ("oops: error storing parameter: %s\n", gpg_strerror (rc)); gcry_free (plain); return NULL; } p += n; } plainlen = p - plain; assert (needed == plainlen); /* Append some pad characters; we already allocated extra space. */ n = 8 - plainlen % 8; for (i=0; i < n; i++, plainlen++) *p++ = n; *r_length = plainlen; return plain; } static unsigned char * build_key_bag (unsigned char *buffer, size_t buflen, char *salt, const unsigned char *sha1hash, const char *keyidstr, size_t *r_length) { size_t len[11], needed; unsigned char *p, *keybag; size_t keybaglen; /* Walk 11 steps down to collect the info: */ /* 10. The data goes into an octet string. */ needed = compute_tag_length (buflen); needed += buflen; /* 9. Prepend the algorithm identifier. */ needed += DIM (data_3desiter2048); /* 8. Put a sequence around. */ len[8] = needed; needed += compute_tag_length (needed); /* 7. Prepend a [0] tag. */ len[7] = needed; needed += compute_tag_length (needed); /* 6b. The attributes which are appended at the end. */ if (sha1hash) needed += DIM (data_attrtemplate) + 20; /* 6. Prepend the shroudedKeyBag OID. */ needed += 2 + DIM (oid_pkcs_12_pkcs_8ShroudedKeyBag); /* 5+4. Put all into two sequences. */ len[5] = needed; needed += compute_tag_length ( needed); len[4] = needed; needed += compute_tag_length (needed); /* 3. This all goes into an octet string. */ len[3] = needed; needed += compute_tag_length (needed); /* 2. Prepend another [0] tag. */ len[2] = needed; needed += compute_tag_length (needed); /* 1. Prepend the data OID. */ needed += 2 + DIM (oid_data); /* 0. Prepend another sequence. */ len[0] = needed; needed += compute_tag_length (needed); /* Now that we have all length information, allocate a buffer. */ p = keybag = gcry_malloc (needed); if (!keybag) { log_error ("error allocating buffer\n"); return NULL; } /* Walk 11 steps up to store the data. */ /* 0. Store the first sequence. */ p = store_tag_length (p, TAG_SEQUENCE, len[0]); /* 1. Store the data OID. */ p = store_tag_length (p, TAG_OBJECT_ID, DIM (oid_data)); memcpy (p, oid_data, DIM (oid_data)); p += DIM (oid_data); /* 2. Store a [0] tag. */ p = store_tag_length (p, 0xa0, len[2]); /* 3. And an octet string. */ p = store_tag_length (p, TAG_OCTET_STRING, len[3]); /* 4+5. Two sequences. */ p = store_tag_length (p, TAG_SEQUENCE, len[4]); p = store_tag_length (p, TAG_SEQUENCE, len[5]); /* 6. Store the shroudedKeyBag OID. */ p = store_tag_length (p, TAG_OBJECT_ID, DIM (oid_pkcs_12_pkcs_8ShroudedKeyBag)); memcpy (p, oid_pkcs_12_pkcs_8ShroudedKeyBag, DIM (oid_pkcs_12_pkcs_8ShroudedKeyBag)); p += DIM (oid_pkcs_12_pkcs_8ShroudedKeyBag); /* 7. Store a [0] tag. */ p = store_tag_length (p, 0xa0, len[7]); /* 8. Store a sequence. */ p = store_tag_length (p, TAG_SEQUENCE, len[8]); /* 9. Now for the pre-encoded algorithm identifier and the salt. */ memcpy (p, data_3desiter2048, DIM (data_3desiter2048)); memcpy (p + DATA_3DESITER2048_SALT_OFF, salt, 8); p += DIM (data_3desiter2048); /* 10. And the octet string with the encrypted data. */ p = store_tag_length (p, TAG_OCTET_STRING, buflen); memcpy (p, buffer, buflen); p += buflen; /* Append the attributes whose length we calculated at step 2b. */ if (sha1hash) { int i; memcpy (p, data_attrtemplate, DIM (data_attrtemplate)); for (i=0; i < 8; i++) p[DATA_ATTRTEMPLATE_KEYID_OFF+2*i+1] = keyidstr[i]; p += DIM (data_attrtemplate); memcpy (p, sha1hash, 20); p += 20; } keybaglen = p - keybag; if (needed != keybaglen) log_debug ("length mismatch: %lu, %lu\n", (unsigned long)needed, (unsigned long)keybaglen); *r_length = keybaglen; return keybag; } static unsigned char * build_cert_bag (unsigned char *buffer, size_t buflen, char *salt, size_t *r_length) { size_t len[9], needed; unsigned char *p, *certbag; size_t certbaglen; /* Walk 9 steps down to collect the info: */ /* 8. The data goes into an octet string. */ needed = compute_tag_length (buflen); needed += buflen; /* 7. The algorithm identifier. */ needed += DIM (data_rc2iter2048); /* 6. The data OID. */ needed += 2 + DIM (oid_data); /* 5. A sequence. */ len[5] = needed; needed += compute_tag_length ( needed); /* 4. An integer. */ needed += 3; /* 3. A sequence. */ len[3] = needed; needed += compute_tag_length (needed); /* 2. A [0] tag. */ len[2] = needed; needed += compute_tag_length (needed); /* 1. The encryptedData OID. */ needed += 2 + DIM (oid_encryptedData); /* 0. The first sequence. */ len[0] = needed; needed += compute_tag_length (needed); /* Now that we have all length information, allocate a buffer. */ p = certbag = gcry_malloc (needed); if (!certbag) { log_error ("error allocating buffer\n"); return NULL; } /* Walk 9 steps up to store the data. */ /* 0. Store the first sequence. */ p = store_tag_length (p, TAG_SEQUENCE, len[0]); /* 1. Store the encryptedData OID. */ p = store_tag_length (p, TAG_OBJECT_ID, DIM (oid_encryptedData)); memcpy (p, oid_encryptedData, DIM (oid_encryptedData)); p += DIM (oid_encryptedData); /* 2. Store a [0] tag. */ p = store_tag_length (p, 0xa0, len[2]); /* 3. Store a sequence. */ p = store_tag_length (p, TAG_SEQUENCE, len[3]); /* 4. Store the integer 0. */ *p++ = TAG_INTEGER; *p++ = 1; *p++ = 0; /* 5. Store a sequence. */ p = store_tag_length (p, TAG_SEQUENCE, len[5]); /* 6. Store the data OID. */ p = store_tag_length (p, TAG_OBJECT_ID, DIM (oid_data)); memcpy (p, oid_data, DIM (oid_data)); p += DIM (oid_data); /* 7. Now for the pre-encoded algorithm identifier and the salt. */ memcpy (p, data_rc2iter2048, DIM (data_rc2iter2048)); memcpy (p + DATA_RC2ITER2048_SALT_OFF, salt, 8); p += DIM (data_rc2iter2048); /* 8. And finally the [0] tag with the encrypted data. */ p = store_tag_length (p, 0x80, buflen); memcpy (p, buffer, buflen); p += buflen; certbaglen = p - certbag; if (needed != certbaglen) log_debug ("length mismatch: %lu, %lu\n", (unsigned long)needed, (unsigned long)certbaglen); *r_length = certbaglen; return certbag; } static unsigned char * build_cert_sequence (unsigned char *buffer, size_t buflen, const unsigned char *sha1hash, const char *keyidstr, size_t *r_length) { size_t len[8], needed, n; unsigned char *p, *certseq; size_t certseqlen; int i; assert (strlen (keyidstr) == 8); /* Walk 8 steps down to collect the info: */ /* 7. The data goes into an octet string. */ needed = compute_tag_length (buflen); needed += buflen; /* 6. A [0] tag. */ len[6] = needed; needed += compute_tag_length (needed); /* 5. An OID. */ needed += 2 + DIM (oid_x509Certificate_for_pkcs_12); /* 4. A sequence. */ len[4] = needed; needed += compute_tag_length (needed); /* 3. A [0] tag. */ len[3] = needed; needed += compute_tag_length (needed); /* 2b. The attributes which are appended at the end. */ if (sha1hash) needed += DIM (data_attrtemplate) + 20; /* 2. An OID. */ needed += 2 + DIM (oid_pkcs_12_CertBag); /* 1. A sequence. */ len[1] = needed; needed += compute_tag_length (needed); /* 0. The first sequence. */ len[0] = needed; needed += compute_tag_length (needed); /* Now that we have all length information, allocate a buffer. */ p = certseq = gcry_malloc (needed + 8 /*(for padding)*/); if (!certseq) { log_error ("error allocating buffer\n"); return NULL; } /* Walk 8 steps up to store the data. */ /* 0. Store the first sequence. */ p = store_tag_length (p, TAG_SEQUENCE, len[0]); /* 1. Store the second sequence. */ p = store_tag_length (p, TAG_SEQUENCE, len[1]); /* 2. Store the pkcs12-cert-bag OID. */ p = store_tag_length (p, TAG_OBJECT_ID, DIM (oid_pkcs_12_CertBag)); memcpy (p, oid_pkcs_12_CertBag, DIM (oid_pkcs_12_CertBag)); p += DIM (oid_pkcs_12_CertBag); /* 3. Store a [0] tag. */ p = store_tag_length (p, 0xa0, len[3]); /* 4. Store a sequence. */ p = store_tag_length (p, TAG_SEQUENCE, len[4]); /* 5. Store the x509Certificate OID. */ p = store_tag_length (p, TAG_OBJECT_ID, DIM (oid_x509Certificate_for_pkcs_12)); memcpy (p, oid_x509Certificate_for_pkcs_12, DIM (oid_x509Certificate_for_pkcs_12)); p += DIM (oid_x509Certificate_for_pkcs_12); /* 6. Store a [0] tag. */ p = store_tag_length (p, 0xa0, len[6]); /* 7. And the octet string with the actual certificate. */ p = store_tag_length (p, TAG_OCTET_STRING, buflen); memcpy (p, buffer, buflen); p += buflen; /* Append the attributes whose length we calculated at step 2b. */ if (sha1hash) { memcpy (p, data_attrtemplate, DIM (data_attrtemplate)); for (i=0; i < 8; i++) p[DATA_ATTRTEMPLATE_KEYID_OFF+2*i+1] = keyidstr[i]; p += DIM (data_attrtemplate); memcpy (p, sha1hash, 20); p += 20; } certseqlen = p - certseq; if (needed != certseqlen) log_debug ("length mismatch: %lu, %lu\n", (unsigned long)needed, (unsigned long)certseqlen); /* Append some pad characters; we already allocated extra space. */ n = 8 - certseqlen % 8; for (i=0; i < n; i++, certseqlen++) *p++ = n; *r_length = certseqlen; return certseq; } /* Expect the RSA key parameters in KPARMS and a password in PW. Create a PKCS structure from it and return it as well as the length in R_LENGTH; return NULL in case of an error. If CHARSET is not NULL, re-encode PW to that character set. */ unsigned char * p12_build (gcry_mpi_t *kparms, unsigned char *cert, size_t certlen, const char *pw, const char *charset, size_t *r_length) { unsigned char *buffer = NULL; size_t n, buflen; char salt[8]; struct buffer_s seqlist[3]; int seqlistidx = 0; unsigned char sha1hash[20]; char keyidstr[8+1]; char *pwbuf = NULL; size_t pwbufsize = 0; n = buflen = 0; /* (avoid compiler warning). */ memset (sha1hash, 0, 20); *keyidstr = 0; if (charset && pw && *pw) { jnlib_iconv_t cd; const char *inptr; char *outptr; size_t inbytes, outbytes; /* We assume that the converted passphrase is at max 2 times longer than its utf-8 encoding. */ pwbufsize = strlen (pw)*2 + 1; pwbuf = gcry_malloc_secure (pwbufsize); if (!pwbuf) { log_error ("out of secure memory while converting passphrase\n"); goto failure; } cd = jnlib_iconv_open (charset, "utf-8"); if (cd == (jnlib_iconv_t)(-1)) { log_error ("can't convert passphrase to" " requested charset `%s': %s\n", charset, strerror (errno)); gcry_free (pwbuf); goto failure; } inptr = pw; inbytes = strlen (pw); outptr = pwbuf; outbytes = pwbufsize - 1; if ( jnlib_iconv (cd, (const char **)&inptr, &inbytes, &outptr, &outbytes) == (size_t)-1) { log_error ("error converting passphrase to" " requested charset `%s': %s\n", charset, strerror (errno)); gcry_free (pwbuf); jnlib_iconv_close (cd); goto failure; } *outptr = 0; jnlib_iconv_close (cd); pw = pwbuf; } if (cert && certlen) { /* Calculate the hash value we need for the bag attributes. */ gcry_md_hash_buffer (GCRY_MD_SHA1, sha1hash, cert, certlen); sprintf (keyidstr, "%02x%02x%02x%02x", sha1hash[16], sha1hash[17], sha1hash[18], sha1hash[19]); /* Encode the certificate. */ buffer = build_cert_sequence (cert, certlen, sha1hash, keyidstr, &buflen); if (!buffer) goto failure; /* Encrypt it. */ gcry_randomize (salt, 8, GCRY_STRONG_RANDOM); crypt_block (buffer, buflen, salt, 8, 2048, pw, GCRY_CIPHER_RFC2268_40, 1); /* Encode the encrypted stuff into a bag. */ seqlist[seqlistidx].buffer = build_cert_bag (buffer, buflen, salt, &n); seqlist[seqlistidx].length = n; gcry_free (buffer); buffer = NULL; if (!seqlist[seqlistidx].buffer) goto failure; seqlistidx++; } if (kparms) { /* Encode the key. */ buffer = build_key_sequence (kparms, &buflen); if (!buffer) goto failure; /* Encrypt it. */ gcry_randomize (salt, 8, GCRY_STRONG_RANDOM); crypt_block (buffer, buflen, salt, 8, 2048, pw, GCRY_CIPHER_3DES, 1); /* Encode the encrypted stuff into a bag. */ if (cert && certlen) seqlist[seqlistidx].buffer = build_key_bag (buffer, buflen, salt, sha1hash, keyidstr, &n); else seqlist[seqlistidx].buffer = build_key_bag (buffer, buflen, salt, NULL, NULL, &n); seqlist[seqlistidx].length = n; gcry_free (buffer); buffer = NULL; if (!seqlist[seqlistidx].buffer) goto failure; seqlistidx++; } seqlist[seqlistidx].buffer = NULL; seqlist[seqlistidx].length = 0; buffer = create_final (seqlist, pw, &buflen); failure: if (pwbuf) { wipememory (pwbuf, pwbufsize); gcry_free (pwbuf); } for ( ; seqlistidx; seqlistidx--) gcry_free (seqlist[seqlistidx].buffer); *r_length = buffer? buflen : 0; return buffer; } #ifdef TEST static void cert_cb (void *opaque, const unsigned char *cert, size_t certlen) { printf ("got a certificate of %u bytes length\n", certlen); } int main (int argc, char **argv) { FILE *fp; struct stat st; unsigned char *buf; size_t buflen; gcry_mpi_t *result; if (argc != 3) { fprintf (stderr, "usage: testp12 file passphrase\n"); return 1; } gcry_control (GCRYCTL_DISABLE_SECMEM, NULL); gcry_control (GCRYCTL_INITIALIZATION_FINISHED, NULL); fp = fopen (argv[1], "rb"); if (!fp) { fprintf (stderr, "can't open `%s': %s\n", argv[1], strerror (errno)); return 1; } if (fstat (fileno(fp), &st)) { fprintf (stderr, "can't stat `%s': %s\n", argv[1], strerror (errno)); return 1; } buflen = st.st_size; buf = gcry_malloc (buflen+1); if (!buf || fread (buf, buflen, 1, fp) != 1) { fprintf (stderr, "error reading `%s': %s\n", argv[1], strerror (errno)); return 1; } fclose (fp); result = p12_parse (buf, buflen, argv[2], cert_cb, NULL); if (result) { int i, rc; unsigned char *tmpbuf; for (i=0; result[i]; i++) { rc = gcry_mpi_aprint (GCRYMPI_FMT_HEX, &tmpbuf, NULL, result[i]); if (rc) printf ("%d: [error printing number: %s]\n", i, gpg_strerror (rc)); else { printf ("%d: %s\n", i, tmpbuf); gcry_free (tmpbuf); } } } return 0; } /* Local Variables: -compile-command: "gcc -Wall -O0 -g -DTEST=1 -o minip12 minip12.c ../jnlib/libjnlib.a -L /usr/local/lib -lgcrypt -lgpg-error" +compile-command: "gcc -Wall -O0 -g -DTEST=1 -o minip12 minip12.c ../common/libcommon.a -L /usr/local/lib -lgcrypt -lgpg-error" End: */ #endif /* TEST */ diff --git a/agent/protect-tool.c b/agent/protect-tool.c index dc040f9d8..4008a8867 100644 --- a/agent/protect-tool.c +++ b/agent/protect-tool.c @@ -1,1271 +1,1270 @@ /* protect-tool.c - A tool to test the secret key protection * Copyright (C) 2002, 2003, 2004, 2006 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 3 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, see . */ #include #include #include #include #include #include #include #include #include #include #ifdef HAVE_LOCALE_H #include #endif #ifdef HAVE_LANGINFO_CODESET #include #endif #ifdef HAVE_DOSISH_SYSTEM #include /* for setmode() */ #endif #define JNLIB_NEED_LOG_LOGV #include "agent.h" #include "minip12.h" #include "i18n.h" #include "get-passphrase.h" #include "sysutils.h" -#include "estream.h" enum cmd_and_opt_values { aNull = 0, oVerbose = 'v', oArmor = 'a', oPassphrase = 'P', oProtect = 'p', oUnprotect = 'u', oNoVerbose = 500, oShadow, oShowShadowInfo, oShowKeygrip, oS2Kcalibration, oCanonical, oP12Import, oP12Export, oP12Charset, oStore, oForce, oHaveCert, oNoFailOnExist, oHomedir, oPrompt, oStatusMsg, oAgentProgram }; struct rsa_secret_key_s { gcry_mpi_t n; /* public modulus */ gcry_mpi_t e; /* public exponent */ gcry_mpi_t d; /* exponent */ gcry_mpi_t p; /* prime p. */ gcry_mpi_t q; /* prime q. */ gcry_mpi_t u; /* inverse of p mod q. */ }; static const char *opt_homedir; static int opt_armor; static int opt_canonical; static int opt_store; static int opt_force; static int opt_no_fail_on_exist; static int opt_have_cert; static const char *opt_passphrase; static char *opt_prompt; static int opt_status_msg; static const char *opt_p12_charset; static const char *opt_agent_program; static char *get_passphrase (int promptno); static void release_passphrase (char *pw); static int store_private_key (const unsigned char *grip, const void *buffer, size_t length, int force); static ARGPARSE_OPTS opts[] = { ARGPARSE_group (300, N_("@Commands:\n ")), ARGPARSE_c (oProtect, "protect", "protect a private key"), ARGPARSE_c (oUnprotect, "unprotect", "unprotect a private key"), ARGPARSE_c (oShadow, "shadow", "create a shadow entry for a public key"), ARGPARSE_c (oShowShadowInfo, "show-shadow-info", "return the shadow info"), ARGPARSE_c (oShowKeygrip, "show-keygrip", "show the \"keygrip\""), ARGPARSE_c (oP12Import, "p12-import", "import a pkcs#12 encoded private key"), ARGPARSE_c (oP12Export, "p12-export", "export a private key pkcs#12 encoded"), ARGPARSE_c (oS2Kcalibration, "s2k-calibration", "@"), ARGPARSE_group (301, N_("@\nOptions:\n ")), ARGPARSE_s_n (oVerbose, "verbose", "verbose"), ARGPARSE_s_n (oArmor, "armor", "write output in advanced format"), ARGPARSE_s_n (oCanonical, "canonical", "write output in canonical format"), ARGPARSE_s_s (oPassphrase, "passphrase", "|STRING|use passphrase STRING"), ARGPARSE_s_s (oP12Charset,"p12-charset", "|NAME|set charset for a new PKCS#12 passphrase to NAME"), ARGPARSE_s_n (oHaveCert, "have-cert", "certificate to export provided on STDIN"), ARGPARSE_s_n (oStore, "store", "store the created key in the appropriate place"), ARGPARSE_s_n (oForce, "force", "force overwriting"), ARGPARSE_s_n (oNoFailOnExist, "no-fail-on-exist", "@"), ARGPARSE_s_s (oHomedir, "homedir", "@"), ARGPARSE_s_s (oPrompt, "prompt", "|ESCSTRING|use ESCSTRING as prompt in pinentry"), ARGPARSE_s_n (oStatusMsg, "enable-status-msg", "@"), ARGPARSE_s_s (oAgentProgram, "agent-program", "@"), ARGPARSE_end () }; static const char * my_strusage (int level) { const char *p; switch (level) { case 11: p = "gpg-protect-tool (GnuPG)"; break; case 13: p = VERSION; break; case 17: p = PRINTABLE_OS_NAME; break; case 19: p = _("Please report bugs to <@EMAIL@>.\n"); break; case 1: case 40: p = _("Usage: gpg-protect-tool [options] (-h for help)\n"); break; case 41: p = _("Syntax: gpg-protect-tool [options] [args]\n" "Secret key maintenance tool\n"); break; default: p = NULL; } return p; } /* static void */ /* print_mpi (const char *text, gcry_mpi_t a) */ /* { */ /* char *buf; */ /* void *bufaddr = &buf; */ /* int rc; */ /* rc = gcry_mpi_aprint (GCRYMPI_FMT_HEX, bufaddr, NULL, a); */ /* if (rc) */ /* log_info ("%s: [error printing number: %s]\n", text, gpg_strerror (rc)); */ /* else */ /* { */ /* log_info ("%s: %s\n", text, buf); */ /* gcry_free (buf); */ /* } */ /* } */ static unsigned char * make_canonical (const char *fname, const char *buf, size_t buflen) { int rc; size_t erroff, len; gcry_sexp_t sexp; unsigned char *result; rc = gcry_sexp_sscan (&sexp, &erroff, buf, buflen); if (rc) { log_error ("invalid S-Expression in `%s' (off=%u): %s\n", fname, (unsigned int)erroff, gpg_strerror (rc)); return NULL; } len = gcry_sexp_sprint (sexp, GCRYSEXP_FMT_CANON, NULL, 0); assert (len); result = xmalloc (len); len = gcry_sexp_sprint (sexp, GCRYSEXP_FMT_CANON, result, len); assert (len); gcry_sexp_release (sexp); return result; } static char * make_advanced (const unsigned char *buf, size_t buflen) { int rc; size_t erroff, len; gcry_sexp_t sexp; char *result; rc = gcry_sexp_sscan (&sexp, &erroff, (const char*)buf, buflen); if (rc) { log_error ("invalid canonical S-Expression (off=%u): %s\n", (unsigned int)erroff, gpg_strerror (rc)); return NULL; } len = gcry_sexp_sprint (sexp, GCRYSEXP_FMT_ADVANCED, NULL, 0); assert (len); result = xmalloc (len); len = gcry_sexp_sprint (sexp, GCRYSEXP_FMT_ADVANCED, result, len); assert (len); gcry_sexp_release (sexp); return result; } static char * read_file (const char *fname, size_t *r_length) { FILE *fp; char *buf; size_t buflen; if (!strcmp (fname, "-")) { size_t nread, bufsize = 0; fp = stdin; #ifdef HAVE_DOSISH_SYSTEM setmode ( fileno(fp) , O_BINARY ); #endif buf = NULL; buflen = 0; #define NCHUNK 8192 do { bufsize += NCHUNK; if (!buf) buf = xmalloc (bufsize); else buf = xrealloc (buf, bufsize); nread = fread (buf+buflen, 1, NCHUNK, fp); if (nread < NCHUNK && ferror (fp)) { log_error ("error reading `[stdin]': %s\n", strerror (errno)); xfree (buf); return NULL; } buflen += nread; } while (nread == NCHUNK); #undef NCHUNK } else { struct stat st; fp = fopen (fname, "rb"); if (!fp) { log_error ("can't open `%s': %s\n", fname, strerror (errno)); return NULL; } if (fstat (fileno(fp), &st)) { log_error ("can't stat `%s': %s\n", fname, strerror (errno)); fclose (fp); return NULL; } buflen = st.st_size; buf = xmalloc (buflen+1); if (fread (buf, buflen, 1, fp) != 1) { log_error ("error reading `%s': %s\n", fname, strerror (errno)); fclose (fp); xfree (buf); return NULL; } fclose (fp); } *r_length = buflen; return buf; } static unsigned char * read_key (const char *fname) { char *buf; size_t buflen; unsigned char *key; buf = read_file (fname, &buflen); if (!buf) return NULL; key = make_canonical (fname, buf, buflen); xfree (buf); return key; } static void read_and_protect (const char *fname) { int rc; unsigned char *key; unsigned char *result; size_t resultlen; char *pw; key = read_key (fname); if (!key) return; pw = get_passphrase (1); rc = agent_protect (key, pw, &result, &resultlen); release_passphrase (pw); xfree (key); if (rc) { log_error ("protecting the key failed: %s\n", gpg_strerror (rc)); return; } if (opt_armor) { char *p = make_advanced (result, resultlen); xfree (result); if (!p) return; result = (unsigned char*)p; resultlen = strlen (p); } fwrite (result, resultlen, 1, stdout); xfree (result); } static void read_and_unprotect (const char *fname) { int rc; unsigned char *key; unsigned char *result; size_t resultlen; char *pw; gnupg_isotime_t protected_at; key = read_key (fname); if (!key) return; rc = agent_unprotect (key, (pw=get_passphrase (1)), protected_at, &result, &resultlen); release_passphrase (pw); xfree (key); if (rc) { if (opt_status_msg) log_info ("[PROTECT-TOOL:] bad-passphrase\n"); log_error ("unprotecting the key failed: %s\n", gpg_strerror (rc)); return; } if (opt.verbose) log_info ("key protection done at %.4s-%.2s-%.2s %.2s:%.2s:%s\n", protected_at, protected_at+4, protected_at+6, protected_at+9, protected_at+11, protected_at+13); if (opt_armor) { char *p = make_advanced (result, resultlen); xfree (result); if (!p) return; result = (unsigned char*)p; resultlen = strlen (p); } fwrite (result, resultlen, 1, stdout); xfree (result); } static void read_and_shadow (const char *fname) { int rc; unsigned char *key; unsigned char *result; size_t resultlen; unsigned char dummy_info[] = "(8:313233342:43)"; key = read_key (fname); if (!key) return; rc = agent_shadow_key (key, dummy_info, &result); xfree (key); if (rc) { log_error ("shadowing the key failed: %s\n", gpg_strerror (rc)); return; } resultlen = gcry_sexp_canon_len (result, 0, NULL,NULL); assert (resultlen); if (opt_armor) { char *p = make_advanced (result, resultlen); xfree (result); if (!p) return; result = (unsigned char*)p; resultlen = strlen (p); } fwrite (result, resultlen, 1, stdout); xfree (result); } static void show_shadow_info (const char *fname) { int rc; unsigned char *key; const unsigned char *info; size_t infolen; key = read_key (fname); if (!key) return; rc = agent_get_shadow_info (key, &info); xfree (key); if (rc) { log_error ("get_shadow_info failed: %s\n", gpg_strerror (rc)); return; } infolen = gcry_sexp_canon_len (info, 0, NULL,NULL); assert (infolen); if (opt_armor) { char *p = make_advanced (info, infolen); if (!p) return; fwrite (p, strlen (p), 1, stdout); xfree (p); } else fwrite (info, infolen, 1, stdout); } static void show_file (const char *fname) { unsigned char *key; size_t keylen; char *p; key = read_key (fname); if (!key) return; keylen = gcry_sexp_canon_len (key, 0, NULL,NULL); assert (keylen); if (opt_canonical) { fwrite (key, keylen, 1, stdout); } else { p = make_advanced (key, keylen); if (p) { fwrite (p, strlen (p), 1, stdout); xfree (p); } } xfree (key); } static void show_keygrip (const char *fname) { unsigned char *key; gcry_sexp_t private; unsigned char grip[20]; int i; key = read_key (fname); if (!key) return; if (gcry_sexp_new (&private, key, 0, 0)) { log_error ("gcry_sexp_new failed\n"); return; } xfree (key); if (!gcry_pk_get_keygrip (private, grip)) { log_error ("can't calculate keygrip\n"); return; } gcry_sexp_release (private); for (i=0; i < 20; i++) printf ("%02X", grip[i]); putchar ('\n'); } static int rsa_key_check (struct rsa_secret_key_s *skey) { int err = 0; gcry_mpi_t t = gcry_mpi_snew (0); gcry_mpi_t t1 = gcry_mpi_snew (0); gcry_mpi_t t2 = gcry_mpi_snew (0); gcry_mpi_t phi = gcry_mpi_snew (0); /* check that n == p * q */ gcry_mpi_mul (t, skey->p, skey->q); if (gcry_mpi_cmp( t, skey->n) ) { log_error ("RSA oops: n != p * q\n"); err++; } /* check that p is less than q */ if (gcry_mpi_cmp (skey->p, skey->q) > 0) { gcry_mpi_t tmp; log_info ("swapping secret primes\n"); tmp = gcry_mpi_copy (skey->p); gcry_mpi_set (skey->p, skey->q); gcry_mpi_set (skey->q, tmp); gcry_mpi_release (tmp); /* and must recompute u of course */ gcry_mpi_invm (skey->u, skey->p, skey->q); } /* check that e divides neither p-1 nor q-1 */ gcry_mpi_sub_ui (t, skey->p, 1 ); gcry_mpi_div (NULL, t, t, skey->e, 0); if (!gcry_mpi_cmp_ui( t, 0) ) { log_error ("RSA oops: e divides p-1\n"); err++; } gcry_mpi_sub_ui (t, skey->q, 1); gcry_mpi_div (NULL, t, t, skey->e, 0); if (!gcry_mpi_cmp_ui( t, 0)) { log_info ( "RSA oops: e divides q-1\n" ); err++; } /* check that d is correct. */ gcry_mpi_sub_ui (t1, skey->p, 1); gcry_mpi_sub_ui (t2, skey->q, 1); gcry_mpi_mul (phi, t1, t2); gcry_mpi_invm (t, skey->e, phi); if (gcry_mpi_cmp (t, skey->d)) { /* no: try universal exponent. */ gcry_mpi_gcd (t, t1, t2); gcry_mpi_div (t, NULL, phi, t, 0); gcry_mpi_invm (t, skey->e, t); if (gcry_mpi_cmp (t, skey->d)) { log_error ("RSA oops: bad secret exponent\n"); err++; } } /* check for correctness of u */ gcry_mpi_invm (t, skey->p, skey->q); if (gcry_mpi_cmp (t, skey->u)) { log_info ( "RSA oops: bad u parameter\n"); err++; } if (err) log_info ("RSA secret key check failed\n"); gcry_mpi_release (t); gcry_mpi_release (t1); gcry_mpi_release (t2); gcry_mpi_release (phi); return err? -1:0; } /* A callback used by p12_parse to return a certificate. */ static void import_p12_cert_cb (void *opaque, const unsigned char *cert, size_t certlen) { struct b64state state; gpg_error_t err, err2; (void)opaque; err = b64enc_start (&state, stdout, "CERTIFICATE"); if (!err) err = b64enc_write (&state, cert, certlen); err2 = b64enc_finish (&state); if (!err) err = err2; if (err) log_error ("error writing armored certificate: %s\n", gpg_strerror (err)); } static void import_p12_file (const char *fname) { char *buf; unsigned char *result; size_t buflen, resultlen, buf_off; int i; int rc; gcry_mpi_t *kparms; struct rsa_secret_key_s sk; gcry_sexp_t s_key; unsigned char *key; unsigned char grip[20]; char *pw; /* fixme: we should release some stuff on error */ buf = read_file (fname, &buflen); if (!buf) return; /* GnuPG 2.0.4 accidently created binary P12 files with the string "The passphrase is %s encoded.\n\n" prepended to the ASN.1 data. We fix that here. */ if (buflen > 29 && !memcmp (buf, "The passphrase is ", 18)) { for (buf_off=18; buf_off < buflen && buf[buf_off] != '\n'; buf_off++) ; buf_off++; if (buf_off < buflen && buf[buf_off] == '\n') buf_off++; } else buf_off = 0; kparms = p12_parse ((unsigned char*)buf+buf_off, buflen-buf_off, (pw=get_passphrase (2)), import_p12_cert_cb, NULL); release_passphrase (pw); xfree (buf); if (!kparms) { log_error ("error parsing or decrypting the PKCS-12 file\n"); return; } for (i=0; kparms[i]; i++) ; if (i != 8) { log_error ("invalid structure of private key\n"); return; } /* print_mpi (" n", kparms[0]); */ /* print_mpi (" e", kparms[1]); */ /* print_mpi (" d", kparms[2]); */ /* print_mpi (" p", kparms[3]); */ /* print_mpi (" q", kparms[4]); */ /* print_mpi ("dmp1", kparms[5]); */ /* print_mpi ("dmq1", kparms[6]); */ /* print_mpi (" u", kparms[7]); */ sk.n = kparms[0]; sk.e = kparms[1]; sk.d = kparms[2]; sk.q = kparms[3]; sk.p = kparms[4]; sk.u = kparms[7]; if (rsa_key_check (&sk)) return; /* print_mpi (" n", sk.n); */ /* print_mpi (" e", sk.e); */ /* print_mpi (" d", sk.d); */ /* print_mpi (" p", sk.p); */ /* print_mpi (" q", sk.q); */ /* print_mpi (" u", sk.u); */ /* Create an S-expresion from the parameters. */ rc = gcry_sexp_build (&s_key, NULL, "(private-key(rsa(n%m)(e%m)(d%m)(p%m)(q%m)(u%m)))", sk.n, sk.e, sk.d, sk.p, sk.q, sk.u, NULL); for (i=0; i < 8; i++) gcry_mpi_release (kparms[i]); gcry_free (kparms); if (rc) { log_error ("failed to created S-expression from key: %s\n", gpg_strerror (rc)); return; } /* Compute the keygrip. */ if (!gcry_pk_get_keygrip (s_key, grip)) { log_error ("can't calculate keygrip\n"); return; } log_info ("keygrip: "); for (i=0; i < 20; i++) log_printf ("%02X", grip[i]); log_printf ("\n"); /* Convert to canonical encoding. */ buflen = gcry_sexp_sprint (s_key, GCRYSEXP_FMT_CANON, NULL, 0); assert (buflen); key = gcry_xmalloc_secure (buflen); buflen = gcry_sexp_sprint (s_key, GCRYSEXP_FMT_CANON, key, buflen); assert (buflen); gcry_sexp_release (s_key); pw = get_passphrase (4); rc = agent_protect (key, pw, &result, &resultlen); release_passphrase (pw); xfree (key); if (rc) { log_error ("protecting the key failed: %s\n", gpg_strerror (rc)); return; } if (opt_armor) { char *p = make_advanced (result, resultlen); xfree (result); if (!p) return; result = (unsigned char*)p; resultlen = strlen (p); } if (opt_store) store_private_key (grip, result, resultlen, opt_force); else fwrite (result, resultlen, 1, stdout); xfree (result); } static gcry_mpi_t * sexp_to_kparms (gcry_sexp_t sexp) { gcry_sexp_t list, l2; const char *name; const char *s; size_t n; int i, idx; const char *elems; gcry_mpi_t *array; list = gcry_sexp_find_token (sexp, "private-key", 0 ); if(!list) return NULL; l2 = gcry_sexp_cadr (list); gcry_sexp_release (list); list = l2; name = gcry_sexp_nth_data (list, 0, &n); if(!name || n != 3 || memcmp (name, "rsa", 3)) { gcry_sexp_release (list); return NULL; } /* Parameter names used with RSA. */ elems = "nedpqu"; array = xcalloc (strlen(elems) + 1, sizeof *array); for (idx=0, s=elems; *s; s++, idx++ ) { l2 = gcry_sexp_find_token (list, s, 1); if (!l2) { for (i=0; i 1) usage (1); /* Set the information which can't be taken from envvars. */ gnupg_prepare_get_passphrase (GPG_ERR_SOURCE_DEFAULT, opt.verbose, opt_homedir, opt_agent_program, NULL, NULL, NULL); if (opt_prompt) opt_prompt = percent_plus_unescape (opt_prompt, 0); if (cmd == oProtect) read_and_protect (fname); else if (cmd == oUnprotect) read_and_unprotect (fname); else if (cmd == oShadow) read_and_shadow (fname); else if (cmd == oShowShadowInfo) show_shadow_info (fname); else if (cmd == oShowKeygrip) show_keygrip (fname); else if (cmd == oP12Import) import_p12_file (fname); else if (cmd == oP12Export) export_p12_file (fname); else if (cmd == oS2Kcalibration) { if (!opt.verbose) opt.verbose++; /* We need to see something. */ get_standard_s2k_count (); } else show_file (fname); agent_exit (0); return 8; /*NOTREACHED*/ } void agent_exit (int rc) { rc = rc? rc : log_get_errorcount(0)? 2 : 0; exit (rc); } /* Return the passphrase string and ask the agent if it has not been set from the command line PROMPTNO select the prompt to display: 0 = default 1 = taken from the option --prompt 2 = for unprotecting a pkcs#12 object 3 = for protecting a new pkcs#12 object 4 = for protecting an imported pkcs#12 in our system */ static char * get_passphrase (int promptno) { char *pw; int err; const char *desc; char *orig_codeset; int repeat = 0; if (opt_passphrase) return xstrdup (opt_passphrase); orig_codeset = i18n_switchto_utf8 (); if (promptno == 1 && opt_prompt) { desc = opt_prompt; } else if (promptno == 2) { desc = _("Please enter the passphrase to unprotect the " "PKCS#12 object."); } else if (promptno == 3) { desc = _("Please enter the passphrase to protect the " "new PKCS#12 object."); repeat = 1; } else if (promptno == 4) { desc = _("Please enter the passphrase to protect the " "imported object within the GnuPG system."); repeat = 1; } else desc = _("Please enter the passphrase or the PIN\n" "needed to complete this operation."); i18n_switchback (orig_codeset); err = gnupg_get_passphrase (NULL, NULL, _("Passphrase:"), desc, repeat, repeat, 1, &pw); if (err) { if (gpg_err_code (err) == GPG_ERR_CANCELED) log_info (_("cancelled\n")); else log_error (_("error while asking for the passphrase: %s\n"), gpg_strerror (err)); agent_exit (0); } assert (pw); return pw; } static void release_passphrase (char *pw) { if (pw) { wipememory (pw, strlen (pw)); xfree (pw); } } static int store_private_key (const unsigned char *grip, const void *buffer, size_t length, int force) { char *fname; estream_t fp; char hexgrip[40+4+1]; bin2hex (grip, 20, hexgrip); strcpy (hexgrip+40, ".key"); fname = make_filename (opt_homedir, GNUPG_PRIVATE_KEYS_DIR, hexgrip, NULL); if (force) fp = es_fopen (fname, "wb"); else { if (!access (fname, F_OK)) { if (opt_status_msg) log_info ("[PROTECT-TOOL:] secretkey-exists\n"); if (opt_no_fail_on_exist) log_info ("secret key file `%s' already exists\n", fname); else log_error ("secret key file `%s' already exists\n", fname); xfree (fname); return opt_no_fail_on_exist? 0 : -1; } /* FWIW: Under Windows Vista the standard fopen in the msvcrt fails if the "x" GNU extension is used. */ fp = es_fopen (fname, "wbx"); } if (!fp) { log_error ("can't create `%s': %s\n", fname, strerror (errno)); xfree (fname); return -1; } if (es_fwrite (buffer, length, 1, fp) != 1) { log_error ("error writing `%s': %s\n", fname, strerror (errno)); es_fclose (fp); remove (fname); xfree (fname); return -1; } if (es_fclose (fp)) { log_error ("error closing `%s': %s\n", fname, strerror (errno)); remove (fname); xfree (fname); return -1; } log_info ("secret key stored as `%s'\n", fname); if (opt_status_msg) log_info ("[PROTECT-TOOL:] secretkey-stored\n"); xfree (fname); return 0; } diff --git a/agent/trustlist.c b/agent/trustlist.c index be5406b05..3236ae425 100644 --- a/agent/trustlist.c +++ b/agent/trustlist.c @@ -1,763 +1,762 @@ /* trustlist.c - Maintain the list of trusted keys * Copyright (C) 2002, 2004, 2006, 2007, 2009 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 3 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, see . */ #include #include #include #include #include #include #include #include #include #include #include "agent.h" #include /* fixme: need a way to avoid assuan calls here */ #include "i18n.h" -#include "estream.h" /* A structure to store the information from the trust file. */ struct trustitem_s { struct { int disabled:1; /* This entry is disabled. */ int for_pgp:1; /* Set by '*' or 'P' as first flag. */ int for_smime:1; /* Set by '*' or 'S' as first flag. */ int relax:1; /* Relax checking of root certificate constraints. */ int cm:1; /* Use chain model for validation. */ } flags; unsigned char fpr[20]; /* The binary fingerprint. */ }; typedef struct trustitem_s trustitem_t; /* Malloced table and its allocated size with all trust items. */ static trustitem_t *trusttable; static size_t trusttablesize; /* A mutex used to protect the table. */ static pth_mutex_t trusttable_lock; static const char headerblurb[] = "# This is the list of trusted keys. Comment lines, like this one, as\n" "# well as empty lines are ignored. Lines have a length limit but this\n" "# is not a serious limitation as the format of the entries is fixed and\n" "# checked by gpg-agent. A non-comment line starts with optional white\n" "# space, followed by the SHA-1 fingerpint in hex, followed by a flag\n" "# which may be one of 'P', 'S' or '*' and optionally followed by a list of\n" "# other flags. The fingerprint may be prefixed with a '!' to mark the\n" "# key as not trusted. You should give the gpg-agent a HUP or run the\n" "# command \"gpgconf --reload gpg-agent\" after changing this file.\n" "\n\n" "# Include the default trust list\n" "include-default\n" "\n"; /* This function must be called once to initialize this module. This has to be done before a second thread is spawned. We can't do the static initialization because Pth emulation code might not be able to do a static init; in particular, it is not possible for W32. */ void initialize_module_trustlist (void) { static int initialized; if (!initialized) { if (!pth_mutex_init (&trusttable_lock)) log_fatal ("error initializing mutex: %s\n", strerror (errno)); initialized = 1; } } static void lock_trusttable (void) { if (!pth_mutex_acquire (&trusttable_lock, 0, NULL)) log_fatal ("failed to acquire mutex in %s\n", __FILE__); } static void unlock_trusttable (void) { if (!pth_mutex_release (&trusttable_lock)) log_fatal ("failed to release mutex in %s\n", __FILE__); } static gpg_error_t read_one_trustfile (const char *fname, int allow_include, trustitem_t **addr_of_table, size_t *addr_of_tablesize, int *addr_of_tableidx) { gpg_error_t err = 0; FILE *fp; int n, c; char *p, line[256]; trustitem_t *table, *ti; int tableidx; size_t tablesize; int lnr = 0; table = *addr_of_table; tablesize = *addr_of_tablesize; tableidx = *addr_of_tableidx; fp = fopen (fname, "r"); if (!fp) { err = gpg_error_from_syserror (); log_error (_("error opening `%s': %s\n"), fname, gpg_strerror (err)); goto leave; } while (fgets (line, DIM(line)-1, fp)) { lnr++; if (!*line || line[strlen(line)-1] != '\n') { /* Eat until end of line. */ while ( (c=getc (fp)) != EOF && c != '\n') ; err = gpg_error (*line? GPG_ERR_LINE_TOO_LONG : GPG_ERR_INCOMPLETE_LINE); log_error (_("file `%s', line %d: %s\n"), fname, lnr, gpg_strerror (err)); continue; } line[strlen(line)-1] = 0; /* Chop the LF. */ /* Allow for empty lines and spaces */ for (p=line; spacep (p); p++) ; if (!*p || *p == '#') continue; if (!strncmp (p, "include-default", 15) && (!p[15] || spacep (p+15))) { char *etcname; gpg_error_t err2; if (!allow_include) { log_error (_("statement \"%s\" ignored in `%s', line %d\n"), "include-default", fname, lnr); continue; } /* fixme: Should check for trailing garbage. */ etcname = make_filename (gnupg_sysconfdir (), "trustlist.txt", NULL); if ( !strcmp (etcname, fname) ) /* Same file. */ log_info (_("statement \"%s\" ignored in `%s', line %d\n"), "include-default", fname, lnr); else if ( access (etcname, F_OK) && errno == ENOENT ) { /* A non existent system trustlist is not an error. Just print a note. */ log_info (_("system trustlist `%s' not available\n"), etcname); } else { err2 = read_one_trustfile (etcname, 0, &table, &tablesize, &tableidx); if (err2) err = err2; } xfree (etcname); continue; } if (tableidx == tablesize) /* Need more space. */ { trustitem_t *tmp; size_t tmplen; tmplen = tablesize + 20; tmp = xtryrealloc (table, tmplen * sizeof *table); if (!tmp) { err = gpg_error_from_syserror (); goto leave; } table = tmp; tablesize = tmplen; } ti = table + tableidx; memset (&ti->flags, 0, sizeof ti->flags); if (*p == '!') { ti->flags.disabled = 1; p++; while (spacep (p)) p++; } n = hexcolon2bin (p, ti->fpr, 20); if (n < 0) { log_error (_("bad fingerprint in `%s', line %d\n"), fname, lnr); err = gpg_error (GPG_ERR_BAD_DATA); continue; } p += n; for (; spacep (p); p++) ; /* Process the first flag which needs to be the first for backward compatibility. */ if (!*p || *p == '*' ) { ti->flags.for_smime = 1; ti->flags.for_pgp = 1; } else if ( *p == 'P' || *p == 'p') { ti->flags.for_pgp = 1; } else if ( *p == 'S' || *p == 's') { ti->flags.for_smime = 1; } else { log_error (_("invalid keyflag in `%s', line %d\n"), fname, lnr); err = gpg_error (GPG_ERR_BAD_DATA); continue; } p++; if ( *p && !spacep (p) ) { log_error (_("invalid keyflag in `%s', line %d\n"), fname, lnr); err = gpg_error (GPG_ERR_BAD_DATA); continue; } /* Now check for more key-value pairs of the form NAME[=VALUE]. */ while (*p) { for (; spacep (p); p++) ; if (!*p) break; n = strcspn (p, "= \t"); if (p[n] == '=') { log_error ("assigning a value to a flag is not yet supported; " "in `%s', line %d\n", fname, lnr); err = gpg_error (GPG_ERR_BAD_DATA); p++; } else if (n == 5 && !memcmp (p, "relax", 5)) ti->flags.relax = 1; else if (n == 2 && !memcmp (p, "cm", 2)) ti->flags.cm = 1; else log_error ("flag `%.*s' in `%s', line %d ignored\n", n, p, fname, lnr); p += n; } tableidx++; } if ( !err && !feof (fp) ) { err = gpg_error_from_syserror (); log_error (_("error reading `%s', line %d: %s\n"), fname, lnr, gpg_strerror (err)); } leave: if (fp) fclose (fp); *addr_of_table = table; *addr_of_tablesize = tablesize; *addr_of_tableidx = tableidx; return err; } /* Read the trust files and update the global table on success. */ static gpg_error_t read_trustfiles (void) { gpg_error_t err; trustitem_t *table, *ti; int tableidx; size_t tablesize; char *fname; int allow_include = 1; tablesize = 20; table = xtrycalloc (tablesize, sizeof *table); if (!table) return gpg_error_from_syserror (); tableidx = 0; fname = make_filename (opt.homedir, "trustlist.txt", NULL); if ( access (fname, F_OK) ) { if ( errno == ENOENT ) ; /* Silently ignore a non-existing trustfile. */ else { err = gpg_error_from_syserror (); log_error (_("error opening `%s': %s\n"), fname, gpg_strerror (err)); } xfree (fname); fname = make_filename (gnupg_sysconfdir (), "trustlist.txt", NULL); allow_include = 0; } err = read_one_trustfile (fname, allow_include, &table, &tablesize, &tableidx); xfree (fname); if (err) { xfree (table); if (gpg_err_code (err) == GPG_ERR_ENOENT) { /* Take a missing trustlist as an empty one. */ lock_trusttable (); xfree (trusttable); trusttable = NULL; trusttablesize = 0; unlock_trusttable (); err = 0; } return err; } /* Fixme: we should drop duplicates and sort the table. */ ti = xtryrealloc (table, (tableidx?tableidx:1) * sizeof *table); if (!ti) { err = gpg_error_from_syserror (); xfree (table); return err; } lock_trusttable (); xfree (trusttable); trusttable = ti; trusttablesize = tableidx; unlock_trusttable (); return 0; } /* Check whether the given fpr is in our trustdb. We expect FPR to be an all uppercase hexstring of 40 characters. */ gpg_error_t agent_istrusted (ctrl_t ctrl, const char *fpr, int *r_disabled) { gpg_error_t err; trustitem_t *ti; size_t len; unsigned char fprbin[20]; if (r_disabled) *r_disabled = 0; if ( hexcolon2bin (fpr, fprbin, 20) < 0 ) return gpg_error (GPG_ERR_INV_VALUE); if (!trusttable) { err = read_trustfiles (); if (err) { log_error (_("error reading list of trusted root certificates\n")); return err; } } if (trusttable) { for (ti=trusttable, len = trusttablesize; len; ti++, len--) if (!memcmp (ti->fpr, fprbin, 20)) { if (ti->flags.disabled && r_disabled) *r_disabled = 1; if (ti->flags.relax) { err = agent_write_status (ctrl, "TRUSTLISTFLAG", "relax", NULL); if (err) return err; } else if (ti->flags.cm) { err = agent_write_status (ctrl, "TRUSTLISTFLAG", "cm", NULL); if (err) return err; } return ti->flags.disabled? gpg_error (GPG_ERR_NOT_TRUSTED) : 0; } } return gpg_error (GPG_ERR_NOT_TRUSTED); } /* Write all trust entries to FP. */ gpg_error_t agent_listtrusted (void *assuan_context) { trustitem_t *ti; char key[51]; gpg_error_t err; size_t len; if (!trusttable) { err = read_trustfiles (); if (err) { log_error (_("error reading list of trusted root certificates\n")); return err; } } if (trusttable) { /* We need to lock the table because the scheduler may interrupt assuan_send_data and an other thread may then re-read the table. */ lock_trusttable (); for (ti=trusttable, len = trusttablesize; len; ti++, len--) { if (ti->flags.disabled) continue; bin2hex (ti->fpr, 20, key); key[40] = ' '; key[41] = ((ti->flags.for_smime && ti->flags.for_pgp)? '*' : ti->flags.for_smime? 'S': ti->flags.for_pgp? 'P':' '); key[42] = '\n'; assuan_send_data (assuan_context, key, 43); assuan_send_data (assuan_context, NULL, 0); /* flush */ } unlock_trusttable (); } return 0; } /* Create a copy of string with colons inserted after each two bytes. Caller needs to release the string. In case of a memory failure, NULL is returned. */ static char * insert_colons (const char *string) { char *buffer, *p; size_t n = strlen (string); size_t nnew = n + (n+1)/2; p = buffer = xtrymalloc ( nnew + 1 ); if (!buffer) return NULL; while (*string) { *p++ = *string++; if (*string) { *p++ = *string++; if (*string) *p++ = ':'; } } *p = 0; assert (strlen (buffer) <= nnew); return buffer; } /* To pretty print DNs in the Pinentry, we replace slashes by REPLSTRING. The caller needs to free the returned string. NULL is returned on error with ERRNO set. */ static char * reformat_name (const char *name, const char *replstring) { const char *s; char *newname; char *d; size_t count; size_t replstringlen = strlen (replstring); /* If the name does not start with a slash it is not a preformatted DN and thus we don't bother to reformat it. */ if (*name != '/') return xtrystrdup (name); /* Count the names. Note that a slash contained in a DN part is expected to be C style escaped and thus the slashes we see here are the actual part delimiters. */ for (s=name+1, count=0; *s; s++) if (*s == '/') count++; newname = xtrymalloc (strlen (name) + count*replstringlen + 1); if (!newname) return NULL; for (s=name+1, d=newname; *s; s++) if (*s == '/') d = stpcpy (d, replstring); else *d++ = *s; *d = 0; return newname; } /* Insert the given fpr into our trustdb. We expect FPR to be an all uppercase hexstring of 40 characters. FLAG is either 'P' or 'C'. This function does first check whether that key has already been put into the trustdb and returns success in this case. Before a FPR actually gets inserted, the user is asked by means of the Pinentry whether this is actual want he wants to do. */ gpg_error_t agent_marktrusted (ctrl_t ctrl, const char *name, const char *fpr, int flag) { gpg_error_t err = 0; char *desc; char *fname; estream_t fp; char *fprformatted; char *nameformatted; int is_disabled; int yes_i_trust; /* Check whether we are at all allowed to modify the trustlist. This is useful so that the trustlist may be a symlink to a global trustlist with only admin priviliges to modify it. Of course this is not a secure way of denying access, but it avoids the usual clicking on an Okay button most users are used to. */ fname = make_filename (opt.homedir, "trustlist.txt", NULL); if ( access (fname, W_OK) && errno != ENOENT) { xfree (fname); return gpg_error (GPG_ERR_EPERM); } xfree (fname); if (!agent_istrusted (ctrl, fpr, &is_disabled)) { return 0; /* We already got this fingerprint. Silently return success. */ } /* This feature must explicitly been enabled. */ if (!opt.allow_mark_trusted) return gpg_error (GPG_ERR_NOT_SUPPORTED); if (is_disabled) { /* There is an disabled entry in the trustlist. Return an error so that the user won't be asked again for that one. Changing this flag with the integrated marktrusted feature is and will not be made possible. */ return gpg_error (GPG_ERR_NOT_TRUSTED); } /* Insert a new one. */ nameformatted = reformat_name (name, "%0A "); if (!nameformatted) return gpg_error_from_syserror (); /* First a general question whether this is trusted. */ desc = xtryasprintf ( /* TRANSLATORS: This prompt is shown by the Pinentry and has one special property: A "%%0A" is used by Pinentry to insert a line break. The double percent sign is actually needed because it is also a printf format string. If you need to insert a plain % sign, you need to encode it as "%%25". The "%s" gets replaced by the name as stored in the certificate. */ _("Do you ultimately trust%%0A" " \"%s\"%%0A" "to correctly certify user certificates?"), nameformatted); if (!desc) { xfree (nameformatted); return out_of_core (); } err = agent_get_confirmation (ctrl, desc, _("Yes"), _("No"), 1); xfree (desc); if (!err) yes_i_trust = 1; else if (gpg_err_code (err) == GPG_ERR_NOT_CONFIRMED) yes_i_trust = 0; else { xfree (nameformatted); return err; } fprformatted = insert_colons (fpr); if (!fprformatted) { xfree (nameformatted); return out_of_core (); } /* If the user trusts this certificate he has to verify the fingerprint of course. */ if (yes_i_trust) { desc = xtryasprintf ( /* TRANSLATORS: This prompt is shown by the Pinentry and has one special property: A "%%0A" is used by Pinentry to insert a line break. The double percent sign is actually needed because it is also a printf format string. If you need to insert a plain % sign, you need to encode it as "%%25". The second "%s" gets replaced by a hexdecimal fingerprint string whereas the first one receives the name as stored in the certificate. */ _("Please verify that the certificate identified as:%%0A" " \"%s\"%%0A" "has the fingerprint:%%0A" " %s"), nameformatted, fprformatted); if (!desc) { xfree (fprformatted); xfree (nameformatted); return out_of_core (); } /* TRANSLATORS: "Correct" is the label of a button and intended to be hit if the fingerprint matches the one of the CA. The other button is "the default "Cancel" of the Pinentry. */ err = agent_get_confirmation (ctrl, desc, _("Correct"), _("Wrong"), 1); xfree (desc); if (gpg_err_code (err) == GPG_ERR_NOT_CONFIRMED) yes_i_trust = 0; else if (err) { xfree (fprformatted); xfree (nameformatted); return err; } } /* Now check again to avoid duplicates. We take the lock to make sure that nobody else plays with our file and force a reread. */ lock_trusttable (); agent_reload_trustlist (); if (!agent_istrusted (ctrl, fpr, &is_disabled) || is_disabled) { unlock_trusttable (); xfree (fprformatted); xfree (nameformatted); return is_disabled? gpg_error (GPG_ERR_NOT_TRUSTED) : 0; } fname = make_filename (opt.homedir, "trustlist.txt", NULL); if ( access (fname, F_OK) && errno == ENOENT) { fp = es_fopen (fname, "wx"); if (!fp) { err = gpg_error_from_syserror (); log_error ("can't create `%s': %s\n", fname, gpg_strerror (err)); xfree (fname); unlock_trusttable (); xfree (fprformatted); xfree (nameformatted); return err; } es_fputs (headerblurb, fp); es_fclose (fp); } fp = es_fopen (fname, "a+"); if (!fp) { err = gpg_error_from_syserror (); log_error ("can't open `%s': %s\n", fname, gpg_strerror (err)); xfree (fname); unlock_trusttable (); xfree (fprformatted); xfree (nameformatted); return err; } /* Append the key. */ es_fputs ("\n# ", fp); xfree (nameformatted); nameformatted = reformat_name (name, "\n# "); if (!nameformatted || strchr (name, '\n')) { /* Note that there should never be a LF in NAME but we better play safe and print a sanitized version in this case. */ es_write_sanitized (fp, name, strlen (name), NULL, NULL); } else es_fputs (nameformatted, fp); es_fprintf (fp, "\n%s%s %c\n", yes_i_trust?"":"!", fprformatted, flag); if (es_ferror (fp)) err = gpg_error_from_syserror (); if (es_fclose (fp)) err = gpg_error_from_syserror (); agent_reload_trustlist (); xfree (fname); unlock_trusttable (); xfree (fprformatted); xfree (nameformatted); return err; } /* This function may be called to force reloading of the trustlist. */ void agent_reload_trustlist (void) { /* All we need to do is to delete the trusttable. At the next access it will get re-read. */ lock_trusttable (); xfree (trusttable); trusttable = NULL; trusttablesize = 0; unlock_trusttable (); bump_key_eventcounter (); } diff --git a/common/ChangeLog b/common/ChangeLog index 7408123ec..6f4b70b30 100644 --- a/common/ChangeLog +++ b/common/ChangeLog @@ -1,1640 +1,1667 @@ +2010-03-10 Werner Koch + + * util.h: Replace jnlib path part by common. + (snprintf): Use the replacement macro on all platforms. + + * Makefile.am (jnlib_sources): New. + (libcommon_a_SOURCES, libcommonpth_a_SOURCES): Add jnlib_sources. + (jnlib_tests): New. + (noinst_PROGRAMS, TESTS): Add jnlib_tests. + (t_common_ldadd): Remove libjnlib.a. + + * README.jnlib, ChangeLog.jnlib, libjnlib-config.h, argparse.c + * argparse.h, dotlock.c, dotlock.h, dynload.h, logging.c + * logging.h, mischelp.c, mischelp.h, stringhelp.c, stringhelp.h + * strlist.c, strlist.h, types.h, utf8conv.c, utf8conv.h + * w32-afunix.c, w32-afunix.h, w32-reg.c, w32help.h, xmalloc.c + * xmalloc.h, t-stringhelp.c, t-support.c, t-support.h + * t-timestuff.c, t-w32-reg.c: Move from jnlib to here. + + * init.c: Remove "estream.h". + * util.h: Include "estream.h". + + * xasprintf.c, ttyio.c: Remove "estream-printf.h". + 2010-03-08 Werner Koch + * exechelp.c [!HAVE_SIGNAL_H]: Do not include signal.h. + (DETACHED_PROCESS, CREATE_NEW_PROCESS_GROUP) [W32CE]: Provide stubs. + * iobuf.h (iobuf_ioctl_t): New. Use the new macros instead of the hard wired values. * iobuf.c (iobuf_append): Remove. (iobuf_fdopen): Factor code out to ... (do_iobuf_fdopen): ... new. (iobuf_fdopen_nc): New. (iobuf_open_fd_or_name): Implement using iobuf_fdopen_nc. * iobuf.c (INVALID_FD): Replace by GNUPG_INVALID_FD. (fp_or_fd_t): Replace by gnupg_fd_t. (my_fileno): Replace by the FD2INT macro. (FILEP_OR_FD_FOR_STDIN, FILEP_OR_FD_FOR_STDOUT): Rename to FD_FOR_STDIN, FD_FOR_STDOUT. (file_filter): Make full use of FD_FOR_STDIN. (USE_SETMODE): Remove. Not needed without stdio. (my_fopen_ro, my_fopen): Replace unneeded macros. * iobuf.c [FILE_FILTER_USES_STDIO]: Remove all code. It has not been used for a long time. * exechelp.h: Include "estream.h". * exechelp.c (gnupg_spawn_process): Change OUTFILE to an estream_t. 2010-03-02 Werner Koch * estream.c, estream.h, estream-printf.c, estream-printf.h: Update from libestream. 2010-03-01 Werner Koch * signal.c [!HAVE_SIGNAL_H]: Don't include signal.h. * iobuf.c (direct_open) [W32CE]: Make filename to wchar_t. (iobuf_cancel) [W32CE]: Use DeleteFile. * gettime.c (dump_isotime): Use "%s" to print "none". * homedir.c (standard_homedir) [W32CE]: Use wchar_t to create the directory. (w32_rootdir) [W32CE]: Likewise. * sysutils.c (translate_sys2libc_fd) [W32CE]: Add support. (gnupg_tmpfile) [W32CE]: Ditto. (_gnupg_getenv) [W32CE]: New. * util.h (getpid, getenv) [W32CE]: New. * i18n.c (i18n_switchto_utf8) (i18n_switchback) [USE_SIMPLE_GETTEXT]: Use new function from libgpg-error which supports proper restoring. * sysutils.c (get_session_marker): Simplified by using gcrypt. 2009-12-08 Marcus Brinkmann * Makefile.am (audit-events.h, status.h) [!MAINTAINER_MODE]: No longer include these rules if not in maintainer mode. 2009-12-08 Werner Koch * userids.h, userids.c: New. (classify_user_id): Merged from similar fucntions in sm/ and g10/. * dns-cert.c (get_dns_cert): Add support for ADNS. 2009-12-08 Marcus Brinkmann * asshelp.c (start_new_gpg_agent): Convert posix FD to assuan FD. * asshelp.c (start_new_gpg_agent) [HAVE_W32_SYSTEM]: Add missing argument in assuan_socket_connect invocation. * iobuf.c (iobuf_open_fd_or_name): Fix type of FD in function declaration. 2009-12-07 Werner Koch * pka.c (get_pka_info): Add support for ADNS. * src.v (getsrv): Add support for ADNS. * srv.c (getsrv): s/xrealloc/xtryrealloc/. 2009-12-04 Werner Koch * Makefile.am (audit-events.h, status-codes.h): Create files in the source dir. Fixes bug#1164. 2009-12-02 Werner Koch * audit.c (proc_type_decrypt, proc_type_sign): Implemented. (proc_type_verify): Print hash algo infos. * audit.h (AUDIT_DATA_CIPHER_ALGO, AUDIT_BAD_DATA_CIPHER_ALSO) (AUDIT_NEW_RECP, AUDIT_DECRYPTION_RESULT, AUDIT_RECP_RESULT) (AUDIT_ATTR_HASH_ALGO, AUDIT_SIGNED_BY, AUDIT_SIGNING_DONE): 2009-11-05 Marcus Brinkmann * asshelp.c (start_new_gpg_agent): Update use of assuan_socket_connect and assuan_pipe_connect. 2009-11-02 Marcus Brinkmann * get-passphrase.c (default_inq_cb, membuf_data_cb): Change return type to gpg_error_t. 2009-10-28 Werner Koch * status.h (STATUS_MOUNTPOINT): New. 2009-10-16 Marcus Brinkmann * Makefile.am (libcommon_a_CFLAGS): Use LIBASSUAN_CFLAGS instead of LIBASSUAN_PTH_CFLAGS. 2009-10-13 Werner Koch * exechelp.c (gnupg_kill_process): New. 2009-09-29 Werner Koch * exechelp.c (create_inheritable_pipe): Rename to create_inheritable_pipe_w. (create_inheritable_pipe_r): New. (gnupg_create_outbound_pipe): New. * iobuf.h: Include "sysutils.h" * iobuf.c (iobuf_open_fd_or_name): New. (iobuf_get_fname_nonnull): New. 2009-09-23 Marcus Brinkmann * asshelp.c (start_new_gpg_agent): Allocate assuan context before starting server. 2009-09-03 Werner Koch Update from libestream: * estream-printf.c: Include stdint.h only if HAVE_STDINT_H is defined. * estream-printf.c: Remove all test code. Use macro DEBUG instead of TEST for debugging. * estream-printf.c (pr_float): Make buffer larger for silly high numbers. 2009-08-11 David Shaw * ttyio.h, ttyio.c (tty_enable_completion): Some ifdefs around HAVE_LIBREADLINE to allow building when readline isn't available. 2009-08-06 Werner Koch * status.h (STATUS_INV_SGNR, STATUS_NO_SGNR): New. * status.c (get_inv_recpsgnr_code): New. 2009-07-23 David Shaw * srv.c (getsrv): Fix type-punning warning. 2009-07-23 Werner Koch * util.h (GPG_ERR_NOT_ENABLED): New. * audit.h (enum): Add AUDIT_CRL_CHECK. * audit.c (proc_type_verify): Show CRL check result. 2009-07-06 Werner Koch * get-passphrase.c (struct agentargs): Add SESSION_ENV and remove obsolete args. (gnupg_prepare_get_passphrase): Ditto. * session-env.c, session-env.h: New. * t-session-env.c: New. * Makefile.am (common_sources, module_tests): Add them. * asshelp.h: Include "session-env.h" * asshelp.c (send_one_option): Add arg PUTENV. (send_pinentry_environment): Replace most args by SESSION_ENV and rewrite fucntion. (start_new_gpg_agent): Likewise. * t-exechelp.c (test_close_all_fds): Remove debug code. 2009-07-01 Werner Koch * sexputil.c (get_pk_algo_from_canon_sexp): New. 2009-06-29 Werner Koch * estream.c (BUFFER_ROUND_TO_BLOCK): Remove unused macro. (es_func_mem_write): Rewrite reallocation part. * estream.c (es_write_sanitized_utf8_buffer): Typo typo fix. 2009-06-25 Werner Koch * estream.c (es_write_sanitized_utf8_buffer): Typo fix. 2009-06-24 Werner Koch * estream.c (es_read_line): In the malloc error case, set MAX_LENGTH to 0 only if requested. * xreadline.c (read_line): Ditto. * estream.c (es_write_sanitized_utf8_buffer): Pass on error from es_fputs. * sexputil.c (get_rsa_pk_from_canon_sexp): Check for error after the loop. Reported by Fabian Keil. 2009-06-22 Werner Koch * estream.c (es_pth_read, es_pth_write) [W32]: New. (ESTREAM_SYS_READ, ESTREAM_SYS_WRITE) [HAVE_PTH]: Use them. 2009-06-03 Werner Koch * estream.c (es_convert_mode): Rewrite and support the "x" flag. 2009-05-28 David Shaw From 1.4: * http.h, http.c (send_request) Pass in a STRLIST for additional headers. Change all callers. 2009-05-27 David Shaw From 1.4: * http.h, http.c (send_request): Pass in srvtag and make its presence sufficient to turn the feature on. (http_open): From here. (http_document): And here. * srv.c (getsrv): Raise maximum packet size to 2048, as PACKETSZ is too small these days. 2009-05-22 Werner Koch * ttyio.c (tty_cleanup_after_signal): New. 2009-05-19 Werner Koch * simple-pwquery.c (agent_open): Use SUN_LEN (JNLIB_NEED_AFLOCAL): Define and include mischelp.h. 2009-05-07 Werner Koch * sexputil.c (get_rsa_pk_from_canon_sexp): New. * t-sexputil.c (test_make_canon_sexp_from_rsa_pk): Extend the test. 2009-04-28 Werner Koch * sexputil.c (make_canon_sexp_from_rsa_pk): New. * t-sexputil.c (test_make_canon_sexp_from_rsa_pk): New. 2009-04-01 Werner Koch * iobuf.c: Port David's changes from 1.4: (fd_cache_invalidate): Pass return code from close back. (direct_open, iobuf_ioctl): Check that return value. (fd_cache_synchronize): New. (iobuf_ioctl): Add new sub command 4 (fsync). * iobuf.c (fd_cache_strcmp): New. Taken from 1.4. (fd_cache_invalidate, fd_cache_close, fd_cache_open): Use it. * exechelp.c (gnupg_spawn_process): Implement new flag bit 6. * sysutils.c (gnupg_allow_set_foregound_window): Allow the use of ASFW_ANY. * membuf.c (put_membuf, get_membuf): Wipe memory on out of core. 2009-03-31 Werner Koch * percent.c (percent_unescape, percent_plus_unescape): New. (percent_plus_unescape_inplace, percent_unescape_inplace): New. (do_plus_or_plain_unescape, count_unescape, do_unescape): New. (do_unescape_inplace): New. * t-percent.c (test_percent_plus_escape): Test percent_plus_unescape. * get-passphrase.c, get-passphrase.h: New. * Makefile.am (without_pth_sources): New. 2009-03-18 Werner Koch * exechelp.c: Include sys/resource.h and sys/stat.h. (get_max_open_fds): New. (do_exec): Use it. (get_all_open_fds): New. (close_all_fds): New. (do_exec): Use close_all_fds. * t-exechelp.c: New. 2009-03-13 David Shaw * http.c (do_parse_uri): Properly handle IPv6 literal addresses as per RFC-2732. Adapted from patch by Phil Pennock. 2009-03-12 Werner Koch * gettime.c: Include i18n.h. (dump_isotime): New. 2009-03-06 Werner Koch * sexputil.c (make_canon_sexp): New. 2009-03-03 Werner Koch * exechelp.c (do_exec): Make sure that /dev/null connected FDs are not closed. 2009-01-19 Werner Koch * audit.c (writeout_li): Translate a few more result strings. Fixes bug#970. * convert.c (hex2str): Fix optimization to append a nul character. 2008-12-05 Werner Koch * percent.c, t-percent.c: New. * exechelp.c (gnupg_spawn_process, gnupg_spawn_process_fd) (gnupg_spawn_process_detached) [W32]: Remove debug output. 2008-11-20 Werner Koch * audit.c (writeout_li): Translate OKTEXT. 2008-11-04 Werner Koch * i18n.c (i18n_init) [USE_SIMPLE_GETTEXT]: Adjust for changed w32-gettext.c. * homedir.c (gnupg_localedir): New. 2008-10-20 Werner Koch * http.c (http_register_tls_callback) [!HTTP_USE_GNUTLS]: Mark unused arg. * localename.c (do_nl_locale_name): Ditto. * audit.c (event2str): Silent gcc warning. * sysutils.c (translate_sys2libc_fd): Mark unused arg. (translate_sys2libc_fd_int): Ditto. * iobuf.c (translate_file_handle): Ditto. * asshelp.c (send_one_option): Ditto. * exechelp.c (gnupg_spawn_process): Ditto. * signal.c (got_usr_signal): Ditto * estream.c (es_func_fd_create) [!W32]: Ditto. (es_func_fp_create) [!W32]: Ditto. (es_write_hexstring): Ditto. (dummy_mutex_call_void, dummy_mutex_call_int) [HAVE_PTH]: New. (ESTREAM_MUTEX_LOCK, ESTREAM_MUTEX_UNLOCK, ESTREAM_MUTEX_TRYLOCK) (ESTREAM_MUTEX_INITIALIZE) [HAVE_PTH]: Use dummy calls so to mark unused arg. 2008-10-19 Werner Koch * estream-printf.c (estream_vsnprintf): Fix return value. (check_snprintf): Add a new test. (one_test) [W32]: Disable test. 2008-10-17 Werner Koch * util.h (snprintf) [W32]: Redefine to estream_snprintf. 2008-09-03 Werner Koch * convert.c (hex2str): New. (hex2str_alloc): New. * t-convert.c (test_hex2str): New. 2008-08-19 Werner Koch * iobuf.c: Avoid passing a NULL (iobuf_t)->desc to the log function. Should in general never be NULL, but well. Reported by M. Heneka. 2008-06-26 Werner Koch * estream.c (es_write_sanitized): Loose check for control characters to better cope with utf-8. The range 0x80..0x9f is nowadays not anymore accidently used for control charaters. 2008-06-25 Marcus Brinkmann Revert last three changes related to handle translation. * sysutils.c: (FD_TRANSLATE_MAX, fd_translate, fd_translate_len) (translate_table_init, translate_table_lookup): Removed. * iobuf.c (check_special_filename): Do not use translate_table_lookup. * sysutils.h (translate_table_init, translate_table_lookup): Remove prototypes. 2008-06-19 Werner Koch * sysutils.c: Remove . (fd_translate_max): Use macro for the size. (translate_table_init): Protect read against EINTR and replace isspace by spacep. 2008-06-18 Marcus Brinkmann * sysutils.c (TRANS_MAX): Bump up to 350 to be on the safe side. * sysutils.h (translate_table_init, translate_table_lookup): New prototypes. * sysutils.c: Include . (FD_TRANSLATE_MAX): New macro. (fd_translate, fd_translate_len): New static variables. (translate_table_init, translate_table_lookup): New functions. (translate_sys2libc_fd_int): Translate file descriptor. * iobuf.c (check_special_filename): Translate handle values from special filenames. 2008-06-16 Werner Koch * homedir.c (w32_commondir): New. (gnupg_sysconfdir): Use it. 2008-06-09 Werner Koch * b64dec.c: New. 2008-06-05 Werner Koch * util.h (gnupg_copy_time): Replace strcpy by memcpy. 2008-05-26 Werner Koch * asshelp.c (send_one_option, send_pinentry_environment): use xfree and xtrystrdup. * i18n.c (i18n_switchto_utf8) [USE_SIMPLE_GETTEXT]: Return NULL. * homedir.c (gnupg_module_name): Add GNUPG_MODULE_NAME_CONNECT_AGENT and GNUPG_MODULE_NAME_GPGCONF. 2008-04-21 Werner Koch * http.c (http_wait_response) [W32]: Use DuplicateHandle because it is a socket. (cookie_read) [W32]: Use recv in place of read. 2008-04-08 Werner Koch * i18n.c (i18n_switchto_utf8, i18n_switchback) [USE_SIMPLE_GETTEXT]: Implement. 2008-04-07 Werner Koch * b64enc.c (b64enc_start): Detect PGP mode. (b64enc_finish): Write PGP CRC. * util.h (struct b64state): Add field CRC. * t-b64.c: New. * pka.c (get_pka_info): Use xtrymalloc and check result. 2008-03-25 Werner Koch * localename.c: Strip all W32 code. Include w32help.h. (gnupg_messages_locale_name) [W32]: Use the gettext_localename. 2008-03-17 Werner Koch * iobuf.c (IOBUF_BUFFER_SIZE): Actually use this macro. * simple-pwquery.c (agent_send_all_options): Fix last change. 2008-03-06 Werner Koch * simple-pwquery.c (agent_send_all_options): Add support for XAUTHORITY and PINENTRY_USER_DATA. 2008-02-15 Marcus Brinkmann * exechelp.c (gnupg_spawn_process_fd): Add flag DETACHED_PROCESS unconditionally (required for all callers at the moment). 2008-02-14 Werner Koch * sysutils.c (gnupg_allow_set_foregound_window): New. (WINVER) [W32]: Define. 2008-01-31 Werner Koch * audit.c (audit_print_result): Make sure that the output is always UTF8. 2008-01-27 Werner Koch * exechelp.c (gnupg_spawn_process): Add arg FLAGS and changed all callers to pass 0 for it. 2007-12-13 Werner Koch * sexputil.c (hash_algo_from_sigval): New. * t-sexputil.c: New. * Makefile.am (module_tests): Add it. 2007-12-11 Werner Koch * asshelp.c (send_pinentry_environment): Allow using of old gpg-agents not capabale of the xauthority and pinentry_user_data options. 2007-12-04 Werner Koch * Makefile.am (t_helpfile_LDADD, module_maint_tests): New. * t-helpfile.c: New. * helpfile.c: New. * membuf.h (is_membuf_ready, MEMBUF_ZERO): New. * localename.c: New. Taken from gettext with modifications as done for GpgOL. Export one new function. * util.h (gnupg_messages_locale_name, gnupg_get_help_string): Added. * sysutils.c (gnupg_reopen_std): New. Taken from ../g10/gpg.c. 2007-11-27 Werner Koch * Makefile.am (CLEANFILES): New. * homedir.c (dirmngr_socket_name): Use CSIDL_WINDOWS. 2007-11-15 Werner Koch * asshelp.c (send_pinentry_environment): Add args XAUTHORITY and PINENTRY_USER_DATA. (start_new_gpg_agent): Ditto. 2007-11-07 Werner Koch * status.h: New. * errors.h: Remove. 2007-11-05 Werner Koch * audit.c, audit.h: New. * Makefile.am: Add rules to build audit-events.h. * exaudit.awk: New. * mkstrtable.awk: New. Taken from libgpg-error. 2007-10-19 Werner Koch * i18n.c (i18n_switchto_utf8, i18n_switchback): New. 2007-10-01 Werner Koch * sysutils.h (FD2INT, INT2FD): New. 2007-09-21 Werner Koch * homedir.c (default_homedir): Make registry work. Reported by Marc Mutz. 2007-08-29 Werner Koch * exechelp.c (gnupg_wait_process): Add arg EXITCODE. Changed all callers. (gnupg_create_inbound_pipe): New. * util.h (GNUPG_MODULE_NAME_GPGSM, GNUPG_MODULE_NAME_GPG): New. * homedir.c (gnupg_module_name): Add them 2007-08-28 Werner Koch * gettime.c (check_isotime, add_isotime): New. Originally written for DirMngr by me. (add_days_to_isotime): New. (date2jd, jd2date, days_per_month, days_per_year): New. Taken from my ancient (1988) code used in Wedit (time2.c). 2007-08-27 Werner Koch * util.h (GNUPG_MODULE_NAME_CHECK_PATTERN): New. * homedir.c (gnupg_module_name): Add it. * exechelp.c (w32_fd_or_null) [W32]: New. (gnupg_spawn_process_fd): New. (gnupg_wait_process) [W32]: Close the handle after if the process has returned. 2007-08-22 Werner Koch Updated estream from libestream. * estream.c (mem_malloc, mem_realloc, mem_free): New. Use them instead of the ES_MEM_foo. * estream.c (estream_cookie_mem): Remove members DONT_FREE, APPEND_ZERO, PTR and SIZE. Add MEMORY_LIMIT. Put GROW into a new FLAGS struct. (es_func_mem_create): Remove APPEND_ZERO, DONT_FREE, PTR and SIZE. Add MEMORY_LIMIT. (es_func_mem_write, es_func_mem_seek, es_func_mem_destroy): Revamp. (es_open_memstream): Change API to just take a memory limit and a mode argument. Rename to .. (es_fopenmem): .. this. (HAVE_W32_SYSTEM) [_WIN32]: Define if not defined. (tmpfd) [W32]: Implement directly using the W32 API. (es_fgets): Rewrite without using doreadline. 2007-08-21 Werner Koch * sysutils.c (gnupg_tmpfile): New. * t-sysutils.c: New. * Makefile.am (module_tests): Add t-sysutils. 2007-08-20 Werner Koch * exechelp.c [W32]: Redefine X_OK to F_OK. 2007-08-16 Werner Koch * Makefile.am (t_convert_DEPENDENCIES): Remove ($(PROGRAMS)): Remove. (t_common_ldadd): Use libcommon.a and not the macro. 2007-08-14 Werner Koch * homedir.c (dirmngr_socket_name): New. 2007-08-07 Werner Koch * tlv.c, tlv.h: Move from ../scd/. * tlv.c (parse_sexp, parse_ber_header): Add ERRSOURCE arg and prefix name with a _. * tlv.h: Use macro to convey ERRSOURCE. 2007-08-02 Werner Koch * gc-opt-flags.h: New. 2007-08-01 Werner Koch * estream-printf.c (read_dummy_value): Removed as it is useless now. (read_values): Remove check on !vaargs which is not anymore needed and anyway not portable. Reported by Peter O'Gorman. 2007-07-16 Werner Koch * estream.c (es_func_file_create): Clear NO_CLOSE flag. 2007-07-12 Werner Koch * sysutils.h (gnupg_fd_t): New. * sysutils.c (translate_sys2libc_fd): Use that type instead of int. (translate_sys2libc_fd_int): New. 2007-07-09 Werner Koch * t-gettime.c (test_isotime2epoch): Use time_t and not u32. 2007-07-05 Werner Koch * t-gettime.c: New. * gettime.c (isotime2epoch, epoch2isotime): New. 2007-07-04 Werner Koch * estream.c (es_init_do): Do not throw an error if pth has already been initialized. 2007-06-26 Werner Koch * Makefile.am ($(PROGRAMS)): New. * util.h (init_common_subsystems): Moved to .. * init.h: .. New. * util.h: Include init.h. * homedir.c (standard_homedir): New. (default_homedir) [W32]: Reimplemented in terms of standard_homedir. Fixed memory leak. 2007-06-25 Werner Koch * iobuf.c: Add more documentation and slighly restructured macro defintion for better readability. (FILEP_OR_FD): Rename to fp_or_fd_t. (CLOSE_CACHE): Rename to close_cache_t. * sysutils.c (translate_sys2libc_fd): New using the code from iobuf.c. * iobuf.c: Include sysutils.h. (iobuf_translate_file_handle): Remove. (translate_file_handle): Use new function. * estream-printf.c [TEST]: Header including fixes. (do_format): Do not append a trailing Nul. This avoids spurious Nuls in the es_printf output. (estream_vsnprintf, estream_vasprintf): Take this in account. * estream.h (struct es__stream): Change FLAGS to a bit structure. (ES__FLAG_WRITING): Replace by a bit from FLAGS. * estream.c (struct estream_internal): Rename FLAGS to MODEFLAGS so that they are not confused with the estream flags. (es_initialize, es_create): Add arg MODEFLAGS so that we can setup the intial writemode. Changed all callers to pass them. (es_convert_mode): Set O_BINARY. (es_func_fd_create, es_func_fp_create, es_func_file_create) [W32]: Call setmode if requested. 2007-06-24 Werner Koch * estream.c (do_fpopen, es_fpopen, es_fpopen_nc): New. (es_func_fp_create, es_func_fp_read, es_func_fp_write) (es_func_fp_seek, es_func_fp_destroy): New. 2007-06-22 Werner Koch * estream.c (es_fdopen): Factored code out to.. (do_fdopen): .. new. (es_fdopen_nc): New. (estream_cookie_fd): Add field NO_CLOSE. (es_func_fd_create): Add arg NO_CLOSE and changed all callers. (es_func_fd_destroy): Handle the new flag. * homedir.c (gnupg_libexecdir) [W32]: Factor code out to .. (w32_rootdir): .. new. (gnupg_sysconfdir, gnupg_libdir, gnupg_datadir) [W32]: Return name based on w32_rootdir(). 2007-06-21 Werner Koch * membuf.h (get_membuf_len): New. * membuf.c (init_membuf_secure): Really allocate in secure memory. (put_membuf_str): New. * ttyio.c (tty_getf): New. * util.h (ctrl_t): Declare it here. * asshelp.c (start_new_gpg_agent): New. Based on code from ../sm/call-agent.c 2007-06-20 Werner Koch * sysutils.c (gnupg_sleep): New. * sysutils.h [W32]: Remove _sleep wrapper. Changed all callers to use gnupg_sleep. * exechelp.c (build_w32_commandline_copy): New. (build_w32_commandline): Factored some code out to new function and correctly process a PGMNAME with spaces. (gnupg_spawn_process_detached) [W32]: Implement. 2007-06-14 Werner Koch * simple-pwquery.h (MAP_SPWQ_ERROR_IMPL): New. (SPWQ_NO_PIN_ENTRY): New. * simple-pwquery.c (simple_pw_set_socket): New. (agent_open): Use it if GPG_AGENT_INFO is not set. (simple_pwquery): Extended to allow returning of otehyr error codes. * util.h (GNUPG_MODULE_NAME_AGENT, GNUPG_MODULE_NAME_PINENTRY) (GNUPG_MODULE_NAME_SCDAEMON, GNUPG_MODULE_NAME_DIRMNGR) (GNUPG_MODULE_NAME_PROTECT_TOOL): New. * homedir.c (gnupg_module_name): New. (gnupg_bindir): New. 2007-06-12 Werner Koch * homedir.c (gnupg_sysconfdir): New. (gnupg_libexecdir): New. Taken from g10/misc.c:get_libexecdir. (gnupg_datadir): New. (gnupg_libdir): New. * http.c (connect_server) [W32]: Do not call init_sockets if HTTP_NO_WSASTARTUP is defined. * init.c: New. * estream.c (es_init_do): Init stream lock here because we can't use a static initialization with W32pth. 2007-06-11 Werner Koch * Makefile.am (t_common_ldadd): Use libcommonstd macro. 2007-06-06 Werner Koch * Makefile.am: Include am/cmacros.am. * sysutils.h [W32]: Remove prototypes for the registry access. * w32reg.c: Move to ../jnlib/w32-reg.c. * i18n.c (i18n_init): New. * simple-gettext.c: Remove. * iobuf.c (iobuf_get_filelength): Rename SIZE to EXSIZE to silent shadowing warning. 2007-06-04 Werner Koch * http.c [W32]: Include unistd.h also in this case. (write_server) [W32]: Fixed error code. (init_sockets): Fixed syntax error. (cookie_close): Replace close by sock_close macro. * estream.c [w32]: Do not init Mutex. * Makefile.am (common_sources) [USE_SNS_SRV]: Build srv.c only when needed. * ttyio.c (init_ttyfp) [W32]: Do not use TTYFP. * util.h: Include ../jnlib/dynload.h. * dynload.h: Move to ../jnlib. 2007-05-30 Werner Koch * estream.c (MEM_FREE, MEM_ALLOC, MEM_REALLOC): Prefix with ES_ as windows.h also has such definitions, 2007-05-15 Werner Koch * util.h: Do not include gnulib's vasprintf. Redefine asprintf and vasprintf. * xasprintf.c (xasprintf, xtryasprintf): Use estream_vasprintf. * estream-printf.h, estream-printf.c: New. Taken from current libestream SVN. * Makefile.am (common_sources): Add them. 2007-05-14 Werner Koch * sexp-parse.h (smklen): New. * sexputil.c: Include sexp-parse.h. (make_simple_sexp_from_hexstr): Replace sprintf by smklen. 2007-05-07 Werner Koch * signal.c (got_fatal_signal): Protect SIG from being clobbered by a faulty signal implementaion. Suggested by James Juran. 2007-04-25 Werner Koch * i18n.h (ngettext): New. * simple-gettext.c (ngettext): New. 2007-04-20 Werner Koch * miscellaneous.c (my_gcry_logger, my_gcry_outofcore_handler): Moved from gpg-agent to here. (my_gcry_fatalerror_handler): new. (setup_libgcrypt_logging): New. 2007-03-19 Werner Koch * miscellaneous.c (print_hexstring): New. * estream.c (es_fprintf_unlocked): New. (es_write_sanitized): New. (es_write_hexstring): New. (es_write_sanitized_utf8_buffer) [GNUPG_MAJOR_VERSION]: New. 2007-03-09 David Shaw From STABLE-BRANCH-1-4 * http.c (do_parse_uri): Remove the hkp port 11371 detection. We implement hkp in the keyserver handler, and the support here makes it appear like a bad hkp request actually succeeded. 2007-01-31 Werner Koch * Makefile.am (t_common_ldadd): Add LIBINCONV and LIBINTL. 2007-01-25 Werner Koch * simple-pwquery.c (simple_pwquery): New arg OPT_CHECK. 2006-12-13 David Shaw * Makefile.am (AM_CPPFLAGS): Include intl/ so we can reference the built-in headers. 2006-11-23 Werner Koch * http.c: Include i18n.h 2006-11-21 Werner Koch * estream.c: Remove explicit Pth soft mapping diabling becuase it is now done in config.h. 2006-11-15 Werner Koch * estream.c: Disabled Pth soft mapping. (my_funopen_hook_ret_t): New. (print_fun_writer): Use it here. * iobuf.c (fd_cache_close): Use %d instead of %p for debug output. 2006-11-03 Werner Koch * Makefile.am (t_convert_DEPENDENCIES): Add libcommon. From Gentoo. 2006-10-24 Marcus Brinkmann * Makefile.am (libcommon_a_CFLAGS): Add $(LIBASSUAN_CFLAGS). (libsimple_pwquery_a_CFLAGS): New variable. 2006-10-20 Werner Koch * convert.c (hex2bin): New. 2006-10-17 Werner Koch * estream.c (struct estream_internal, es_initialize) (es_deinitialize, print_fun_writer, es_print): New and modified functions to avoid tempfiles for printf style printing. * Makefile.am (libcommonpth_a_SOURCES): New. We now build a secon version of the library with explicit Pth support. * exechelp.c, estream.c: Make use of WITHOUT_GNU_PTH. 2006-10-08 Werner Koch * gpgrlhelp.c: Trun all functions into dummies if readline is not available. 2006-10-06 Werner Koch * Makefile.am (AM_CFLAGS): Use PTH version of libassuan. * util.h (GNUPG_GCC_A_SENTINEL): Defined for gcc >= 4. 2006-10-04 David Shaw * gpgrlhelp.c: readline requires stdio.h. 2006-10-04 Werner Koch * membuf.c (init_membuf_secure): New. (put_membuf): Make sure that ERRNO is set even if the underlying malloc code does not work properly. (get_membuf): Set ERRNO on error. (get_membuf): Allow to pass LEN as NULL. 2006-10-02 Werner Koch * iobuf.c (iobuf_unread): Removed. This code is not required. Also removed the entire unget buffer stuff. 2006-09-27 Werner Koch * util.h: Do not include strsep.h and strpbrk.h. (isascii): Removed as it is now in jnlib. * iobuf.c (pop_filter, underflow, iobuf_close): Free the unget buffer. 2006-09-27 Florian Weimer (wk) * iobuf.c (iobuf_unread): New. 2006-09-22 Werner Koch * i18n.h: Changed license to an all permissive one. * ttyio.c (tty_get): We need to use readline too. Added two more hooks. 2006-09-21 Werner Koch * ttyio.c (tty_private_set_rl_hooks): New. (tty_enable_completion, tty_disable_completion): Use a hook to enable readline support. Now always available. (tty_cleanup_rl_after_signal): New. * ttyio.h: Removed readline specific stuff. Included util.h. * common-defs.h: New. 2006-09-15 Werner Koch * convert.c: New. (hexcolon2bin): New. (bin2hex, bin2hexcolon, do_binhex): New. * t-convert.c: New 2006-09-14 Werner Koch * util.h (out_of_core): Use new gpg_error_from_syserror function. * http.c (init_sockets): Changed it to require 2.2 unless it is build within gnupg 1 where we require 1.1 (and not anymore allow for 1.0). 2006-09-07 Werner Koch * exechelp.c (gnupg_spawn_process): Factor out post fork code to .. (do_exec): .. new function. Allow passing of -1 for the fds. (gnupg_spawn_process): Terminate gcrypt's secure memory in the child. (gnupg_spawn_process_detached): New. 2006-09-06 Werner Koch * maperror.c: Removed. * util.h (out_of_core): New. 2006-09-04 Werner Koch * http.c (http_get_header): New. (capitalize_header_name, store_header): New. (parse_response): Store headers away. (send_request): Return GPG_ERR_NOT_FOUND if connect_server failed. * http.h: New flag HTTP_FLAG_NEED_HEADER. 2006-08-21 Werner Koch * Makefile.am (libcommon_a_SOURCES): Added keyserver.h * openpgpdefs.h: New. Stripped from ..g10/packet.h. 2006-08-16 Werner Koch * keyserver.h: Moved from ../include to here. * http.c: Include srv.h. * srv.c, srv.h: New. Taken from GnuPG 1.4 2006-08-14 Werner Koch * http.h (struct http_context_s): Moved to implementation. * http.c (http_open): Changed call to return a context. (http_open_document): Ditto. (http_get_read_ptr, http_get_read_ptr, http_get_status_code): New. (do_parse_uri): Replaced strlwr by straight code to ease standalone use of this file. (http_wait_response): Removed arg STATUS_CODE as it is available through an accessor function. Adjusted caller. (http_escape_string): New. * estream.c (es_read_line): Renamed to .. (doreadline): .. this. Changed all callers. (es_read_line): New. This is theusual limited getline variabnt as used at several places. Here taken and adjusted from xreadline.c (es_free): New. 2006-08-11 Werner Koch * http.c: Major internal changes to optionallly support GNUTLS and ESTREAM. (http_open): Move initialization of the stream ... (send_request): .. here. (http_register_tls_callback): New. * estream.c (es_writen): Try to seek only is a seek function has been registered. 2006-08-09 Werner Koch * http.c, http.h: New. Taken from gnupg 1.4.5, merged with changes done for the Dirmngr project (by g10 Code) and cleaned up some stuff. (make_header_line): New. Change all caller to make user of the new * Makefile.am (libcommon_a_SOURCES): Added http.c and http.h. 2006-05-23 Werner Koch * gettime.c (isotimestamp): New. * ttyio.c (tty_get_ttyname): Posixly correct usage of ctermid. * dns-cert.c: New. Taken from 1.4.3's util/cert.c. * dns-cert.h: New. 2006-05-22 Werner Koch * pka.c: New. Taked from 1.4.3. * pka.h: New. * Makefile.am: Added pka. 2006-05-19 Werner Koch * yesno.c (answer_is_yes_no_default, answer_is_yes_no_quit): Updated from 1.4.3. (answer_is_okay_cancel): new. From 1.4.3. * miscellaneous.c (match_multistr): New. Taken from 1.4.3. * ttyio.c (tty_enable_completion, tty_disable_completion): New dummy functions. * ttyio.h: Add prototypes and stubs. 2006-04-19 Werner Koch * iobuf.c (iobuf_get_fd): New. Taken from 1.4.3. (iobuf_is_pipe_filename): New. (pop_filter): Made static. (iobuf_skip_rest): New. Orginal patch by Florian Weimer. Added new argument PARTIAL. (block_filter): Remove the old gpg indeterminate length mode. (block_filter): Properly handle a partial body stream that ends with a 5-byte length that happens to be zero. (iobuf_set_block_mode, iobuf_in_block_mode): Removed as superfluous. (iobuf_get_filelength): New arg OVERFLOW. (iobuf_get_filelength) [W32]: Use GetFileSizeEx if available * miscellaneous.c (is_file_compressed): Take care of OVERFLOW. 2006-04-18 Werner Koch * homedir.c (w32_shgetfolderpath): New. Taken from gpg 1.4.3. (default_homedir): Use it. 2005-10-08 Marcus Brinkmann * signal.c (get_signal_name): Check value of HAVE_DECL_SYS_SIGLIST instead of just if it is defined. 2005-09-28 Marcus Brinkmann * Makefile.am (AM_CFLAGS): Add $(LIBASSUAN_CFLAGS). 2005-07-04 Marcus Brinkmann * simple-pwquery.h (simple_pwclear): New prototype. * simple-pwquery.c (simple_pwclear): New function. 2005-06-15 Werner Koch * miscellaneous.c (make_printable_string): Made P a void*. * sexputil.c (keygrip_from_canon_sexp, cmp_simple_canon_sexp): Fixed signed/unsigned pointer mismatch. (make_simple_sexp_from_hexstr): Ditto. This is all too ugly; I wonder why gcc-4's default is to warn about them and forcing us to use cast the warning away. * iobuf.c (block_filter): Ditto. (iobuf_flush): Ditto. (iobuf_read_line): Ditto. (iobuf_read): Make BUFFER a void *. (iobuf_write): Make BUFFER a const void *. * ttyio.c (tty_print_utf8_string2): Ditto. * estream.c (estream_cookie_mem): Make MEMORY unsigned char*. (es_write): Make BUFFER a void *. (es_writen): Ditto. (es_func_fd_read, es_func_fd_write, es_func_mem_read) (es_func_mem_write): Ditto. (es_read, es_readn): Ditto. (es_func_mem_write): Made MEMORY_NEW an unsigned char *. * estream.h (es_cookie_read_function_t) (es_cookie_write_function_t): Changed buffer arg to void*. 2005-06-03 Werner Koch * estream.c: Use HAVE_CONFIG_H and not USE_CONFIG_H! (es_func_fd_read, es_func_fd_write): Protect against EINTR. 2005-06-01 Werner Koch * Makefile.am (AM_CPPFLAGS): Added. * util.h: Add some includes for gnulib. (ttyname, isascii): Define them inline. * fseeko.c, ftello.c: Removed. * strsep.c, mkdtemp.c: Removed. * ttyname.c, isascii.c: Removed. 2005-05-31 Werner Koch * dynload.h: s/__inline__/inline/. 2005-05-13 Werner Koch * signal.c (got_fatal_signal): Print the signal number if we can't get a name for it. (get_signal_name): Return NULL if no name is available. Fixed conditional for sys_siglist to the correct one. 2005-04-17 Werner Koch * sexputil.c (cmp_simple_canon_sexp): New. (make_simple_sexp_from_hexstr): New. 2005-04-07 Werner Koch * sexputil.c: New. 2005-04-11 Marcus Brinkmann * simple-pwquery.c (simple_pwquery): Use spwq_secure_free. 2005-03-03 Werner Koch * Makefile.am (AM_CFLAGS): Added PTH_CFLAGS. Noted by Kazu Yamamoto. 2005-02-25 Werner Koch * xasprintf.c (xtryasprintf): New. 2005-01-26 Moritz Schulte * Makefile.am (libcommon_a_SOURCES): New source files: estream.c, estream.h. * estream.c, estream.h: New files. 2005-01-03 Werner Koch * asshelp.c (send_pinentry_environment): Fixed changed from 2004-12-18; cut+paste error for lc-messages. 2004-12-21 Werner Koch * simple-pwquery.c (agent_open) [W32]: Implement for W32. (readline) [W32]: Use recv instead of read. (writen) [W32]: Use send instead of write. (my_stpcpy): Define a stpcpy replacement so that this file continues to be self-contained. (agent_send_all_options) [W32]: Don't call ttyname. 2004-12-21 Marcus Brinkmann * simple-pwquery.h (simple_query): Add prototype. * simple-pwquery.c (simple_query): New function. 2004-12-21 Werner Koch * signal.c (got_fatal_signal, got_usr_signal) (got_fatal_signal) [DOSISH]: Don't build. * simple-gettext.c: Include sysutils.h * homedir.c: New. Use CSIDL_APPDATA for W32 as the default home directory. * Makefile.am (libcommon_a_SOURCES): Add it. (EXTRA_DIST): Removed mkerror and mkerrtok. 2004-12-20 Werner Koch * sysutils.h [W32]: Define sleep. * util.h: Add prototype for mkdtemp. * membuf.c (put_membuf): Wipe out buffer after a failed realloc. 2004-12-19 Werner Koch * maperror.c (map_assuan_err_with_source): Oops, args were swapped. 2004-12-18 Werner Koch * maperror.c (map_assuan_err): Renamed to .. (map_assuan_err_with_source): .. this and add arg SOURCE.c * asshelp.c (send_pinentry_environment, send_one_option): Add arg ERRSOURCE. 2004-12-15 Werner Koch * sysutils.h [W32]: Prototypes for registry functions. * w32reg.c: Include sysutils.h * simple-pwquery.c [W32]: Dummy code to allow a build. * exechelp.c [W32]: Implemented for W32 . * ttyname.c: New. * asshelp.c (send_one_option): New. (send_pinentry_environment): Cleaned up and made sure that empty values are not send. 2004-12-07 Werner Koch * asshelp.c (send_pinentry_environment) [W32]: Do not use ttyname. 2004-12-06 Werner Koch * exechelp.h, exechelp.c: New. Based on code from ../sm/import.c. 2004-12-03 Werner Koch * strsep.c: Fixed copyright comments. 2004-11-26 Werner Koch * simple-gettext.c: New taken from gnupg 1.3.x * simple-pwquery.c [_WIN32]: Include winsock2.h. (agent_open): Disable it until we have our AF_UNIX implementation ready. * fseeko.c, ftello.c: Include sys/types for the sake of W32. 2004-11-23 Werner Koch * b64enc.c: Include stdio.h and string.h 2004-08-18 Werner Koch * simple-pwquery.c (simple_pwquery): Handle gpg-error style return code for canceled. 2004-07-20 Werner Koch * maperror.c: Removed header ksba.h. Not required anymore. 2004-06-14 Werner Koch * xreadline.c: New. Based on the iobuf_read_line function. 2004-05-12 Werner Koch * util.h (xtrycalloc_secure,xtrymalloc_secure): New. 2004-05-11 Werner Koch * sysutils.c (disable_core_dumps): Only set the current limit. (enable_core_dumps): New. 2004-04-13 Werner Koch * simple-pwquery.c (copy_and_escape): Relaxed quoting. 2004-04-05 Werner Koch * errors.h (STATUS_NEWSIG): New. 2004-03-11 Werner Koch * dynload.h [__MINGW32__]: Define RTLD_LAZY. 2004-03-09 Werner Koch * maperror.c (map_assuan_err): Map the Locale_Problem item. 2004-03-03 Werner Koch * asshelp.c, asshelp.h: New. (send_pinentry_environment): New. Code taken from ../sm/call-agent.c. 2004-02-19 Werner Koch * simple-pwquery.c (agent_open): Don't mangle INFOSTR. 2004-02-17 Werner Koch * simple-pwquery.c (agent_open): Ignore an empty GPG_AGENT_INFO. * errors.h: Added STATUS_IMPORT_OK. 2004-02-10 Werner Koch * b64enc.c: New. Based on code from ../sm/base64.c. 2004-01-30 Marcus Brinkmann * Makefile.am (libcommon_a_SOURCES): Add xasprintf.c. * miscellaneous.c (xasprintf): Moved to ... * xasprintf (xasprintf): ... here. New file. This allows to use xasprintf without sucking in gpg-error. 2004-01-27 Werner Koch * sexp-parse.h: New; moved from../agent. * util.h (xtoi_4): New. 2003-12-23 Werner Koch * maperror.c (map_assuan_err): Prepared for a new error code. 2003-12-17 Werner Koch * gettime.c (asctimestamp): Add a note on a non-avoidable gcc warning. * util.h [!HAVE_VASPRINTF]: Add printf format attribute to the replacement function. * miscellaneous.c (xasprintf): New. 2003-11-14 Werner Koch * mkdtemp.c (mkdtemp): Use gcry_create_nonce. * cryptmiss.c: Removed. 2003-11-13 Werner Koch * util.h (vasprintf): Also fixed the prototype. * vasprintf.c (vasprintf): ARGS should not be a pointer. Fixed segv on Solaris. Reported by Andrew J. Schorr. 2003-11-12 Werner Koch * maperror.c (map_ksba_err, map_gcry_err, map_kbx_err): Removed. 2003-10-31 Werner Koch * util.h (gnupg_isotime_t): New. (gnupg_copy_time): New. * gettime.c (gnupg_get_isotime): New. 2003-09-23 Werner Koch * iobuf.c (check_special_filename): Replaced is isdigit by digitp to avoid passing negative values and potential locale problems. Problem noted by Christian Biere. * util.h (ascii_isspace): New. 2003-09-18 Werner Koch * ttyio.c (tty_fprintf): New. (tty_print_string, tty_print_utf8_string2) (tty_print_utf8_string): Made P argument const byte*. 2003-08-20 Marcus Brinkmann * maperror.c (map_ksba_err): Map -1. Use gpg_err_make to set the error source. 2003-08-14 Timo Schulz * dynload.h. New. W32 wrapper around the dynload mechanism. 2003-07-15 Werner Koch * simple-pwquery.c, simple-pwquery.h: New; moved from ../agent. * Makefile.am (libsimple_pwquery_a_LIBADD): New. 2003-06-25 Werner Koch * maperror.c (map_to_assuan_status): Directly map 0 to 0. 2003-06-17 Werner Koch * gettime.c (scan_isodatestr,add_days_to_timestamp,strtimevalue) (strtimestamp,asctimestamp): New. Code taken from gnupg 1.3.2 mischelp.c. * yesno.c: New. Code taken from gnupg 1.3.2 mischelp.c * miscellaneous.c: New. * util.h: Include utf8conf.h 2003-06-16 Werner Koch * gettime.c (make_timestamp): New. * ttyio.c: New. Taken from gnupg 1.2. * ttyio.h: Move from ../include. 2003-06-13 Werner Koch * util.h (seterr): Removed macro. (xmalloc_secure,xcalloc_secure): New. 2003-06-11 Werner Koch * iobuf.c (iobuf_writebyte,iobuf_write): Return error code from iobuf_flush. (iobuf_writestr): Ditto. 2003-06-10 Werner Koch * iobuf.c, iobuf.h: New. Taken from current gnupg 1.3 CVS. Run indent on it and adjusted error handling to libgpg-error style. Replaced IOBUF by iobuf_t. Renamed malloc functions. 2003-06-04 Werner Koch * errors.h: Removed all error codes. We keep the status codes for now. * Makefile.am: Do not create errors.c anymore; remove it from the sources. * maperror.c: Don't include error.h. Change all error codes to libgpg-error style. (map_assuan_err): Changed to new Assuan error code convention. (map_to_assuan_status): Likewise. (map_gcry_err,map_kbx_err): Not needed. For now dummy functions. * membuf.c, membuf.h: New. Code taken from ../sm/call-agent.h. * Makefile.am: Added above. 2003-04-29 Werner Koch * util.h (fopencokokie): Removed prototype and struct. * fopencookie.c: Removed. * maperror.c: Use system assuan.h 2002-10-31 Neal H. Walfield * isascii.c: New file. * putc_unlocked.c: Likewise. 2002-10-28 Neal H. Walfield * signal.c (caught_fatal_sig): Remove superfluous zero initializer. (caught_sigusr1): Likewise. 2002-09-04 Neal H. Walfield * vasprintf.c (vasprintf) [va_copy]: Use va_copy. [!va_copy && __va_copy]: Use __va_copy. [!va_copy && !__va_copy]: Only now fall back to using memcpy. 2002-08-21 Werner Koch * errors.h: Added STATUS_IMPORT_PROBLEM. 2002-08-20 Werner Koch * vasprintf.c: Hack to handle NULL for %s. 2002-08-09 Werner Koch * signal.c: New. Taken from GnuPG 1.1.91. 2002-07-23 Werner Koch * util.h (_IO_cookie_io_functions_t): Fixed typo. Noted by Richard Lefebvre. 2002-07-22 Werner Koch * fseeko.c, ftello.c: New. 2002-06-28 Werner Koch * maperror.c (map_to_assuan_status): Map more errorcodes to Bad Certificate. 2002-06-26 Werner Koch * maperror.c (map_to_assuan_status): Map EOF to No_Data_Available. 2002-06-10 Werner Koch * errors.h (gnupg_error_token): Add new prototype. (STATUS_ERROR): New. * mkerrtok: New. * Makefile.am: Use it to create the new error token function. 2002-06-04 Werner Koch * maperror.c (map_to_assuan_status): Map Bad_CA_Certificate. 2002-05-23 Werner Koch * no-pth.c, Makefile.am: Removed. 2002-05-22 Werner Koch * mkdtemp.c: Replaced byte by unsigned char because it is no longer defined in gcrypt.h. 2002-05-21 Werner Koch * maperror.c (map_gcry_err): Add libgcrypt's new S-expression errors. (map_ksba_err): Add a few mappings. 2002-05-14 Werner Koch * gettime.c: New. 2002-05-03 Werner Koch * errors.h: Added STARUS_EXPSIG and STATUS_EXPKEYSIG. 2002-04-15 Werner Koch * cryptmiss.c: New. 2002-02-14 Werner Koch * maperror.c: Add more assuan<->gnupg mappings. 2002-02-12 Werner Koch * fopencookie.c: Dummy function. * vasprintf.c: New. Taken from binutils-2.9.1 and dropped all non ANSI-C stuff. Merged with asprintf version. * no-pth.c: New. 2002-01-23 Werner Koch * mkdtemp.c: Copied from gnupg-1.0.6c and changed to use libgcrypt. 2002-01-19 Werner Koch * sysutils.c: New. This is the misc.c file from gnupg 1.0.6 with the OpenPGP stuff removed. * sysutils.h: New. 2002-01-15 Werner Koch * maperror.c: Add mapping for Not_Trusted. 2002-01-11 Werner Koch * maperror.c (map_assuan_err): Codes for CRL 2002-01-08 Werner Koch * util.h (spacep): New. 2002-01-02 Werner Koch * maperror.c (map_to_assuan_status): New. Merged from ../agent and ../sm. 2001-12-20 Werner Koch * maperror.c (map_gcry_err): Add some mappings. 2001-12-18 Werner Koch * Makefile.am (AM_CPPFLAGS): Include flags for gcrypt and ksba 2001-12-14 Werner Koch * util.h (digitp, hexdigitp): New ctype like macros. (atoi_1,atoi_2,atoi_4,xtoi_1,xtoi_2): New. Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 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/jnlib/ChangeLog b/common/ChangeLog.jnlib similarity index 97% rename from jnlib/ChangeLog rename to common/ChangeLog.jnlib index 53ceedf27..f51525e42 100644 --- a/jnlib/ChangeLog +++ b/common/ChangeLog.jnlib @@ -1,758 +1,769 @@ +2010-03-10 Werner Koch + + See gnupg/common/ChangeLog for newer changes. + + JNLIB has been merged into GnuPG's common directory. README.jnlib + list the files making up JNLIB. + + * README: Rename to README.jnlib + * ChangeLog: Rename to ChangeLog.jnlib. + * Makefile.am: Remove. + 2010-03-01 Werner Koch * t-w32-reg.c: New. * w32-reg.c (read_w32_registry_string) (write_w32_registry_string): Support W32CE. 2010-02-26 Werner Koch * t-timestuff.c: New. * dynload.h (dlopen, dlsym) [W32CE]: Map to wchar_t. * mischelp.c (_jnlib_free): New. (same_file_p) [W32CE]: Map to wchar_t. * utf8conv.c (set_native_charset) [W32CE]: Do not use GetConsoleOutputCP. (wchar_to_utf8, utf8_to_wchar) [W32]: New. * Makefile.am (t_jnlib_ldadd) [W32CE]: Add gpg-error. * t-support.h (getenv) [HAVE_GETENV]: Add getenv stub. [W32CE]: Include gpg-error.h * t-support.c (gpg_err_code_from_errno) (gpg_err_code_from_syserror) [GPG_ERROR_H]: Do not build. * t-stringhelp.c (gethome) [!HAVE_GETPWUID]: Keep result of getenv. * dotlock.c [!HAVE_SIGNAL_H]: Don't include signal.h. (create_dotlock) [W32CE]: Map filename top wchar_t. * libjnlib-config.h [USE_SIMPLE_GETTEXT]: Include gpg-error.h and remove w32help.h. (jnlib_set_errno): New. Use it everywhere to set ERRNO. (getenv) [!HAVE_GETENV]: New. (getpid) [W32E]: New. * stringhelp.c (get_pwdir) [!HAVE_PWD_H]: Mark unused args. (w32_strerror) [W32CE]: Use a simple implementation. * w32help.h [USE_SIMPLE_GETTEXT]: Remove all definitions; we are now using the gpg-error included implementation. * w32-gettext.c: Remove. * mischelp.c (same_file_p): Fix bug in case the second file can't be opened. 2009-10-19 Werner Koch * strlist.c (add_to_strlist_try): New. 2009-09-22 Werner Koch * dotlock.h (DOTLOCK): Rename to dotlock_t. Change all users. 2009-08-26 Werner Koch * stringhelp.c (do_make_filename): Factor some code out to .. (get_pwdir): .. new. 2009-08-26 Werner Koch * stringhelp.c [HAVE_PWD_H]: Include pwd.h. (do_make_filename): New. (make_filename, make_filename_try): Implement using the new function. * t-stringhelp.c (test_make_filename_try): New. * t-support.c (gcry_strdup): Fix. * stringhelp.h (make_filename, make_filename_try): Add sentinel attribute. 2009-08-25 Werner Koch * stringhelp.c: Include errno.h. (do_strconcat): New. (strconcat, xstrconcat): New. * types.h (GNUPG_GCC_A_SENTINEL): New. * t-stringhelp.c (test_strconcat, test_xstrconcat): New. (main): Run them. 2009-07-07 Werner Koch * stringhelp.c (make_filename_try): Use jnlib_malloc. * dotlock.c (read_lockfile): Replace jnlib_xmalloc by jnlib_malloc. 2009-06-04 Werner Koch * mischelp.h: Include SUN_LEN etc also for W32. 2009-05-19 Werner Koch * mischelp.h: Define PF_LOCAL, AF_LOCAL and SUN_LEN if requested. * logging.c (fun_writer): Use SUN_LEN to fix a Mac OS X freeze. 2009-03-25 Werner Koch * logging.c (fun_closer): Never close fd 2. (set_file_fd): Close logstream early. 2009-02-25 Werner Koch * logging.c (get_tid_callback): New. (do_logv): Use it. (log_set_get_tid_callback): New. 2009-01-22 Werner Koch - * t-support.c (gpg_err_code_from_errno) + * t-support.c (gpg_err_code_from_errno) (gpg_err_code_from_syserror): New. 2008-11-20 Werner Koch * argparse.c (arg_parse): Fix last change. 2008-11-11 Werner Koch * argparse.h: Add a bunch of macros and constants. * argparse.c: Use the new macros. Re-indent the code. Change license back to LGPL 2.1. 2008-11-04 Werner Koch * w32-gettext.c: Merged with code from libgpg-error and rewrote most parts. * Makefile.am (AM_CFLAGS): Add -DJNLIB_IN_JNLIB. 2008-10-29 Werner Koch * stringhelp.c (make_filename): Implement using macros. Factor some code out to .. (change_slashes): New. (make_filename_try): New. * w32-gettext.c (gettext): Return if no domain is loaded. Reported by Tom Pegios. 2008-10-28 Werner Koch * w32-gettext.c (gettext): Try the binary search if the string was not found in the hash table. 2008-10-20 Werner Koch * w32-afunix.c (_w32_sock_connect): Mark ADDRLEN as unused. * dotlock.c (release_dotlock): Do not mix declaration and code. * stringhelp.c (make_basename): Silent gcc warning about unused arg. * argparse.c (store_alias): Ditto. - (find_long_option): + (find_long_option): 2008-10-15 Werner Koch * logging.c (do_logv) [W32]: Flush the log stream. 2008-09-29 Werner Koch * argparse.c (ARGERR_): Use constants for error values. (optfile_parse): Prettify. Replace xmalloc and xrealloc by malloc and realloc. * libjnlib-config.h (jnlib_strdup, jnlib_realloc): New. 2008-06-26 Werner Koch * stringhelp.c (print_sanitized_buffer2): Loose check for control characters to better cope with utf-8. The range 0x80..0x9f is nowadays not anymore accidently used for control charaters. 2008-06-13 Werner Koch * dotlock.c: Reformat code and implement locking for W32. (create_dotlock): Use snprintf. 2008-06-11 Werner Koch * utf8conv.c: Remove useless variable ACTIVE_CHARSET. Suggested by Petr Uzel. 2008-05-26 Werner Koch * argparse.c (usage): Make sure to print a trailing LF for usage(1). 2008-04-08 Werner Koch * w32-gettext.c (gettext_select_utf8): New. (get_string): Support switching encodings. (load_domain): Allocate space for DATA_NATIVE. 2008-03-25 Werner Koch * w32-gettext.c (_nl_locale_name): New. Taken from ../common/localename and GNU gettext's localename.c. (set_gettext_file): Rewritten. (gettext_localename): New. 2008-03-17 Werner Koch * logging.c (my_funopen_hook_size_t): New. (fun_writer): Use it to cope with fopencookie/funopen differences. * dotlock.c (read_lockfile): Initialize PID. Reported by Stéphane Corthésy. 2008-02-22 Werner Koch * argparse.c (strusage): Set copyright year to 2008. 2007-11-19 Werner Koch * stringhelp.c (percent_escape): Factor code out to (do_percent_escape): .. new. (try_percent_escape): New. 2007-10-01 Werner Koch * w32-afunix.c: Only keep the client related code. (read_port_and_nonce): New. Taken from Assuan. (_w32_sock_connect): Rewritten. 2007-08-29 Werner Koch * argparse.c (initialize): Make strings translatable and remove extra LF. 2007-08-24 Werner Koch * mischelp.c (same_file_p): New. (libjnlib_dummy_mischelp_func): Remove as we now always have one function. 2007-08-09 Werner Koch * argparse.c (show_help): Expand the @EMAIL@ macro in the package bug reporting address. 2007-08-02 Werner Koch * t-stringhelp.c (test_compare_filenames): New. * stringhelp.c (compare_filenames) [HAVE_DRIVE_LETTERS]: Fixed comparison to take slash and backslash in account. (make_filename): Avoid mixing / and \. 2007-07-04 Werner Koch * utf8conv.c (load_libiconv): Remove URL from translatble string. Switched JNLIB from LGPLv2.1 to LGPLv3. 2007-07-01 Werner Koch * argparse.c (strusage): Use id 10 for the license string; default to GPL3+. Change long note to version 3 or later. (show_version): Print the license info. 2007-06-19 Werner Koch * Makefile.am: Add support for regression tests. * t-support.h, t-support.c: New. * t-stringhelp.c: New. * stringhelp.c (percent_escape): Add arg EXTRA to make it a more general function. Changed all callers. 2007-06-18 Werner Koch * w32-afunix.c (_w32_sock_bind): Changed to properly detect an already used socket. 2007-06-18 Marcus Brinkmann * stringhelp.h (percent_escape): New prototype. * stringhelp.c (percent_escape): New function. 2007-06-11 Werner Koch * utf8conv.c (jnlib_iconv_open, jnlib_iconv, jnlib_iconv_close): New. 2007-06-06 Werner Koch * w32help.h: New. * w32-gettext.c: New. Taken from gnupg 1.4, added ngettext, changed to use jnlib malloc functions and put under the LGPL. * w32-reg.c: New. Taken from../common/w32reg.c and changed to LGPL. Changed API to use the jnlib malloc functions. * Makefile.am (libjnlib_a_SOURCES) [!W32]: Do not build the w32 specific modules. * dotlock.c: Include stringhelp.h for stpcpy prototype. 2007-06-04 Werner Koch * dynload.h: New. Taken from ../common and changed to LGPL. * utf8conv.c (load_libiconv): New. Taken from GnuPG 1.4 2007-05-30 Werner Koch * w32-pth.h, w32-pth.c: Remove. 2007-04-25 Werner Koch * argparse.c (long_opt_strlen): Fixed for utf-8. 2007-03-07 Werner Koch * argparse.c (strusage): Set copyright year to 2007. 2007-01-25 Werner Koch * stringhelp.c (utf8_charcount): New. 2006-11-29 Werner Koch * utf8conv.c (set_native_charset) [HAVE_W32_SYSTEM]: Fixed typo in macro name. 2006-11-15 Werner Koch * logging.c (my_funopen_hook_ret_t): New. (fun_writer): Use it. 2006-10-19 Werner Koch * stringhelp.c (memrchr) [!HAVE_MEMRCHR]: Provide a replacement. 2006-09-27 Werner Koch * mischelp.c: New. (timegm): Copied from gnupg 1.4, changed from GPL to LGPL. Fixed a memory leak. * stringhelp.h (isascii): New. * stringhelp.c (strsep): New. Copied from gnupg 1.4.5 util/strgutil.c. - * strlist.h (STRLIST): Removed deprecated typedef. + * strlist.h (STRLIST): Removed deprecated typedef. * types.h: Made cpp commands work with old compilers. Also shows up nicer with Emacs' font locking. * w32-afunix.c (_w32_sock_connect): Set ERRNO for an invalid port. Changed license from GPL to LGPL. Note that all code has either been written by me, David, employees of g10 Code or taken from glibc. - + * libjnlib-config.h, stringhelp.c, stringhelp.h: * strlist.c, strlist.h, utf8conv.c, utf8conv.h: * argparse.c, argparse.h, logging.c, logging.h: * dotlock.c, dotlock.h, types.h, mischelp.h: * xmalloc.c, xmalloc.h, w32-pth.c, w32-pth.h: * w32-afunix.c, w32-afunix.h: Tagged them to be long to jnlib - which is a part of GnuPG but also used by other projetcs. + which is a part of GnuPG but also used by other projetcs. 2006-09-22 Werner Koch * utf8conv.c: Reworked to match the gnupg 1.4.5 code. This now requires iconv support but this is reasonable for all modern systems. 2006-08-29 Werner Koch * logging.c (do_logv): Emit a missing LF for fatal errors. 2006-06-28 Werner Koch * dotlock.c (make_dotlock, release_dotlock, read_lockfile) (maybe_deadlock, destroy_dotlock, create_dotlock): Re-indented. (create_dotlock): Repalces some log_fatal by log_error as it was not intended that they should terminate. Write the nodename to the locking file. Code cleanups. (read_lockfile): Reworked to read the node name. (make_dotlock): Test for identical node name and delete lock stale file. (release_dotlock): Likewise. 2006-05-23 Werner Koch * libjnlib-config.h (JNLIB_NEED_UTF8CONV): Fixed typo in name. * dotlock.c (release_dotlock): Don't act if we don't have any locks at all. (destroy_dotlock): New. From 1.4.3. (dotlock_remove_lockfiles): Make use of destroy function. 2006-05-19 Werner Koch * strlist.c (append_to_strlist2): Enabled. * stringhelp.c (print_sanitized_buffer2): New. Changed the rules to match the behaviour of print_string2 from gnupg 1.4.3. (print_sanitized_buffer): Use the new function. (print_sanitized_string2): New. (hextobyte): New. Taken from gpg 1.4.3. 2006-04-28 Werner Koch * stringhelp.c (print_sanitized_buffer): Fix bug where the count got wrong for the \xNN representation. (sanitize_buffer): Fix bug where some control characters lose part of their \xNN representation. 2006-04-20 Werner Koch * stringhelp.c (make_basename): New arg INPUTPATH for future riscos compatibility. 2006-04-18 Werner Koch * libjnlib-config.h (JNLIB_NEED_UTF8CONF): Defined. * strlist.c (add_to_strlist2) [JNLIB_NEED_UTF8CONV]: Enabled. 2005-06-15 Werner Koch * stringhelp.c (sanitize_buffer): Make P a void*. (ascii_memistr, memistr): Ditto. (ascii_memcasecmp): Ditto. * logging.c (writen): Use void * for arg BUFFER. * stringhelp.c (memistr): Fixed unsigned/signed pointer conflict. (ascii_memistr): Ditto. (ascii_memcasemem): Ditto. * utf8conv.c (utf8_to_native): Ditto. (utf8_to_native): Ditto. * argparse.c (show_version): Removed non-required cast. 2005-01-19 Werner Koch * logging.c (fun_writer): Don't fallback to stderr. Print to stderr only if connected to a tty. 2004-12-20 Werner Koch * w32-pth.c (do_pth_event_free): The events are hold in a ring buffer. Adjust for that. (do_pth_event_body): Ditto. (pth_event_isolate): Ditto. (do_pth_wait): Ditto. (_pth_event_count): Renamed to .. (event_count): .. and adjusted as above. (pth_init): Define 3 debug levels and change all debug calls to make use of them. This makes the moule now silent. 2004-12-19 Werner Koch * w32-pth.c (pth_init): Enable debugging depending on env var. (pth_self): New. (pth_mutex_release, pth_mutex_acquire): Implemented directly using the W32 API. 2004-12-18 Werner Koch * w32-pth.c (pth_init): Reverse return values. Use TRUE and FALSE constants. (pth_kill, pth_mutex_acquire, pth_attr_set, pth_join, pth_cancel): Ditto. 2004-12-15 Werner Koch * logging.c [W32]: Don't include unavailable headers. 2004-12-14 Werner Koch * w32-pth.c (_pth_strerror): Renamed to ... (w32_strerror): .. this. And let callers provide a buffer. (spawn_helper_thread): Removed HD arg and hardwire the stack size to 32k. (do_pth_wait): Removed use of ATTR; not needed for the helper threads. (helper_thread): Renamed to .. (launch_thread): .. this. Release handle if not joinable. (struct pth_priv_hd_s): Renamed to ... (struct thread_info_s): .. this. Add member JOINABLE and TH. 2004-12-14 Timo Schulz * w32-pth.c (pth_kill): Just release the crit section if pth_init was really called. And set all handles to NULL. (_pth_strerror): New. (do_pth_wait): Before we enter the loop we check if there are too much events in the ring. - + 2004-12-14 Werner Koch - * w32-pth.h (pth_event_occured): Removed macro. + * w32-pth.h (pth_event_occured): Removed macro. * w32-pth.c: Fixed license statement; its under the LGPL. (enter_pth, leave_pth): Use them to bracket almost all public functions. 2004-12-13 Timo Schulz * w32-pth.c (enter_pth, leave_pth): New. (pth_init): Initialize global mutex section. (pth_kill): Release global mutex section. (helper_thread): New. (pth_spawn): Make sure only one thread is running. - + 2004-12-13 Werner Koch * stringhelp.c (w32_strerror) [W32]: New. * w32-pth.c, w32-pth.h: Added real code written by Timo Schulz. Not finished, though. 2004-12-07 Werner Koch * w32-pth.c, w32-pth.h: New. 2004-11-26 Werner Koch * logging.c [_WIN32]: Don't include socket headers. 2004-11-30 Timo Schulz * w32-afunix.c: New. AF_UNIX emulation for W32. * w32-afunix.h: Likewise. - + 2004-11-22 Werner Koch * logging.c (log_test_fd): Add test on LOGSTREAM. Reported by Barry Schwartz. 2004-11-18 Werner Koch * logging.c: Explicitly include sys/stat.h for the S_I* constants. 2004-10-21 Werner Koch * logging.c (do_logv): Use set_log_stream to setup a default. (log_set_file): Factored code out to .. (set_file_fd): .. New function to allow using a file descriptor. (log_set_fd): Make use of new fucntion. (fun_writer): Reworked. 2004-08-18 Werner Koch * stringhelp.c (print_sanitized_utf8_string): Actually implement it. 2004-06-21 Werner Koch * logging.c (log_set_file): Do not close an old logstream if it used to be stderr or stdout. 2004-05-05 Werner Koch * logging.c (log_set_file): Oops, don't close if LOGSTREAM is NULL. 2004-04-30 Werner Koch * logging.c (log_set_file): Make sure the log stream will be closed even if the stderr fileno will be assigned to a new socket. 2004-04-16 Werner Koch * logging.h (JNLIB_LOG_WITH_PREFIX): Add constants for the flag values. * logging.c (log_set_prefix): New flag DETACHED. (fun_writer): Take care of this flag. (log_test_fd): New. 2004-02-18 Werner Koch * stringhelp.c (print_sanitized_buffer): Don't care about non-ASCII characaters. (sanitize_buffer): Ditto. 2004-02-12 Werner Koch * Makefile.am: Replaced INCLUDES by AM_CPPFLAGS. 2004-01-05 Werner Koch * argparse.c (strusage): Changed default copyright year to 2004. 2003-12-17 Werner Koch * argparse.c (initialize): Replaced use of non-literal format args. Suggested by Florian Weimer. 2003-12-16 Werner Koch * logging.c (writen, fun_writer, fun_closer): New. (log_set_file): Add feature to log to a socket. (log_set_file, do_logv): Force printing with prefix and pid. 2003-11-13 Werner Koch * strlist.c (strlist_copy): New. * dotlock.c: Define DIRSEP_C et al. if not defined. 2003-11-06 Werner Koch * strlist.h (strlist_t): New. STRLIST is now deprecated. 2003-06-18 Werner Koch * strlist.c (strlist_pop): New. * dotlock.c (dotlock_remove_lockfiles): Prefixed with dotlock_ and made global. 2003-06-17 Werner Koch * stringhelp.c (length_sans_trailing_chars) (length_sans_trailing_ws): New. * logging.c (log_inc_errorcount): New. * stringhelp.c (print_sanitized_utf8_buffer): Implement utf8 conversion. (sanitize_buffer): New. Based on gnupg 1.3.2 make_printable_string. * dotlock.c: Updated to match the version from 1.3.2 * utf8conv.c: New. Code taken from strgutil.c of gnupg 1.3.2. * utf8conv.h: New. 2003-06-16 Werner Koch * logging.c (do_logv): Hack to optionally suppress a leading space. * stringhelp.c (ascii_strncasecmp): New. Taken from gnupg 1.3. (ascii_memistr): New. Taken from gnupg 1.3 2003-06-13 Werner Koch - * mischelp.h (wipememory2,wipememory): New. Taken from GnuPG 1.3.2. + * mischelp.h (wipememory2,wipememory): New. Taken from GnuPG 1.3.2. 2002-06-04 Werner Koch * stringhelp.c (print_sanitized_utf8_string): New. No real implementation for now. (print_sanitized_utf8_buffer): Ditto. 2002-04-04 Werner Koch * logging.c (log_get_prefix): New. 2002-03-15 Werner Koch * argparse.c (optfile_parse): Fixed missing argument handling. 2002-02-25 Werner Koch * stringhelp.c (ascii_memcasemem): New. 2002-02-14 Werner Koch * Makefile.am (INCLUDES): Add cflags for libgcrypt. 2002-02-07 Werner Koch * logging.c (log_set_fd): New. * stringhelp.c (print_sanitized_buffer): New. (print_sanitized_string): New. 2002-01-24 Werner Koch * argparse.c (strusage): Set default copyright notice year to 2002. Fixed the copyright notice of this file, as it has always been part of GnuPG and therefore belongs to the FSF. 2001-11-01 Marcus Brinkmann * logging.c (log_printf): Do not initialize ARG_PTR with 0, we don't know the correct type. Instead, run va_start and va_end unconditionally. Reported by Jose Carlos Garcia Sogo . 2002-01-19 Werner Koch * logging.c (log_get_stream): New. 2001-12-05 Werner Koch * logging.c (log_set_prefix): New. (do_logv): Include prefix and pid only if enabled. Print time only when explicitly enabled. - (log_logv): New. + (log_logv): New. * logging.h: Include log_logv() only when requested. 2001-11-06 Werner Koch * strlist.c, strlist.h: New. Taken from pgnupg/util/strgutil.c 2001-08-30 Werner Koch * logging.c (log_printf): Don't pass NULL instead of arg_ptr. 2001-07-19 Werner Koch * stringhelp.c (ascii_memistr,ascii_isupper,ascii_islower, ascii_toupper,ascii_tolower, ascii_strcasecmp, ascii_memcasecmp): New. 2000-07-26 10:02:51 Werner Koch (wk@habibti.openit.de) * stringhelp.c.: Add stdarg.h * argparse.h: s/ulong/unsigned long/ although this should be defined by types.h. 2000-06-28 19:40:23 Werner Koch (wk@habibti.openit.de) * Makefile.am: Replaced second logging.c by .h 2000-05-24 08:58:15 Werner Koch (wk@habibti.openit.de) * logging.c (log_get_errorcount): New. 2000-05-24 08:44:47 Werner Koch (wk@habibti.openit.de) * stringhelp.c: Added a few filename related helper functions. 2000-05-11 18:04:43 Werner Koch (wk@habibti.openit.de) * xmalloc.c (xstrcat2): Replaced stpcpy to quickly address W32 problems. 2000-05-02 19:43:38 Werner Koch (wk@habibti.openit.de) * xmalloc.c (xstrcat2): New. Mon Jan 24 13:04:28 CET 2000 Werner Koch * README: New. * Makefile.am: new. * argparse.c, argparse.h, logging.c, logging.h: * mischelp.h, stringhelp.c, stringhelp.h, xmalloc.c: * xmalloc.h, dotlock.c: Moved from ../util to here. * dotlock.h: New. * libjnlib-config.h: New. * logging.c (log_set_file): New. (log_printf): New. (do_logv): Add kludge to insert LFs. *********************************************************** * Please note that JNLIB is maintained as part of GnuPG. * * You may find it source-copied in other packages. * *********************************************************** Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2010 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/common/Makefile.am b/common/Makefile.am index c7a9f09ba..1a73d31b1 100644 --- a/common/Makefile.am +++ b/common/Makefile.am @@ -1,140 +1,178 @@ # Makefile for common gnupg modules -# Copyright (C) 2001, 2003, 2007 Free Software Foundation, Inc. +# Copyright (C) 2001, 2003, 2007, 2010 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 3 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, see . ## Process this file with automake to produce Makefile.in EXTRA_DIST = mkstrtable.awk exaudit.awk exstatus.awk \ - audit-events.h status-codes.h + audit-events.h status-codes.h README.jnlib ChangeLog.jnlib noinst_LIBRARIES = libcommon.a libcommonpth.a libsimple-pwquery.a libgpgrl.a -noinst_PROGRAMS = $(module_tests) $(module_maint_tests) -TESTS = $(module_tests) +noinst_PROGRAMS = $(jnlib_tests) $(module_tests) $(module_maint_tests) +TESTS = $(jnlib_tests) $(module_tests) BUILT_SOURCES = audit-events.h status-codes.h CLEANFILES = audit-events.h status-codes.h AM_CPPFLAGS = -I$(top_srcdir)/gl -I$(top_srcdir)/intl AM_CFLAGS = $(LIBGCRYPT_CFLAGS) $(KSBA_CFLAGS) include $(top_srcdir)/am/cmacros.am +jnlib_sources = \ + libjnlib-config.h \ + types.h dynload.h w32help.h \ + stringhelp.c stringhelp.h \ + strlist.c strlist.h \ + utf8conv.c utf8conv.h \ + argparse.c argparse.h \ + logging.c logging.h \ + dotlock.c dotlock.h \ + mischelp.c mischelp.h + +if HAVE_W32_SYSTEM +jnlib_sources += w32-reg.c w32-afunix.c w32-afunix.h +endif + + common_sources = \ common-defs.h \ util.h i18n.c i18n.h \ + estream.c estream.h estream-printf.c estream-printf.h \ status.c status.h\ openpgpdefs.h \ gc-opt-flags.h \ keyserver.h \ sexp-parse.h \ tlv.c tlv.h \ init.c init.h \ sexputil.c \ sysutils.c sysutils.h \ homedir.c \ gettime.c \ yesno.c \ b64enc.c b64dec.c \ convert.c \ percent.c \ miscellaneous.c \ xasprintf.c \ xreadline.c \ membuf.c membuf.h \ iobuf.c iobuf.h \ ttyio.c ttyio.h \ asshelp.c asshelp.h \ exechelp.c exechelp.h \ signal.c \ - estream.c estream.h estream-printf.c estream-printf.h \ audit.c audit.h \ srv.h \ dns-cert.c dns-cert.h \ pka.c pka.h \ http.c http.h \ localename.c \ session-env.c session-env.h \ userids.c userids.h \ helpfile.c # Sources only useful without PTH. without_pth_sources = \ get-passphrase.c get-passphrase.h -libcommon_a_SOURCES = $(common_sources) $(without_pth_sources) +libcommon_a_SOURCES = $(jnlib_sources) $(common_sources) $(without_pth_sources) if USE_DNS_SRV libcommon_a_SOURCES += srv.c endif libcommon_a_CFLAGS = $(AM_CFLAGS) $(LIBASSUAN_CFLAGS) -DWITHOUT_GNU_PTH=1 -libcommonpth_a_SOURCES = $(common_sources) +libcommonpth_a_SOURCES = $(jnlib_sources) $(common_sources) if USE_DNS_SRV libcommonpth_a_SOURCES += srv.c endif libcommonpth_a_CFLAGS = $(AM_CFLAGS) $(LIBASSUAN_CFLAGS) $(PTH_CFLAGS) libsimple_pwquery_a_SOURCES = \ simple-pwquery.c simple-pwquery.h asshelp.c asshelp.h libsimple_pwquery_a_CFLAGS = $(AM_CFLAGS) $(LIBASSUAN_CFLAGS) libgpgrl_a_SOURCES = \ gpgrlhelp.c if MAINTAINER_MODE # Note: Due to the dependency on Makefile, the file will always be # rebuilt, so we allow this only in maintainer mode. # Create the audit-events.h include file from audit.h # Note: We create the target file in the source directory because it # is a distributed built source. If we would not do that we may end # up with two files and then it is not clear which version of the # files will be picked up. audit-events.h: Makefile mkstrtable.awk exaudit.awk audit.h $(AWK) -f $(srcdir)/exaudit.awk $(srcdir)/audit.h \ | $(AWK) -f $(srcdir)/mkstrtable.awk -v textidx=3 -v nogettext=1 \ -v namespace=eventstr_ > $(srcdir)/$@ # Create the status-codes.h include file from status.h status-codes.h: Makefile mkstrtable.awk exstatus.awk status.h $(AWK) -f $(srcdir)/exstatus.awk $(srcdir)/status.h \ | $(AWK) -f $(srcdir)/mkstrtable.awk -v textidx=3 -v nogettext=1 \ -v namespace=statusstr_ > $(srcdir)/$@ endif # # Module tests # +t_jnlib_src = t-support.c t-support.h +jnlib_tests = t-stringhelp t-timestuff +if HAVE_W32_SYSTEM +jnlib_tests += t-w32-reg +endif module_tests = t-convert t-percent t-gettime t-sysutils t-sexputil t-exechelp \ t-session-env module_maint_tests = t-helpfile t-b64 -t_common_ldadd = libcommon.a ../jnlib/libjnlib.a ../gl/libgnu.a \ + +t_common_ldadd = libcommon.a ../gl/libgnu.a \ $(LIBGCRYPT_LIBS) $(GPG_ERROR_LIBS) $(LIBINTL) $(LIBICONV) +# jnlib tests +t_stringhelp_SOURCES = t-stringhelp.c $(t_jnlib_src) +t_stringhelp_LDADD = $(t_common_ldadd) + +t_timestuff_SOURCES = t-timestuff.c $(t_jnlib_src) +t_timestuff_LDADD = $(t_common_ldadd) + +if HAVE_W32_SYSTEM +t_w32_reg_SOURCES = t-w32-reg.c $(t_jnlib_src) +t_w32_reg_LDADD = $(t_common_ldadd) +endif + +# common tests t_convert_LDADD = $(t_common_ldadd) t_percent_LDADD = $(t_common_ldadd) t_gettime_LDADD = $(t_common_ldadd) t_sysutils_LDADD = $(t_common_ldadd) t_helpfile_LDADD = $(t_common_ldadd) t_sexputil_LDADD = $(t_common_ldadd) t_b64_LDADD = $(t_common_ldadd) t_exechelp_LDADD = $(t_common_ldadd) t_session_env_LDADD = $(t_common_ldadd) + + + diff --git a/jnlib/Makefile.am b/common/README.jnlib similarity index 55% rename from jnlib/Makefile.am rename to common/README.jnlib index 232aef980..e8df795cb 100644 --- a/jnlib/Makefile.am +++ b/common/README.jnlib @@ -1,85 +1,101 @@ -# Makefile for the JNLIB part of GnuPG -# Copyright (C) 1999, 2000, 2001, 2004, 2006, -# 2010 Feee Software Soundation, Inc. -# -# This file is part of JNLIB. -# -# JNLIB 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 3 of -# the License, or (at your option) any later version. -# -# JNLIB is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this program; if not, see . - - -## Process this file with automake to produce Makefile.in - +JNLIB - This is a collection of utility function which are too small +to put into a library. The code here is licensed under the LGPL. + +libjnlib-config.h should be be modified for each project to make these +functions fit into the software. Mainly these are memory functions in +case you need another allocator. + +Files which make up jnlib: + README.jnlib + ChangeLog.jnlib + libjnlib-config.h + argparse.c + argparse.h + dotlock.c + dotlock.h + dynload.h + logging.c + logging.h + mischelp.c + mischelp.h + stringhelp.c + stringhelp.h + strlist.c + strlist.h + types.h + utf8conv.c + utf8conv.h + w32-afunix.c + w32-afunix.h + w32-reg.c + w32help.h + xmalloc.c + xmalloc.h + t-stringhelp.c + t-support.c + t-support.h + t-timestuff.c + t-w32-reg.c + + +Here is a template Makefile.am for these jnlib modules: +===8<================================================== EXTRA_DIST = README noinst_PROGRAMS = $(module_tests) TESTS = $(module_tests) AM_CPPFLAGS = -I$(top_srcdir)/intl # We need libgcrypt because libjnlib-config includes gcrypt.h -AM_CFLAGS = -DJNLIB_IN_JNLIB $(LIBGCRYPT_CFLAGS) +AM_CFLAGS = $(LIBGCRYPT_CFLAGS) noinst_LIBRARIES = libjnlib.a - -#libjnlib_a_LDFLAGS = libjnlib_a_SOURCES = \ libjnlib-config.h \ stringhelp.c stringhelp.h \ strlist.c strlist.h \ utf8conv.c utf8conv.h \ argparse.c argparse.h \ logging.c logging.h \ dotlock.c dotlock.h \ - types.h mischelp.c mischelp.h dynload.h w32help.h + types.h mischelp.c mischelp.h dynload.h w32help.h \ + xmalloc.c xmalloc.h if HAVE_W32_SYSTEM libjnlib_a_SOURCES += w32-reg.c w32-afunix.c w32-afunix.h endif - -# For GnuPG we don't need the xmalloc stuff. -# xmalloc.c xmalloc.h - - # # Module tests. # # These tests should only be used at the canonical location of jnlib # which is the GnuPG package. The reason for this is that t-support.c # defines replacements for the actual used memory allocation functions # so that there is no dependency on libgcrypt. # module_tests = t-stringhelp t-timestuff if HAVE_W32_SYSTEM module_tests += t-w32-reg endif t_jnlib_src = t-support.c t-support.h t_jnlib_ldadd = libjnlib.a $(LIBINTL) $(LIBICONV) # For W32 we need libgpg-error because it provides gettext. if HAVE_W32_SYSTEM t_jnlib_ldadd += $(GPG_ERROR_LIBS) endif t_stringhelp_SOURCES = t-stringhelp.c $(t_jnlib_src) t_stringhelp_LDADD = $(t_jnlib_ldadd) t_timestuff_SOURCES = t-timestuff.c $(t_jnlib_src) t_timestuff_LDADD = $(t_jnlib_ldadd) if HAVE_W32_SYSTEM t_w32_reg_SOURCES = t-w32-reg.c $(t_jnlib_src) t_w32_reg_LDADD = $(t_jnlib_ldadd) endif +==>8=================================================== + diff --git a/jnlib/argparse.c b/common/argparse.c similarity index 100% rename from jnlib/argparse.c rename to common/argparse.c diff --git a/jnlib/argparse.h b/common/argparse.h similarity index 100% rename from jnlib/argparse.h rename to common/argparse.h diff --git a/common/audit.h b/common/audit.h index 28d1edbd1..8f413aa30 100644 --- a/common/audit.h +++ b/common/audit.h @@ -1,227 +1,227 @@ /* audit.h - Definitions for the audit subsystem * Copyright (C) 2007 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 3 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, see . */ #ifndef GNUPG_COMMON_AUDIT_H #define GNUPG_COMMON_AUDIT_H #include -#include "estream.h" +#include "../common/estream.h" struct audit_ctx_s; typedef struct audit_ctx_s *audit_ctx_t; /* Constants for the audit type. */ typedef enum { AUDIT_TYPE_NONE = 0, /* No type set. */ AUDIT_TYPE_ENCRYPT, /* Data encryption. */ AUDIT_TYPE_SIGN, /* Signature creation. */ AUDIT_TYPE_DECRYPT, /* Data decryption. */ AUDIT_TYPE_VERIFY /* Signature verification. */ } audit_type_t; /* The events we support. */ typedef enum { AUDIT_NULL_EVENT = 0, /* No such event. Its value shall be 0 and no other values shall be assigned to the other enum symbols. This is required so that the exaudit.awk script comes up with correct values without running cc. */ AUDIT_SETUP_READY, /* All preparations done so that the actual processing can start now. This indicates that all parameters are okay and we can start to process the actual data. */ AUDIT_AGENT_READY, /* err */ /* Indicates whether the gpg-agent is available. For some operations the agent is not required and thus no such event will be logged. */ AUDIT_DIRMNGR_READY, /* err */ /* Indicates whether the Dirmngr is available. For some operations the Dirmngr is not required and thus no such event will be logged. */ AUDIT_GPG_READY, /* err */ /* Indicates whether the Gpg engine is available. */ AUDIT_GPGSM_READY, /* err */ /* Indicates whether the Gpgsm engine is available. */ AUDIT_G13_READY, /* err */ /* Indicates whether the G13 engine is available. */ AUDIT_GOT_DATA, /* Data to be processed has been seen. */ AUDIT_DETACHED_SIGNATURE, /* The signature is a detached one. */ AUDIT_CERT_ONLY_SIG, /* A certifciate only signature has been detected. */ AUDIT_DATA_HASH_ALGO, /* int */ /* The hash algo given as argument is used for the data. This event will be repeated for all hash algorithms used with the data. */ AUDIT_ATTR_HASH_ALGO, /* int */ /* The hash algo given as argument is used to hash the message digest and other signed attributes of this signature. */ AUDIT_DATA_CIPHER_ALGO, /* int */ /* The cipher algo given as argument is used for this data. */ AUDIT_BAD_DATA_HASH_ALGO, /* string */ /* The hash algo as specified by the signature can't be used. STRING is the description of this algorithm which usually is an OID string. STRING may be NULL. */ AUDIT_BAD_DATA_CIPHER_ALGO, /* string */ /* The symmetric cipher algorithm is not supported. STRING is the description of this algorithm which usually is an OID string. STRING may be NULL. */ AUDIT_DATA_HASHING, /* ok_err */ /* Logs the result of the data hashing. */ AUDIT_READ_ERROR, /* ok_err */ /* A generic read error occurred. */ AUDIT_WRITE_ERROR, /* ok_err */ /* A generic write error occurred. */ AUDIT_USAGE_ERROR, /* The program was used in an inappropriate way; For example by passing a data object while the signature does not expect one or vice versa. */ AUDIT_SAVE_CERT, /* cert, ok_err */ /* Save the certificate received in a message. */ AUDIT_NEW_SIG, /* int */ /* Start the verification of a new signature for the last data object. The argument is the signature number as used internally by the program. */ AUDIT_SIG_NAME, /* string */ /* The name of a signer. This is the name or other identification data as known from the signature and not the name from the certificate used for verification. An example for STRING when using CMS is: "#1234/CN=Prostetnic Vogon Jeltz". */ AUDIT_SIG_STATUS, /* string */ /* The signature status of the current signer. This is the last audit information for one signature. STRING gives the status: "error" - there was a problem checking this or any signature. "unsupported" - the signature type is not supported. "no-cert" - The certificate of the signer was not found (the S/N+issuer of the signer is already in the log). "bad" - bad signature "good" - good signature */ AUDIT_NEW_RECP, /* int */ /* A new recipient has been seen during decryption. The argument is the recipient number as used internally by the program. */ AUDIT_RECP_NAME, /* string */ /* The name of a recipient. This is the name or other identification data as known from the decryption and not the name from the certificate used for decryption. An example for STRING when using CMS is: "#1234/CN=Prostetnic Vogon Jeltz". */ AUDIT_RECP_RESULT, /* ok_err */ /* The status of the session key decryption. This is only written for recipients tried. */ AUDIT_DECRYPTION_RESULT, /* ok_err */ /* The status of the entire decryption. The decryption was successful if the error code is 0. */ AUDIT_VALIDATE_CHAIN, /* Start the validation of a certificate chain. */ AUDIT_CHAIN_BEGIN, AUDIT_CHAIN_CERT, /* cert */ AUDIT_CHAIN_ROOTCERT,/* cert */ AUDIT_CHAIN_END, /* These 4 events are used to log the certificates making up a certificate chain. ROOTCERT is used for the trustanchor and CERT for all other certificates. */ AUDIT_CHAIN_STATUS, /* err */ /* Tells the final status of the chain validation. */ AUDIT_ROOT_TRUSTED, /* cert, err */ /* Tells whether the root certificate is trusted. This event is emmited durcing chain validation. */ AUDIT_CRL_CHECK, /* err */ /* Tells the status of a CRL or OCSP check. */ AUDIT_GOT_RECIPIENTS, /* int */ /* Records the number of recipients to be used for encryption. This includes the recipients set by --encrypt-to but records 0 if no real recipient has been given. */ AUDIT_SESSION_KEY, /* string */ /* Mark the creation or availibility of the session key. The parameter is the algorithm ID. */ AUDIT_ENCRYPTED_TO, /* cert, err */ /* Records the certificate used for encryption and whether the session key could be encrypted to it (err==0). */ AUDIT_ENCRYPTION_DONE, /* Encryption succeeded. */ AUDIT_SIGNED_BY, /* cert, err */ /* Records the certificate used for signed and whether the signure could be created (if err==0). */ AUDIT_SIGNING_DONE, /* Signing succeeded. */ AUDIT_LAST_EVENT /* Marker for parsing this list. */ } audit_event_t; audit_ctx_t audit_new (void); void audit_release (audit_ctx_t ctx); void audit_set_type (audit_ctx_t ctx, audit_type_t type); void audit_log (audit_ctx_t ctx, audit_event_t event); void audit_log_ok (audit_ctx_t ctx, audit_event_t event, gpg_error_t err); void audit_log_i (audit_ctx_t ctx, audit_event_t event, int value); void audit_log_s (audit_ctx_t ctx, audit_event_t event, const char *value); void audit_log_cert (audit_ctx_t ctx, audit_event_t event, ksba_cert_t cert, gpg_error_t err); void audit_print_result (audit_ctx_t ctx, estream_t stream, int use_html); #endif /*GNUPG_COMMON_AUDIT_H*/ diff --git a/jnlib/dotlock.c b/common/dotlock.c similarity index 100% rename from jnlib/dotlock.c rename to common/dotlock.c diff --git a/jnlib/dotlock.h b/common/dotlock.h similarity index 100% rename from jnlib/dotlock.h rename to common/dotlock.h diff --git a/jnlib/dynload.h b/common/dynload.h similarity index 100% rename from jnlib/dynload.h rename to common/dynload.h diff --git a/common/exechelp.c b/common/exechelp.c index 95e5b633c..f71cd7349 100644 --- a/common/exechelp.c +++ b/common/exechelp.c @@ -1,1130 +1,1138 @@ /* exechelp.c - fork and exec helpers * Copyright (C) 2004, 2007, 2008, 2009, * 2010 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 3 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, see . */ #include #include #include #include #include #include -#include +#ifdef HAVE_SIGNAL_H +# include +#endif #include #include #ifdef WITHOUT_GNU_PTH /* Give the Makefile a chance to build without Pth. */ #undef HAVE_PTH #undef USE_GNU_PTH #endif #ifdef USE_GNU_PTH #include #endif #ifndef HAVE_W32_SYSTEM #include #endif #ifdef HAVE_GETRLIMIT #include #include #endif /*HAVE_GETRLIMIT*/ #ifdef HAVE_STAT # include #endif #include "util.h" #include "i18n.h" #include "sysutils.h" #include "exechelp.h" /* Define to 1 do enable debugging. */ #define DEBUG_W32_SPAWN 1 /* We have the usual problem here: Some modules are linked against pth and some are not. However we want to use pth_fork and pth_waitpid here. Using a weak symbol works but is not portable - we should provide a an explicit dummy pth module instead of using the pragma. */ #ifndef _WIN32 #pragma weak pth_fork #pragma weak pth_waitpid #endif #ifdef HAVE_W32_SYSTEM /* It seems Vista doesn't grok X_OK and so fails access() tests. Previous versions interpreted X_OK as F_OK anyway, so we'll just use F_OK directly. */ #undef X_OK #define X_OK F_OK #endif /* HAVE_W32_SYSTEM */ +/* Constants not supported by WindowsCE. */ +#ifdef HAVE_W32CE_SYSTEM +# define DETACHED_PROCESS (0) +# define CREATE_NEW_PROCESS_GROUP (0) +#endif + #ifdef HAVE_W32_SYSTEM /* 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)) #endif /* Return the maximum number of currently allowed open file descriptors. Only useful on POSIX systems but returns a value on other systems too. */ int get_max_fds (void) { int max_fds = -1; #ifdef HAVE_GETRLIMIT struct rlimit rl; # ifdef RLIMIT_NOFILE if (!getrlimit (RLIMIT_NOFILE, &rl)) max_fds = rl.rlim_max; # endif # ifdef RLIMIT_OFILE if (max_fds == -1 && !getrlimit (RLIMIT_OFILE, &rl)) max_fds = rl.rlim_max; # endif #endif /*HAVE_GETRLIMIT*/ #ifdef _SC_OPEN_MAX if (max_fds == -1) { long int scres = sysconf (_SC_OPEN_MAX); if (scres >= 0) max_fds = scres; } #endif #ifdef _POSIX_OPEN_MAX if (max_fds == -1) max_fds = _POSIX_OPEN_MAX; #endif #ifdef OPEN_MAX if (max_fds == -1) max_fds = OPEN_MAX; #endif if (max_fds == -1) max_fds = 256; /* Arbitrary limit. */ return max_fds; } /* Close all file descriptors starting with descriptor FIRST. If EXCEPT is not NULL, it is expected to be a list of file descriptors which shall not be closed. This list shall be sorted in ascending order with the end marked by -1. */ void close_all_fds (int first, int *except) { int max_fd = get_max_fds (); int fd, i, except_start; if (except) { except_start = 0; for (fd=first; fd < max_fd; fd++) { for (i=except_start; except[i] != -1; i++) { if (except[i] == fd) { /* If we found the descriptor in the exception list we can start the next compare run at the next index because the exception list is ordered. */ except_start = i + 1; break; } } if (except[i] == -1) close (fd); } } else { for (fd=first; fd < max_fd; fd++) close (fd); } gpg_err_set_errno (0); } /* Returns an array with all currently open file descriptors. The end of the array is marked by -1. The caller needs to release this array using the *standard free* and not with xfree. This allow the use of this fucntion right at startup even before libgcrypt has been initialized. Returns NULL on error and sets ERRNO accordingly. */ int * get_all_open_fds (void) { int *array; size_t narray; int fd, max_fd, idx; #ifndef HAVE_STAT array = calloc (1, sizeof *array); if (array) array[0] = -1; #else /*HAVE_STAT*/ struct stat statbuf; max_fd = get_max_fds (); narray = 32; /* If you change this change also t-exechelp.c. */ array = calloc (narray, sizeof *array); if (!array) return NULL; /* Note: The list we return is ordered. */ for (idx=0, fd=0; fd < max_fd; fd++) if (!(fstat (fd, &statbuf) == -1 && errno == EBADF)) { if (idx+1 >= narray) { int *tmp; narray += (narray < 256)? 32:256; tmp = realloc (array, narray * sizeof *array); if (!tmp) { free (array); return NULL; } array = tmp; } array[idx++] = fd; } array[idx] = -1; #endif /*HAVE_STAT*/ return array; } #ifdef HAVE_W32_SYSTEM /* Helper function to build_w32_commandline. */ static char * build_w32_commandline_copy (char *buffer, const char *string) { char *p = buffer; const char *s; if (!*string) /* Empty string. */ p = stpcpy (p, "\"\""); else if (strpbrk (string, " \t\n\v\f\"")) { /* Need top do some kind of quoting. */ p = stpcpy (p, "\""); for (s=string; *s; s++) { *p++ = *s; if (*s == '\"') *p++ = *s; } *p++ = '\"'; *p = 0; } else p = stpcpy (p, string); return p; } /* Build a command line for use with W32's CreateProcess. On success CMDLINE gets the address of a newly allocated string. */ static gpg_error_t build_w32_commandline (const char *pgmname, const char * const *argv, char **cmdline) { int i, n; const char *s; char *buf, *p; *cmdline = NULL; n = 0; s = pgmname; n += strlen (s) + 1 + 2; /* (1 space, 2 quoting */ for (; *s; s++) if (*s == '\"') n++; /* Need to double inner quotes. */ for (i=0; (s=argv[i]); i++) { n += strlen (s) + 1 + 2; /* (1 space, 2 quoting */ for (; *s; s++) if (*s == '\"') n++; /* Need to double inner quotes. */ } n++; buf = p = xtrymalloc (n); if (!buf) return gpg_error_from_syserror (); p = build_w32_commandline_copy (p, pgmname); for (i=0; argv[i]; i++) { *p++ = ' '; p = build_w32_commandline_copy (p, argv[i]); } *cmdline= buf; return 0; } #endif /*HAVE_W32_SYSTEM*/ #ifdef HAVE_W32_SYSTEM /* Create pipe where the write end is inheritable. */ static int create_inheritable_pipe_w (int filedes[2]) { HANDLE r, w, h; 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; if (!DuplicateHandle (GetCurrentProcess(), w, GetCurrentProcess(), &h, 0, TRUE, DUPLICATE_SAME_ACCESS )) { log_error ("DuplicateHandle failed: %s\n", w32_strerror (-1)); CloseHandle (r); CloseHandle (w); return -1; } CloseHandle (w); w = h; filedes[0] = handle_to_fd (r); filedes[1] = handle_to_fd (w); return 0; } /* Create pipe where the read end is inheritable. */ static int create_inheritable_pipe_r (int filedes[2]) { HANDLE r, w, h; 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; if (!DuplicateHandle (GetCurrentProcess(), r, GetCurrentProcess(), &h, 0, TRUE, DUPLICATE_SAME_ACCESS )) { log_error ("DuplicateHandle failed: %s\n", w32_strerror (-1)); CloseHandle (r); CloseHandle (w); return -1; } CloseHandle (r); r = h; filedes[0] = handle_to_fd (r); filedes[1] = handle_to_fd (w); return 0; } #endif /*HAVE_W32_SYSTEM*/ #ifdef HAVE_W32_SYSTEM static HANDLE w32_open_null (int for_write) { HANDLE hfile; hfile = CreateFile ("nul", for_write? GENERIC_WRITE : GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL); if (hfile == INVALID_HANDLE_VALUE) log_debug ("can't open `nul': %s\n", w32_strerror (-1)); return hfile; } #endif /*HAVE_W32_SYSTEM*/ #ifndef HAVE_W32_SYSTEM /* The exec core used right after the fork. This will never return. */ static void do_exec (const char *pgmname, const char *argv[], int fd_in, int fd_out, int fd_err, void (*preexec)(void) ) { char **arg_list; int i, j; int fds[3]; fds[0] = fd_in; fds[1] = fd_out; fds[2] = fd_err; /* Create the command line argument array. */ i = 0; if (argv) while (argv[i]) i++; arg_list = xcalloc (i+2, sizeof *arg_list); arg_list[0] = strrchr (pgmname, '/'); if (arg_list[0]) arg_list[0]++; else arg_list[0] = xstrdup (pgmname); if (argv) for (i=0,j=1; argv[i]; i++, j++) arg_list[j] = (char*)argv[i]; /* Assign /dev/null to unused FDs. */ for (i=0; i <= 2; i++) { if (fds[i] == -1 ) { fds[i] = open ("/dev/null", i? O_WRONLY : O_RDONLY); if (fds[i] == -1) log_fatal ("failed to open `%s': %s\n", "/dev/null", strerror (errno)); } } /* Connect the standard files. */ for (i=0; i <= 2; i++) { if (fds[i] != i && dup2 (fds[i], i) == -1) log_fatal ("dup2 std%s failed: %s\n", i==0?"in":i==1?"out":"err", strerror (errno)); } /* Close all other files. */ close_all_fds (3, NULL); if (preexec) preexec (); execv (pgmname, arg_list); /* No way to print anything, as we have closed all streams. */ _exit (127); } #endif /*!HAVE_W32_SYSTEM*/ /* Portable function to create a pipe. Under Windows the write end is inheritable. */ gpg_error_t gnupg_create_inbound_pipe (int filedes[2]) { gpg_error_t err = 0; #if HAVE_W32_SYSTEM int fds[2]; filedes[0] = filedes[1] = -1; err = gpg_error (GPG_ERR_GENERAL); if (!create_inheritable_pipe_w (fds)) { filedes[0] = _open_osfhandle (fds[0], 0); if (filedes[0] == -1) { log_error ("failed to translate osfhandle %p\n", (void*)fds[0]); CloseHandle (fd_to_handle (fds[1])); } else { filedes[1] = _open_osfhandle (fds[1], 1); if (filedes[1] == -1) { log_error ("failed to translate osfhandle %p\n", (void*)fds[1]); close (filedes[0]); filedes[0] = -1; CloseHandle (fd_to_handle (fds[1])); } else err = 0; } } #else if (pipe (filedes) == -1) { err = gpg_error_from_syserror (); filedes[0] = filedes[1] = -1; } #endif return err; } /* Portable function to create a pipe. Under Windows the read end is inheritable. */ gpg_error_t gnupg_create_outbound_pipe (int filedes[2]) { gpg_error_t err = 0; #if HAVE_W32_SYSTEM int fds[2]; filedes[0] = filedes[1] = -1; err = gpg_error (GPG_ERR_GENERAL); if (!create_inheritable_pipe_r (fds)) { filedes[0] = _open_osfhandle (fds[0], 0); if (filedes[0] == -1) { log_error ("failed to translate osfhandle %p\n", (void*)fds[0]); CloseHandle (fd_to_handle (fds[1])); } else { filedes[1] = _open_osfhandle (fds[1], 1); if (filedes[1] == -1) { log_error ("failed to translate osfhandle %p\n", (void*)fds[1]); close (filedes[0]); filedes[0] = -1; CloseHandle (fd_to_handle (fds[1])); } else err = 0; } } #else if (pipe (filedes) == -1) { err = gpg_error_from_syserror (); filedes[0] = filedes[1] = -1; } #endif return err; } /* Fork and exec the PGMNAME, connect the file descriptor of INFILE to stdin, write the output to OUTFILE, return a new stream in STATUSFILE for stderr and the pid of the process in PID. The arguments for the process are expected in the NULL terminated array ARGV. The program name itself should not be included there. If PREEXEC is not NULL, that function will be called right before the exec. Calling gnupg_wait_process is required. FLAGS is a bit vector with just one bit defined for now: Bit 7: If set the process will be started as a background process. This flag is only useful under W32 systems, so that no new console is created and pops up a console window when starting the server Bit 6: On W32 run AllowSetForegroundWindow for the child. Due to error problems this actually allows SetForegroundWindow for childs of this process. Returns 0 on success or an error code. */ gpg_error_t gnupg_spawn_process (const char *pgmname, const char *argv[], FILE *infile, estream_t outfile, void (*preexec)(void), unsigned int flags, FILE **statusfile, pid_t *pid) { #ifdef HAVE_W32_SYSTEM gpg_error_t err; SECURITY_ATTRIBUTES sec_attr; PROCESS_INFORMATION pi = { NULL, /* Returns process handle. */ 0, /* Returns primary thread handle. */ 0, /* Returns pid. */ 0 /* Returns tid. */ }; STARTUPINFO si; int cr_flags; char *cmdline; int fd, fdout, rp[2]; (void)preexec; /* Setup return values. */ *statusfile = NULL; *pid = (pid_t)(-1); fflush (infile); rewind (infile); fd = _get_osfhandle (fileno (infile)); fdout = _get_osfhandle (es_fileno (outfile)); if (fd == -1 || fdout == -1) log_fatal ("no file descriptor for file passed to gnupg_spawn_process\n"); /* Prepare security attributes. */ memset (&sec_attr, 0, sizeof sec_attr ); sec_attr.nLength = sizeof sec_attr; sec_attr.bInheritHandle = FALSE; /* Build the command line. */ err = build_w32_commandline (pgmname, argv, &cmdline); if (err) return err; /* Create a pipe. */ if (create_inheritable_pipe_w (rp)) { err = gpg_error (GPG_ERR_GENERAL); log_error (_("error creating a pipe: %s\n"), gpg_strerror (err)); xfree (cmdline); return err; } /* Start the process. Note that we can't run the PREEXEC function because this would change our own environment. */ memset (&si, 0, sizeof si); si.cb = sizeof (si); si.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW; si.wShowWindow = DEBUG_W32_SPAWN? SW_SHOW : SW_MINIMIZE; si.hStdInput = fd_to_handle (fd); si.hStdOutput = fd_to_handle (fdout); si.hStdError = fd_to_handle (rp[1]); cr_flags = (CREATE_DEFAULT_ERROR_MODE | ((flags & 128)? DETACHED_PROCESS : 0) | GetPriorityClass (GetCurrentProcess ()) | CREATE_SUSPENDED); /* log_debug ("CreateProcess, path=`%s' cmdline=`%s'\n", pgmname, cmdline); */ if (!CreateProcess (pgmname, /* Program to start. */ cmdline, /* Command line arguments. */ &sec_attr, /* Process security attributes. */ &sec_attr, /* Thread security attributes. */ TRUE, /* Inherit handles. */ cr_flags, /* Creation flags. */ NULL, /* Environment. */ NULL, /* Use current drive/directory. */ &si, /* Startup information. */ &pi /* Returns process information. */ )) { log_error ("CreateProcess failed: %s\n", w32_strerror (-1)); xfree (cmdline); CloseHandle (fd_to_handle (rp[0])); CloseHandle (fd_to_handle (rp[1])); return gpg_error (GPG_ERR_GENERAL); } xfree (cmdline); cmdline = NULL; /* Close the other end of the pipe. */ CloseHandle (fd_to_handle (rp[1])); /* log_debug ("CreateProcess ready: hProcess=%p hThread=%p" */ /* " dwProcessID=%d dwThreadId=%d\n", */ /* pi.hProcess, pi.hThread, */ /* (int) pi.dwProcessId, (int) pi.dwThreadId); */ /* Fixme: For unknown reasons AllowSetForegroundWindow returns an invalid argument error if we pass the correct processID to it. As a workaround we use -1 (ASFW_ANY). */ if ( (flags & 64) ) gnupg_allow_set_foregound_window ((pid_t)(-1)/*pi.dwProcessId*/); /* Process has been created suspended; resume it now. */ ResumeThread (pi.hThread); CloseHandle (pi.hThread); { int x; x = _open_osfhandle (rp[0], 0); if (x == -1) log_error ("failed to translate osfhandle %p\n", (void*)rp[0] ); else *statusfile = fdopen (x, "r"); } if (!*statusfile) { err = gpg_error_from_syserror (); log_error (_("can't fdopen pipe for reading: %s\n"), gpg_strerror (err)); CloseHandle (pi.hProcess); return err; } *pid = handle_to_pid (pi.hProcess); return 0; #else /* !HAVE_W32_SYSTEM */ gpg_error_t err; int fd, fdout, rp[2]; (void)flags; /* Currently not used. */ *statusfile = NULL; *pid = (pid_t)(-1); fflush (infile); rewind (infile); fd = fileno (infile); fdout = es_fileno (outfile); if (fd == -1 || fdout == -1) log_fatal ("no file descriptor for file passed to gnupg_spawn_process\n"); if (pipe (rp) == -1) { err = gpg_error_from_syserror (); log_error (_("error creating a pipe: %s\n"), strerror (errno)); return err; } #ifdef USE_GNU_PTH *pid = pth_fork? pth_fork () : fork (); #else *pid = fork (); #endif if (*pid == (pid_t)(-1)) { err = gpg_error_from_syserror (); log_error (_("error forking process: %s\n"), strerror (errno)); close (rp[0]); close (rp[1]); return err; } if (!*pid) { gcry_control (GCRYCTL_TERM_SECMEM); /* Run child. */ do_exec (pgmname, argv, fd, fdout, rp[1], preexec); /*NOTREACHED*/ } /* Parent. */ close (rp[1]); *statusfile = fdopen (rp[0], "r"); if (!*statusfile) { err = gpg_error_from_syserror (); log_error (_("can't fdopen pipe for reading: %s\n"), strerror (errno)); kill (*pid, SIGTERM); *pid = (pid_t)(-1); return err; } return 0; #endif /* !HAVE_W32_SYSTEM */ } /* Simplified version of gnupg_spawn_process. This function forks and then execs PGMNAME, while connecting INFD to stdin, OUTFD to stdout and ERRFD to stderr (any of them may be -1 to connect them to /dev/null). The arguments for the process are expected in the NULL terminated array ARGV. The program name itself should not be included there. Calling gnupg_wait_process is required. Returns 0 on success or an error code. */ gpg_error_t gnupg_spawn_process_fd (const char *pgmname, const char *argv[], int infd, int outfd, int errfd, pid_t *pid) { #ifdef HAVE_W32_SYSTEM gpg_error_t err; SECURITY_ATTRIBUTES sec_attr; PROCESS_INFORMATION pi = { NULL, 0, 0, 0 }; STARTUPINFO si; char *cmdline; int i; HANDLE stdhd[3]; /* Setup return values. */ *pid = (pid_t)(-1); /* Prepare security attributes. */ memset (&sec_attr, 0, sizeof sec_attr ); sec_attr.nLength = sizeof sec_attr; sec_attr.bInheritHandle = FALSE; /* Build the command line. */ err = build_w32_commandline (pgmname, argv, &cmdline); if (err) return err; memset (&si, 0, sizeof si); si.cb = sizeof (si); si.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW; si.wShowWindow = DEBUG_W32_SPAWN? SW_SHOW : SW_MINIMIZE; stdhd[0] = infd == -1? w32_open_null (0) : INVALID_HANDLE_VALUE; stdhd[1] = outfd == -1? w32_open_null (1) : INVALID_HANDLE_VALUE; stdhd[2] = errfd == -1? w32_open_null (1) : INVALID_HANDLE_VALUE; si.hStdInput = infd == -1? stdhd[0] : (void*)_get_osfhandle (infd); si.hStdOutput = outfd == -1? stdhd[1] : (void*)_get_osfhandle (outfd); si.hStdError = errfd == -1? stdhd[2] : (void*)_get_osfhandle (errfd); /* log_debug ("CreateProcess, path=`%s' cmdline=`%s'\n", pgmname, cmdline); */ if (!CreateProcess (pgmname, /* Program to start. */ cmdline, /* Command line arguments. */ &sec_attr, /* Process security attributes. */ &sec_attr, /* Thread security attributes. */ TRUE, /* Inherit handles. */ (CREATE_DEFAULT_ERROR_MODE | GetPriorityClass (GetCurrentProcess ()) | CREATE_SUSPENDED | DETACHED_PROCESS), NULL, /* Environment. */ NULL, /* Use current drive/directory. */ &si, /* Startup information. */ &pi /* Returns process information. */ )) { log_error ("CreateProcess failed: %s\n", w32_strerror (-1)); err = gpg_error (GPG_ERR_GENERAL); } else err = 0; xfree (cmdline); for (i=0; i < 3; i++) if (stdhd[i] != INVALID_HANDLE_VALUE) CloseHandle (stdhd[i]); if (err) return err; /* log_debug ("CreateProcess ready: hProcess=%p hThread=%p" */ /* " dwProcessID=%d dwThreadId=%d\n", */ /* pi.hProcess, pi.hThread, */ /* (int) pi.dwProcessId, (int) pi.dwThreadId); */ /* Process has been created suspended; resume it now. */ ResumeThread (pi.hThread); CloseHandle (pi.hThread); *pid = handle_to_pid (pi.hProcess); return 0; #else /* !HAVE_W32_SYSTEM */ gpg_error_t err; #ifdef USE_GNU_PTH *pid = pth_fork? pth_fork () : fork (); #else *pid = fork (); #endif if (*pid == (pid_t)(-1)) { err = gpg_error_from_syserror (); log_error (_("error forking process: %s\n"), strerror (errno)); return err; } if (!*pid) { gcry_control (GCRYCTL_TERM_SECMEM); /* Run child. */ do_exec (pgmname, argv, infd, outfd, errfd, NULL); /*NOTREACHED*/ } return 0; #endif /* !HAVE_W32_SYSTEM */ } /* Wait for the process identified by PID to terminate. PGMNAME should be the same as supplied to the spawn function and is only used for diagnostics. Returns 0 if the process succeeded, GPG_ERR_GENERAL for any failures of the spawned program or other error codes. If EXITCODE is not NULL the exit code of the process is stored at this address or -1 if it could not be retrieved. */ gpg_error_t gnupg_wait_process (const char *pgmname, pid_t pid, int *exitcode) { gpg_err_code_t ec; #ifdef HAVE_W32_SYSTEM HANDLE proc = fd_to_handle (pid); int code; DWORD exc; if (exitcode) *exitcode = -1; if (pid == (pid_t)(-1)) return gpg_error (GPG_ERR_INV_VALUE); /* FIXME: We should do a pth_waitpid here. However this has not yet been implemented. A special W32 pth system call would even be better. */ code = WaitForSingleObject (proc, INFINITE); switch (code) { case WAIT_FAILED: log_error (_("waiting for process %d to terminate failed: %s\n"), (int)pid, w32_strerror (-1)); ec = GPG_ERR_GENERAL; break; case WAIT_OBJECT_0: if (!GetExitCodeProcess (proc, &exc)) { log_error (_("error getting exit code of process %d: %s\n"), (int)pid, w32_strerror (-1) ); ec = GPG_ERR_GENERAL; } else if (exc) { log_error (_("error running `%s': exit status %d\n"), pgmname, (int)exc ); if (exitcode) *exitcode = (int)exc; ec = GPG_ERR_GENERAL; } else { if (exitcode) *exitcode = 0; ec = 0; } CloseHandle (proc); break; default: log_error ("WaitForSingleObject returned unexpected " "code %d for pid %d\n", code, (int)pid ); ec = GPG_ERR_GENERAL; break; } #else /* !HAVE_W32_SYSTEM */ int i, status; if (exitcode) *exitcode = -1; if (pid == (pid_t)(-1)) return gpg_error (GPG_ERR_INV_VALUE); #ifdef USE_GNU_PTH i = pth_waitpid ? pth_waitpid (pid, &status, 0) : waitpid (pid, &status, 0); #else while ( (i=waitpid (pid, &status, 0)) == -1 && errno == EINTR) ; #endif if (i == (pid_t)(-1)) { log_error (_("waiting for process %d to terminate failed: %s\n"), (int)pid, strerror (errno)); ec = gpg_err_code_from_errno (errno); } else if (WIFEXITED (status) && WEXITSTATUS (status) == 127) { log_error (_("error running `%s': probably not installed\n"), pgmname); ec = GPG_ERR_CONFIGURATION; } else if (WIFEXITED (status) && WEXITSTATUS (status)) { log_error (_("error running `%s': exit status %d\n"), pgmname, WEXITSTATUS (status)); if (exitcode) *exitcode = WEXITSTATUS (status); ec = GPG_ERR_GENERAL; } else if (!WIFEXITED (status)) { log_error (_("error running `%s': terminated\n"), pgmname); ec = GPG_ERR_GENERAL; } else { if (exitcode) *exitcode = 0; ec = 0; } #endif /* !HAVE_W32_SYSTEM */ return gpg_err_make (GPG_ERR_SOURCE_DEFAULT, ec); } /* Spawn a new process and immediatley detach from it. The name of the program to exec is PGMNAME and its arguments are in ARGV (the programname is automatically passed as first argument). Environment strings in ENVP are set. An error is returned if pgmname is not executable; to make this work it is necessary to provide an absolute file name. All standard file descriptors are connected to /dev/null. */ gpg_error_t gnupg_spawn_process_detached (const char *pgmname, const char *argv[], const char *envp[] ) { #ifdef HAVE_W32_SYSTEM gpg_error_t err; SECURITY_ATTRIBUTES sec_attr; PROCESS_INFORMATION pi = { NULL, /* Returns process handle. */ 0, /* Returns primary thread handle. */ 0, /* Returns pid. */ 0 /* Returns tid. */ }; STARTUPINFO si; int cr_flags; char *cmdline; /* FIXME: We don't make use of ENVP yet. It is currently only used to pass the GPG_AGENT_INFO variable to gpg-agent. As the default on windows is to use a standard socket, this does not really matter. */ (void)envp; if (access (pgmname, X_OK)) return gpg_error_from_syserror (); /* Prepare security attributes. */ memset (&sec_attr, 0, sizeof sec_attr ); sec_attr.nLength = sizeof sec_attr; sec_attr.bInheritHandle = FALSE; /* Build the command line. */ err = build_w32_commandline (pgmname, argv, &cmdline); if (err) return err; /* Start the process. */ memset (&si, 0, sizeof si); si.cb = sizeof (si); si.dwFlags = STARTF_USESHOWWINDOW; si.wShowWindow = DEBUG_W32_SPAWN? SW_SHOW : SW_MINIMIZE; cr_flags = (CREATE_DEFAULT_ERROR_MODE | GetPriorityClass (GetCurrentProcess ()) | CREATE_NEW_PROCESS_GROUP | DETACHED_PROCESS); /* log_debug ("CreateProcess(detached), path=`%s' cmdline=`%s'\n", */ /* pgmname, cmdline); */ if (!CreateProcess (pgmname, /* Program to start. */ cmdline, /* Command line arguments. */ &sec_attr, /* Process security attributes. */ &sec_attr, /* Thread security attributes. */ FALSE, /* Inherit handles. */ cr_flags, /* Creation flags. */ NULL, /* Environment. */ NULL, /* Use current drive/directory. */ &si, /* Startup information. */ &pi /* Returns process information. */ )) { log_error ("CreateProcess(detached) failed: %s\n", w32_strerror (-1)); xfree (cmdline); return gpg_error (GPG_ERR_GENERAL); } xfree (cmdline); cmdline = NULL; /* log_debug ("CreateProcess(detached) ready: hProcess=%p hThread=%p" */ /* " dwProcessID=%d dwThreadId=%d\n", */ /* pi.hProcess, pi.hThread, */ /* (int) pi.dwProcessId, (int) pi.dwThreadId); */ CloseHandle (pi.hThread); return 0; #else pid_t pid; int i; if (getuid() != geteuid()) return gpg_error (GPG_ERR_BUG); if (access (pgmname, X_OK)) return gpg_error_from_syserror (); #ifdef USE_GNU_PTH pid = pth_fork? pth_fork () : fork (); #else pid = fork (); #endif if (pid == (pid_t)(-1)) { log_error (_("error forking process: %s\n"), strerror (errno)); return gpg_error_from_syserror (); } if (!pid) { gcry_control (GCRYCTL_TERM_SECMEM); if (setsid() == -1 || chdir ("/")) _exit (1); pid = fork (); /* Double fork to let init takes over the new child. */ if (pid == (pid_t)(-1)) _exit (1); if (pid) _exit (0); /* Let the parent exit immediately. */ if (envp) for (i=0; envp[i]; i++) putenv (xstrdup (envp[i])); do_exec (pgmname, argv, -1, -1, -1, NULL); /*NOTREACHED*/ } if (waitpid (pid, NULL, 0) == -1) log_error ("waitpid failed in gnupg_spawn_process_detached: %s", strerror (errno)); return 0; #endif /* !HAVE_W32_SYSTEM*/ } /* Kill a process; that is send an appropriate signal to the process. gnupg_wait_process must be called to actually remove the process from the system. An invalid PID is ignored. */ void gnupg_kill_process (pid_t pid) { #ifdef HAVE_W32_SYSTEM /* Older versions of libassuan set PID to 0 on Windows to indicate an invalid value. */ if (pid != (pid_t) INVALID_HANDLE_VALUE && pid != 0) { HANDLE process = (HANDLE) pid; /* Arbitrary error code. */ TerminateProcess (process, 1); } #else if (pid != (pid_t)(-1)) { kill (pid, SIGTERM); } #endif } diff --git a/common/exechelp.h b/common/exechelp.h index 06cb79c29..c5ecc0dea 100644 --- a/common/exechelp.h +++ b/common/exechelp.h @@ -1,110 +1,110 @@ /* exechelp.h - Definitions for the fork and exec helpers * Copyright (C) 2004, 2009 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 3 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, see . */ #ifndef GNUPG_COMMON_EXECHELP_H #define GNUPG_COMMON_EXECHELP_H -#include "estream.h" +#include "../common/estream.h" /* Return the maximum number of currently allowed file descriptors. Only useful on POSIX systems. */ int get_max_fds (void); /* Close all file descriptors starting with descriptor FIRST. If EXCEPT is not NULL, it is expected to be a list of file descriptors which are not to close. This list shall be sorted in ascending order with its end marked by -1. */ void close_all_fds (int first, int *except); /* Returns an array with all currently open file descriptors. The end of the array is marked by -1. The caller needs to release this array using the *standard free* and not with xfree. This allow the use of this fucntion right at startup even before libgcrypt has been initialized. Returns NULL on error and sets ERRNO accordingly. */ int *get_all_open_fds (void); /* Portable function to create a pipe. Under Windows the write end is inheritable. */ gpg_error_t gnupg_create_inbound_pipe (int filedes[2]); /* Portable function to create a pipe. Under Windows the read end is inheritable. */ gpg_error_t gnupg_create_outbound_pipe (int filedes[2]); /* Fork and exec the PGMNAME, connect the file descriptor of INFILE to stdin, write the output to OUTFILE, return a new stream in STATUSFILE for stderr and the pid of the process in PID. The arguments for the process are expected in the NULL terminated array ARGV. The program name itself should not be included there. If PREEXEC is not NULL, that function will be called right before the exec. FLAGS is currently only useful for W32, see the source for details. Calling gnupg_wait_process is required. Returns 0 on success or an error code. */ gpg_error_t gnupg_spawn_process (const char *pgmname, const char *argv[], FILE *infile, estream_t outfile, void (*preexec)(void), unsigned int flags, FILE **statusfile, pid_t *pid); /* Simplified version of gnupg_spawn_process. This function forks and then execs PGMNAME, while connecting INFD to stdin, OUTFD to stdout and ERRFD to stderr (any of them may be -1 to connect them to /dev/null). The arguments for the process are expected in the NULL terminated array ARGV. The program name itself should not be included there. Calling gnupg_wait_process is required. Returns 0 on success or an error code. */ gpg_error_t gnupg_spawn_process_fd (const char *pgmname, const char *argv[], int infd, int outfd, int errfd, pid_t *pid); /* Wait for the process identified by PID to terminate. PGMNAME should be the same as supplied to the spawn fucntion and is only used for diagnostics. Returns 0 if the process succeded, GPG_ERR_GENERAL for any failures of the spawned program or other error codes. If EXITCODE is not NULL the exit code of the process is stored at this address or -1 if it could not be retrieved. */ gpg_error_t gnupg_wait_process (const char *pgmname, pid_t pid, int *exitcode); /* Kill a process; that is send an appropriate signal to the process. gnupg_wait_process must be called to actually remove the process from the system. An invalid PID is ignored. */ void gnupg_kill_process (pid_t pid); /* Spawn a new process and immediatley detach from it. The name of the program to exec is PGMNAME and its arguments are in ARGV (the programname is automatically passed as first argument). Environment strings in ENVP are set. An error is returned if pgmname is not executable; to make this work it is necessary to provide an absolute file name. */ gpg_error_t gnupg_spawn_process_detached (const char *pgmname, const char *argv[], const char *envp[] ); #endif /*GNUPG_COMMON_EXECHELP_H*/ diff --git a/common/http.h b/common/http.h index 28a5304eb..e7120f561 100644 --- a/common/http.h +++ b/common/http.h @@ -1,116 +1,116 @@ /* http.h - HTTP protocol handler * Copyright (C) 1999, 2000, 2001, 2003, * 2006 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 3 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, see . */ #ifndef GNUPG_COMMON_HTTP_H #define GNUPG_COMMON_HTTP_H #include #ifdef HTTP_USE_ESTREAM -#include "estream.h" +#include "../common/estream.h" #endif struct uri_tuple_s { struct uri_tuple_s *next; const char *name; /* A pointer into name. */ char *value; /* A pointer to value (a Nul is always appended). */ size_t valuelen; /* The real length of the value; we need it because the value may contain embedded Nuls. */ int no_value; /* True if no value has been given in the URL. */ }; typedef struct uri_tuple_s *uri_tuple_t; struct parsed_uri_s { /* All these pointers point into BUFFER; most stuff is not escaped. */ char *scheme; /* Pointer to the scheme string (lowercase). */ int use_tls; /* Whether TLS should be used. */ char *auth; /* username/password for basic auth */ char *host; /* Host (converted to lowercase). */ unsigned short port; /* Port (always set if the host is set). */ char *path; /* Path. */ uri_tuple_t params; /* ";xxxxx" */ uri_tuple_t query; /* "?xxx=yyy" */ char buffer[1]; /* Buffer which holds a (modified) copy of the URI. */ }; typedef struct parsed_uri_s *parsed_uri_t; typedef enum { HTTP_REQ_GET = 1, HTTP_REQ_HEAD = 2, HTTP_REQ_POST = 3 } http_req_t; /* We put the flag values into an enum, so that gdb can display them. */ enum { HTTP_FLAG_TRY_PROXY = 1, HTTP_FLAG_NO_SHUTDOWN = 2, HTTP_FLAG_LOG_RESP = 4, HTTP_FLAG_NEED_HEADER = 8 }; struct http_context_s; typedef struct http_context_s *http_t; void http_register_tls_callback (gpg_error_t (*cb) (http_t, void *, int)); gpg_error_t http_parse_uri (parsed_uri_t *ret_uri, const char *uri); void http_release_parsed_uri (parsed_uri_t uri); gpg_error_t http_open (http_t *r_hd, http_req_t reqtype, const char *url, const char *auth, unsigned int flags, const char *proxy, void *tls_context, const char *srvtag, strlist_t headers); void http_start_data (http_t hd); gpg_error_t http_wait_response (http_t hd); void http_close (http_t hd, int keep_read_stream); gpg_error_t http_open_document (http_t *r_hd, const char *document, const char *auth, unsigned int flags, const char *proxy, void *tls_context, const char *srvtag, strlist_t headers); #ifdef HTTP_USE_ESTREAM estream_t http_get_read_ptr (http_t hd); estream_t http_get_write_ptr (http_t hd); #else /*!HTTP_USE_ESTREAM*/ FILE *http_get_read_ptr (http_t hd); FILE *http_get_write_ptr (http_t hd); #endif /*!HTTP_USE_ESTREAM*/ unsigned int http_get_status_code (http_t hd); const char *http_get_header (http_t hd, const char *name); char *http_escape_string (const char *string, const char *specials); #endif /*GNUPG_COMMON_HTTP_H*/ diff --git a/common/i18n.h b/common/i18n.h index 7405f9a55..abb8bd83e 100644 --- a/common/i18n.h +++ b/common/i18n.h @@ -1,47 +1,47 @@ /* i18n.h * Copyright (C) 1998, 2001 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. */ #ifndef GNUPG_COMMON_I18N_H #define GNUPG_COMMON_I18N_H #ifdef USE_SIMPLE_GETTEXT -# include "../jnlib/w32help.h" +# include "../common/w32help.h" # define _(a) gettext (a) # define N_(a) (a) #else # ifdef HAVE_LOCALE_H # include # endif # ifdef ENABLE_NLS # include # define _(a) gettext (a) # ifdef gettext_noop # define N_(a) gettext_noop (a) # else # define N_(a) (a) # endif # else # define _(a) (a) # define N_(a) (a) # define ngettext(a,b,c) ((c)==1? (a):(b)) # endif #endif /*!USE_SIMPLE_GETTEXT*/ void i18n_init (void); char *i18n_switchto_utf8 (void); void i18n_switchback (char *saved_codeset); const char *i18n_utf8 (const char *string); #endif /*GNUPG_COMMON_I18N_H*/ diff --git a/common/init.c b/common/init.c index 5425acee8..d8e0be7bf 100644 --- a/common/init.c +++ b/common/init.c @@ -1,71 +1,70 @@ /* init.c - Various initializations * Copyright (C) 2007 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 3 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, see . */ #include #ifdef WITHOUT_GNU_PTH /* Give the Makefile a chance to build without Pth. */ #undef HAVE_PTH #undef USE_GNU_PTH #endif #ifdef HAVE_W32_SYSTEM #include #endif #ifdef HAVE_PTH #include #endif -#include "estream.h" #include "util.h" /* This function is to be used early at program startup to make sure that some subsystems are initialized. This is in particular important for W32 to initialize the sockets so that our socket emulation code used directly as well as in libassuan may be used. It should best be called before any I/O is done so that setup required for logging is ready. CAUTION: This might be called while running suid(root). */ void init_common_subsystems (void) { /* Try to auto set the character set. */ set_native_charset (NULL); #ifdef HAVE_W32_SYSTEM /* For W32 we need to initialize the socket layer. This is because we use recv and send in libassuan as well as at some other places. If we are building with PTH we let pth_init do it. We can't do much on error so we ignore them. An error would anyway later pop up if one of the socket functions is used. */ # ifdef HAVE_PTH pth_init (); # else { WSADATA wsadat; WSAStartup (0x202, &wsadat); } # endif /*!HAVE_PTH*/ #endif /* Initialize the Estream library. */ es_init (); } diff --git a/common/iobuf.c b/common/iobuf.c index 87af2868f..441c69467 100644 --- a/common/iobuf.c +++ b/common/iobuf.c @@ -1,2440 +1,2440 @@ /* iobuf.c - File Handling for OpenPGP. * Copyright (C) 1998, 1999, 2000, 2001, 2003, 2004, 2006, 2007, 2008, * 2009, 2010 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 3 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, see . */ #include #include #include #include #include #include #include #include #include #include #include #ifdef HAVE_W32_SYSTEM # include #endif #ifdef __riscos__ # include # include #endif /* __riscos__ */ #include "util.h" #include "sysutils.h" #include "iobuf.h" /*-- Begin configurable part. --*/ /* The size of the internal buffers. NOTE: If you change this value you MUST also adjust the regression test "armored_key_8192" in armor.test! */ #define IOBUF_BUFFER_SIZE 8192 /*-- End configurable part. --*/ #ifdef HAVE_W32_SYSTEM # define FD_FOR_STDIN (GetStdHandle (STD_INPUT_HANDLE)) # define FD_FOR_STDOUT (GetStdHandle (STD_OUTPUT_HANDLE)) #else /*!HAVE_W32_SYSTEM*/ # define FD_FOR_STDIN (0) # define FD_FOR_STDOUT (1) #endif /*!HAVE_W32_SYSTEM*/ /* The context used by the file filter. */ typedef struct { gnupg_fd_t fp; /* Open file pointer or handle. */ int keep_open; int no_cache; int eof_seen; int print_only_name; /* Flags indicating that fname is not a real file. */ char fname[1]; /* Name of the file. */ } file_filter_ctx_t; /* Object to control the "close cache". */ struct close_cache_s { struct close_cache_s *next; gnupg_fd_t fp; char fname[1]; }; typedef struct close_cache_s *close_cache_t; static close_cache_t close_cache; #ifdef HAVE_W32_SYSTEM typedef struct { int sock; int keep_open; int no_cache; int eof_seen; int print_only_name; /* Flag indicating that fname is not a real file. */ char fname[1]; /* Name of the file */ } sock_filter_ctx_t; #endif /*HAVE_W32_SYSTEM*/ /* The first partial length header block must be of size 512 * to make it easier (and efficienter) we use a min. block size of 512 * for all chunks (but the last one) */ #define OP_MIN_PARTIAL_CHUNK 512 #define OP_MIN_PARTIAL_CHUNK_2POW 9 /* The context we use for the block filter (used to handle OpenPGP length information header). */ typedef struct { int use; size_t size; size_t count; int partial; /* 1 = partial header, 2 in last partial packet. */ char *buffer; /* Used for partial header. */ size_t buflen; /* Used size of buffer. */ int first_c; /* First character of a partial header (which is > 0). */ int eof; } block_filter_ctx_t; /* Global flag to tell whether special file names are enabled. See gpg.c for an explanation of these file names. FIXME: it does not belong into the iobuf subsystem. */ static int special_names_enabled; /* Local prototypes. */ static int underflow (iobuf_t a); static int translate_file_handle (int fd, int for_write); /* This is a replacement for strcmp. Under W32 it does not distinguish between backslash and slash. */ static int fd_cache_strcmp (const char *a, const char *b) { #ifdef HAVE_DOSISH_SYSTEM for (; *a && *b; a++, b++) { if (*a != *b && !((*a == '/' && *b == '\\') || (*a == '\\' && *b == '/')) ) break; } return *(const unsigned char *)a - *(const unsigned char *)b; #else return strcmp (a, b); #endif } /* * Invalidate (i.e. close) a cached iobuf */ static int fd_cache_invalidate (const char *fname) { close_cache_t cc; int rc = 0; assert (fname); if (DBG_IOBUF) log_debug ("fd_cache_invalidate (%s)\n", fname); for (cc = close_cache; cc; cc = cc->next) { if (cc->fp != GNUPG_INVALID_FD && !fd_cache_strcmp (cc->fname, fname)) { if (DBG_IOBUF) log_debug (" did (%s)\n", cc->fname); #ifdef HAVE_W32_SYSTEM if (!CloseHandle (cc->fp)) rc = -1; #else rc = close (cc->fp); #endif cc->fp = GNUPG_INVALID_FD; } } return rc; } /* Try to sync changes to the disk. This is to avoid data loss during a system crash in write/close/rename cycle on some file systems. */ static int fd_cache_synchronize (const char *fname) { int err = 0; #ifdef HAVE_FSYNC close_cache_t cc; if (DBG_IOBUF) log_debug ("fd_cache_synchronize (%s)\n", fname); for (cc=close_cache; cc; cc = cc->next ) { if (cc->fp != GNUPG_INVALID_FD && !fd_cache_strcmp (cc->fname, fname)) { if (DBG_IOBUF) log_debug (" did (%s)\n", cc->fname); err = fsync (cc->fp); } } #else (void)fname; #endif /*HAVE_FSYNC*/ return err; } static gnupg_fd_t direct_open (const char *fname, const char *mode) { #ifdef HAVE_W32_SYSTEM unsigned long da, cd, sm; HANDLE hfile; /* Note, that we do not handle all mode combinations */ /* According to the ReactOS source it seems that open() of the * standard MSW32 crt does open the file in shared mode which is * something new for MS applications ;-) */ if (strchr (mode, '+')) { if (fd_cache_invalidate (fname)) return GNUPG_INVALID_FD; da = GENERIC_READ | GENERIC_WRITE; cd = OPEN_EXISTING; sm = FILE_SHARE_READ | FILE_SHARE_WRITE; } else if (strchr (mode, 'w')) { if (fd_cache_invalidate (fname)) return GNUPG_INVALID_FD; da = GENERIC_WRITE; cd = CREATE_ALWAYS; sm = FILE_SHARE_WRITE; } else { da = GENERIC_READ; cd = OPEN_EXISTING; sm = FILE_SHARE_READ; } #ifdef HAVE_W32CE_SYSTEM { wchar_t *wfname = utf8_to_wchar (fname); if (wfname) { hfile = CreateFile (wfname, da, sm, NULL, cd, FILE_ATTRIBUTE_NORMAL, NULL); xfree (wfname); } else hfile = INVALID_HANDLE_VALUE; } #else hfile = CreateFile (fname, da, sm, NULL, cd, FILE_ATTRIBUTE_NORMAL, NULL); #endif return hfile; #else /*!HAVE_W32_SYSTEM*/ int oflag; int cflag = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH; /* Note, that we do not handle all mode combinations */ if (strchr (mode, '+')) { if (fd_cache_invalidate (fname)) return GNUPG_INVALID_FD; oflag = O_RDWR; } else if (strchr (mode, 'w')) { if (fd_cache_invalidate (fname)) return GNUPG_INVALID_FD; oflag = O_WRONLY | O_CREAT | O_TRUNC; } else { oflag = O_RDONLY; } #ifdef O_BINARY if (strchr (mode, 'b')) oflag |= O_BINARY; #endif /* No we need to distinguish between POSIX and RISC OS. */ #ifndef __riscos__ return open (fname, oflag, cflag); #else { struct stat buf; int rc = stat (fname, &buf); /* Don't allow iobufs on directories */ if (!rc && S_ISDIR (buf.st_mode) && !S_ISREG (buf.st_mode)) return __set_errno (EISDIR); else return open (fname, oflag, cflag); } #endif #endif /*!HAVE_W32_SYSTEM*/ } /* * Instead of closing an FD we keep it open and cache it for later reuse * Note that this caching strategy only works if the process does not chdir. */ static void fd_cache_close (const char *fname, gnupg_fd_t fp) { close_cache_t cc; assert (fp); if (!fname || !*fname) { #ifdef HAVE_W32_SYSTEM CloseHandle (fp); #else close (fp); #endif if (DBG_IOBUF) log_debug ("fd_cache_close (%d) real\n", (int)fp); return; } /* try to reuse a slot */ for (cc = close_cache; cc; cc = cc->next) { if (cc->fp == GNUPG_INVALID_FD && !fd_cache_strcmp (cc->fname, fname)) { cc->fp = fp; if (DBG_IOBUF) log_debug ("fd_cache_close (%s) used existing slot\n", fname); return; } } /* add a new one */ if (DBG_IOBUF) log_debug ("fd_cache_close (%s) new slot created\n", fname); cc = xcalloc (1, sizeof *cc + strlen (fname)); strcpy (cc->fname, fname); cc->fp = fp; cc->next = close_cache; close_cache = cc; } /* * Do an direct_open on FNAME but first try to reuse one from the fd_cache */ static gnupg_fd_t fd_cache_open (const char *fname, const char *mode) { close_cache_t cc; assert (fname); for (cc = close_cache; cc; cc = cc->next) { if (cc->fp != GNUPG_INVALID_FD && !fd_cache_strcmp (cc->fname, fname)) { gnupg_fd_t fp = cc->fp; cc->fp = GNUPG_INVALID_FD; if (DBG_IOBUF) log_debug ("fd_cache_open (%s) using cached fp\n", fname); #ifdef HAVE_W32_SYSTEM if (SetFilePointer (fp, 0, NULL, FILE_BEGIN) == 0xffffffff) { log_error ("rewind file failed on handle %p: ec=%d\n", fp, (int) GetLastError ()); fp = GNUPG_INVALID_FD; } #else if (lseek (fp, 0, SEEK_SET) == (off_t) - 1) { log_error ("can't rewind fd %d: %s\n", fp, strerror (errno)); fp = GNUPG_INVALID_FD; } #endif return fp; } } if (DBG_IOBUF) log_debug ("fd_cache_open (%s) not cached\n", fname); return direct_open (fname, mode); } /**************** * Read data from a file into buf which has an allocated length of *LEN. * return the number of read bytes in *LEN. OPAQUE is the FILE * of * the stream. A is not used. * control may be: * IOBUFCTRL_INIT: called just before the function is linked into the * list of function. This can be used to prepare internal * data structures of the function. * IOBUFCTRL_FREE: called just before the function is removed from the * list of functions and can be used to release internal * data structures or close a file etc. * IOBUFCTRL_UNDERFLOW: called by iobuf_underflow to fill the buffer * with new stuff. *RET_LEN is the available size of the * buffer, and should be set to the number of bytes * which were put into the buffer. The function * returns 0 to indicate success, -1 on EOF and * GPG_ERR_xxxxx for other errors. * * IOBUFCTRL_FLUSH: called by iobuf_flush() to write out the collected stuff. * *RET_LAN is the number of bytes in BUF. * * IOBUFCTRL_CANCEL: send to all filters on behalf of iobuf_cancel. The * filter may take appropriate action on this message. */ static int file_filter (void *opaque, int control, iobuf_t chain, byte * buf, size_t * ret_len) { file_filter_ctx_t *a = opaque; gnupg_fd_t f = a->fp; size_t size = *ret_len; size_t nbytes = 0; int rc = 0; (void)chain; /* Not used. */ if (control == IOBUFCTRL_UNDERFLOW) { assert (size); /* We need a buffer. */ if (a->eof_seen) { rc = -1; *ret_len = 0; } else { #ifdef HAVE_W32_SYSTEM unsigned long nread; nbytes = 0; if (!ReadFile (f, buf, size, &nread, NULL)) { int ec = (int) GetLastError (); if (ec != ERROR_BROKEN_PIPE) { rc = gpg_error_from_errno (ec); log_error ("%s: read error: ec=%d\n", a->fname, ec); } } else if (!nread) { a->eof_seen = 1; rc = -1; } else { nbytes = nread; } #else int n; nbytes = 0; do { n = read (f, buf, size); } while (n == -1 && errno == EINTR); if (n == -1) { /* error */ if (errno != EPIPE) { rc = gpg_error_from_syserror (); log_error ("%s: read error: %s\n", a->fname, strerror (errno)); } } else if (!n) { /* eof */ a->eof_seen = 1; rc = -1; } else { nbytes = n; } #endif *ret_len = nbytes; } } else if (control == IOBUFCTRL_FLUSH) { if (size) { #ifdef HAVE_W32_SYSTEM byte *p = buf; unsigned long n; nbytes = size; do { if (size && !WriteFile (f, p, nbytes, &n, NULL)) { int ec = (int) GetLastError (); rc = gpg_error_from_errno (ec); log_error ("%s: write error: ec=%d\n", a->fname, ec); break; } p += n; nbytes -= n; } while (nbytes); nbytes = p - buf; #else byte *p = buf; int n; nbytes = size; do { do { n = write (f, p, nbytes); } while (n == -1 && errno == EINTR); if (n > 0) { p += n; nbytes -= n; } } while (n != -1 && nbytes); if (n == -1) { rc = gpg_error_from_syserror (); log_error ("%s: write error: %s\n", a->fname, strerror (errno)); } nbytes = p - buf; #endif } *ret_len = nbytes; } else if (control == IOBUFCTRL_INIT) { a->eof_seen = 0; a->keep_open = 0; a->no_cache = 0; } else if (control == IOBUFCTRL_DESC) { *(char **) buf = "file_filter(fd)"; } else if (control == IOBUFCTRL_FREE) { if (f != FD_FOR_STDIN && f != FD_FOR_STDOUT) { if (DBG_IOBUF) log_debug ("%s: close fd/handle %d\n", a->fname, FD2INT (f)); if (!a->keep_open) fd_cache_close (a->no_cache ? NULL : a->fname, f); } f = GNUPG_INVALID_FD; xfree (a); /* We can free our context now. */ } return rc; } #ifdef HAVE_W32_SYSTEM /* Because network sockets are special objects under Lose32 we have to use a dedicated filter for them. */ static int sock_filter (void *opaque, int control, iobuf_t chain, byte * buf, size_t * ret_len) { sock_filter_ctx_t *a = opaque; size_t size = *ret_len; size_t nbytes = 0; int rc = 0; (void)chain; if (control == IOBUFCTRL_UNDERFLOW) { assert (size); /* need a buffer */ if (a->eof_seen) { rc = -1; *ret_len = 0; } else { int nread; nread = recv (a->sock, buf, size, 0); if (nread == SOCKET_ERROR) { int ec = (int) WSAGetLastError (); rc = gpg_error_from_errno (ec); log_error ("socket read error: ec=%d\n", ec); } else if (!nread) { a->eof_seen = 1; rc = -1; } else { nbytes = nread; } *ret_len = nbytes; } } else if (control == IOBUFCTRL_FLUSH) { if (size) { byte *p = buf; int n; nbytes = size; do { n = send (a->sock, p, nbytes, 0); if (n == SOCKET_ERROR) { int ec = (int) WSAGetLastError (); rc = gpg_error_from_errno (ec); log_error ("socket write error: ec=%d\n", ec); break; } p += n; nbytes -= n; } while (nbytes); nbytes = p - buf; } *ret_len = nbytes; } else if (control == IOBUFCTRL_INIT) { a->eof_seen = 0; a->keep_open = 0; a->no_cache = 0; } else if (control == IOBUFCTRL_DESC) { *(char **) buf = "sock_filter"; } else if (control == IOBUFCTRL_FREE) { if (!a->keep_open) closesocket (a->sock); xfree (a); /* we can free our context now */ } return rc; } #endif /*HAVE_W32_SYSTEM*/ /**************** * This is used to implement the block write mode. * Block reading is done on a byte by byte basis in readbyte(), * without a filter */ static int block_filter (void *opaque, int control, iobuf_t chain, byte * buffer, size_t * ret_len) { block_filter_ctx_t *a = opaque; char *buf = (char *)buffer; size_t size = *ret_len; int c, needed, rc = 0; char *p; if (control == IOBUFCTRL_UNDERFLOW) { size_t n = 0; p = buf; assert (size); /* need a buffer */ if (a->eof) /* don't read any further */ rc = -1; while (!rc && size) { if (!a->size) { /* get the length bytes */ if (a->partial == 2) { a->eof = 1; if (!n) rc = -1; break; } else if (a->partial) { /* These OpenPGP introduced huffman like encoded length * bytes are really a mess :-( */ if (a->first_c) { c = a->first_c; a->first_c = 0; } else if ((c = iobuf_get (chain)) == -1) { log_error ("block_filter: 1st length byte missing\n"); rc = GPG_ERR_BAD_DATA; break; } if (c < 192) { a->size = c; a->partial = 2; if (!a->size) { a->eof = 1; if (!n) rc = -1; break; } } else if (c < 224) { a->size = (c - 192) * 256; if ((c = iobuf_get (chain)) == -1) { log_error ("block_filter: 2nd length byte missing\n"); rc = GPG_ERR_BAD_DATA; break; } a->size += c + 192; a->partial = 2; if (!a->size) { a->eof = 1; if (!n) rc = -1; break; } } else if (c == 255) { a->size = iobuf_get (chain) << 24; a->size |= iobuf_get (chain) << 16; a->size |= iobuf_get (chain) << 8; if ((c = iobuf_get (chain)) == -1) { log_error ("block_filter: invalid 4 byte length\n"); rc = GPG_ERR_BAD_DATA; break; } a->size |= c; a->partial = 2; if (!a->size) { a->eof = 1; if (!n) rc = -1; break; } } else { /* Next partial body length. */ a->size = 1 << (c & 0x1f); } /* log_debug("partial: ctx=%p c=%02x size=%u\n", a, c, a->size); */ } else BUG (); } while (!rc && size && a->size) { needed = size < a->size ? size : a->size; c = iobuf_read (chain, p, needed); if (c < needed) { if (c == -1) c = 0; log_error ("block_filter %p: read error (size=%lu,a->size=%lu)\n", a, (ulong) size + c, (ulong) a->size + c); rc = GPG_ERR_BAD_DATA; } else { size -= c; a->size -= c; p += c; n += c; } } } *ret_len = n; } else if (control == IOBUFCTRL_FLUSH) { if (a->partial) { /* the complicated openpgp scheme */ size_t blen, n, nbytes = size + a->buflen; assert (a->buflen <= OP_MIN_PARTIAL_CHUNK); if (nbytes < OP_MIN_PARTIAL_CHUNK) { /* not enough to write a partial block out; so we store it */ if (!a->buffer) a->buffer = xmalloc (OP_MIN_PARTIAL_CHUNK); memcpy (a->buffer + a->buflen, buf, size); a->buflen += size; } else { /* okay, we can write out something */ /* do this in a loop to use the most efficient block lengths */ p = buf; do { /* find the best matching block length - this is limited * by the size of the internal buffering */ for (blen = OP_MIN_PARTIAL_CHUNK * 2, c = OP_MIN_PARTIAL_CHUNK_2POW + 1; blen <= nbytes; blen *= 2, c++) ; blen /= 2; c--; /* write the partial length header */ assert (c <= 0x1f); /*;-) */ c |= 0xe0; iobuf_put (chain, c); if ((n = a->buflen)) { /* write stuff from the buffer */ assert (n == OP_MIN_PARTIAL_CHUNK); if (iobuf_write (chain, a->buffer, n)) rc = gpg_error_from_syserror (); a->buflen = 0; nbytes -= n; } if ((n = nbytes) > blen) n = blen; if (n && iobuf_write (chain, p, n)) rc = gpg_error_from_syserror (); p += n; nbytes -= n; } while (!rc && nbytes >= OP_MIN_PARTIAL_CHUNK); /* store the rest in the buffer */ if (!rc && nbytes) { assert (!a->buflen); assert (nbytes < OP_MIN_PARTIAL_CHUNK); if (!a->buffer) a->buffer = xmalloc (OP_MIN_PARTIAL_CHUNK); memcpy (a->buffer, p, nbytes); a->buflen = nbytes; } } } else BUG (); } else if (control == IOBUFCTRL_INIT) { if (DBG_IOBUF) log_debug ("init block_filter %p\n", a); if (a->partial) a->count = 0; else if (a->use == 1) a->count = a->size = 0; else a->count = a->size; /* force first length bytes */ a->eof = 0; a->buffer = NULL; a->buflen = 0; } else if (control == IOBUFCTRL_DESC) { *(char **) buf = "block_filter"; } else if (control == IOBUFCTRL_FREE) { if (a->use == 2) { /* write the end markers */ if (a->partial) { u32 len; /* write out the remaining bytes without a partial header * the length of this header may be 0 - but if it is * the first block we are not allowed to use a partial header * and frankly we can't do so, because this length must be * a power of 2. This is _really_ complicated because we * have to check the possible length of a packet prior * to it's creation: a chain of filters becomes complicated * and we need a lot of code to handle compressed packets etc. * :-((((((( */ /* construct header */ len = a->buflen; /*log_debug("partial: remaining length=%u\n", len ); */ if (len < 192) rc = iobuf_put (chain, len); else if (len < 8384) { if (!(rc = iobuf_put (chain, ((len - 192) / 256) + 192))) rc = iobuf_put (chain, ((len - 192) % 256)); } else { /* use a 4 byte header */ if (!(rc = iobuf_put (chain, 0xff))) if (!(rc = iobuf_put (chain, (len >> 24) & 0xff))) if (!(rc = iobuf_put (chain, (len >> 16) & 0xff))) if (!(rc = iobuf_put (chain, (len >> 8) & 0xff))) rc = iobuf_put (chain, len & 0xff); } if (!rc && len) rc = iobuf_write (chain, a->buffer, len); if (rc) { log_error ("block_filter: write error: %s\n", strerror (errno)); rc = gpg_error_from_syserror (); } xfree (a->buffer); a->buffer = NULL; a->buflen = 0; } else BUG (); } else if (a->size) { log_error ("block_filter: pending bytes!\n"); } if (DBG_IOBUF) log_debug ("free block_filter %p\n", a); xfree (a); /* we can free our context now */ } return rc; } static void print_chain (iobuf_t a) { if (!DBG_IOBUF) return; for (; a; a = a->chain) { size_t dummy_len = 0; const char *desc = "[none]"; if (a->filter) a->filter (a->filter_ov, IOBUFCTRL_DESC, NULL, (byte *) & desc, &dummy_len); log_debug ("iobuf chain: %d.%d `%s' filter_eof=%d start=%d len=%d\n", a->no, a->subno, desc?desc:"?", a->filter_eof, (int) a->d.start, (int) a->d.len); } } int iobuf_print_chain (iobuf_t a) { print_chain (a); return 0; } /**************** * Allocate a new io buffer, with no function assigned. * Use is the desired usage: 1 for input, 2 for output, 3 for temp buffer * BUFSIZE is a suggested buffer size. */ iobuf_t iobuf_alloc (int use, size_t bufsize) { iobuf_t a; static int number = 0; a = xcalloc (1, sizeof *a); a->use = use; a->d.buf = xmalloc (bufsize); a->d.size = bufsize; a->no = ++number; a->subno = 0; a->opaque = NULL; a->real_fname = NULL; return a; } int iobuf_close (iobuf_t a) { iobuf_t a2; size_t dummy_len = 0; int rc = 0; if (a && a->directfp) { fclose (a->directfp); xfree (a->real_fname); if (DBG_IOBUF) log_debug ("iobuf_close -> %p\n", a->directfp); return 0; } for (; a && !rc; a = a2) { a2 = a->chain; if (a->use == 2 && (rc = iobuf_flush (a))) log_error ("iobuf_flush failed on close: %s\n", gpg_strerror (rc)); if (DBG_IOBUF) log_debug ("iobuf-%d.%d: close `%s'\n", a->no, a->subno, a->desc?a->desc:"?"); if (a->filter && (rc = a->filter (a->filter_ov, IOBUFCTRL_FREE, a->chain, NULL, &dummy_len))) log_error ("IOBUFCTRL_FREE failed on close: %s\n", gpg_strerror (rc)); xfree (a->real_fname); if (a->d.buf) { memset (a->d.buf, 0, a->d.size); /* erase the buffer */ xfree (a->d.buf); } xfree (a); } return rc; } int iobuf_cancel (iobuf_t a) { const char *s; iobuf_t a2; int rc; #if defined(HAVE_W32_SYSTEM) || defined(__riscos__) char *remove_name = NULL; #endif if (a && a->use == 2) { s = iobuf_get_real_fname (a); if (s && *s) { #if defined(HAVE_W32_SYSTEM) || defined(__riscos__) remove_name = xstrdup (s); #else remove (s); #endif } } /* send a cancel message to all filters */ for (a2 = a; a2; a2 = a2->chain) { size_t dummy; if (a2->filter) a2->filter (a2->filter_ov, IOBUFCTRL_CANCEL, a2->chain, NULL, &dummy); } rc = iobuf_close (a); #if defined(HAVE_W32_SYSTEM) || defined(__riscos__) if (remove_name) { /* Argg, MSDOS does not allow to remove open files. So * we have to do it here */ #ifdef HAVE_W32CE_SYSTEM wchar_t *wtmp = utf8_to_wchar (remove_name); if (wtmp) DeleteFile (wtmp); xfree (wtmp); #else remove (remove_name); #endif xfree (remove_name); } #endif return rc; } /**************** * create a temporary iobuf, which can be used to collect stuff * in an iobuf and later be written by iobuf_write_temp() to another * iobuf. */ iobuf_t iobuf_temp () { iobuf_t a; a = iobuf_alloc (3, IOBUF_BUFFER_SIZE); return a; } iobuf_t iobuf_temp_with_content (const char *buffer, size_t length) { iobuf_t a; a = iobuf_alloc (3, length); memcpy (a->d.buf, buffer, length); a->d.len = length; return a; } void iobuf_enable_special_filenames (int yes) { special_names_enabled = yes; } /* See whether the filename has the form "-&nnnn", where n is a non-zero number. Returns this number or -1 if it is not the case. */ static int check_special_filename (const char *fname) { if (special_names_enabled && fname && *fname == '-' && fname[1] == '&') { int i; fname += 2; for (i = 0; digitp (fname+i); i++) ; if (!fname[i]) return atoi (fname); } return -1; } /* This fucntion returns true if FNAME indicates a PIPE (stdout or stderr) or a special file name if those are enabled. */ int iobuf_is_pipe_filename (const char *fname) { if (!fname || (*fname=='-' && !fname[1]) ) return 1; return check_special_filename (fname) != -1; } /* Either open the file specified by the file descriptor FD or - if FD is -1, the file with name FNAME. As of now MODE is assumed to be "rb" if FNAME is used. In contrast to iobuf_fdopen the file descriptor FD will not be closed during an iobuf_close. */ iobuf_t iobuf_open_fd_or_name (gnupg_fd_t fd, const char *fname, const char *mode) { iobuf_t a; - if (fd == -1) + if (fd == GNUPG_INVALID_FD) a = iobuf_open (fname); else - a = iobuf_fdopen_nc (fd, mode); + a = iobuf_fdopen_nc (FD2INT(fd), mode); return a; } /**************** * Create a head iobuf for reading from a file * returns: NULL if an error occures and sets errno */ iobuf_t iobuf_open (const char *fname) { iobuf_t a; gnupg_fd_t fp; file_filter_ctx_t *fcx; size_t len; int print_only = 0; int fd; if (!fname || (*fname == '-' && !fname[1])) { fp = FD_FOR_STDIN; fname = "[stdin]"; print_only = 1; } else if ((fd = check_special_filename (fname)) != -1) return iobuf_fdopen (translate_file_handle (fd, 0), "rb"); else if ((fp = fd_cache_open (fname, "rb")) == GNUPG_INVALID_FD) return NULL; a = iobuf_alloc (1, IOBUF_BUFFER_SIZE); fcx = xmalloc (sizeof *fcx + strlen (fname)); fcx->fp = fp; fcx->print_only_name = print_only; strcpy (fcx->fname, fname); if (!print_only) a->real_fname = xstrdup (fname); a->filter = file_filter; a->filter_ov = fcx; file_filter (fcx, IOBUFCTRL_DESC, NULL, (byte *) & a->desc, &len); file_filter (fcx, IOBUFCTRL_INIT, NULL, NULL, &len); if (DBG_IOBUF) log_debug ("iobuf-%d.%d: open `%s' fd=%d\n", a->no, a->subno, fname, FD2INT (fcx->fp)); return a; } static iobuf_t do_iobuf_fdopen (int fd, const char *mode, int keep_open) { iobuf_t a; gnupg_fd_t fp; file_filter_ctx_t *fcx; size_t len; fp = INT2FD (fd); a = iobuf_alloc (strchr (mode, 'w') ? 2 : 1, IOBUF_BUFFER_SIZE); fcx = xmalloc (sizeof *fcx + 20); fcx->fp = fp; fcx->print_only_name = 1; fcx->keep_open = keep_open; sprintf (fcx->fname, "[fd %d]", fd); a->filter = file_filter; a->filter_ov = fcx; file_filter (fcx, IOBUFCTRL_DESC, NULL, (byte *) & a->desc, &len); file_filter (fcx, IOBUFCTRL_INIT, NULL, NULL, &len); if (DBG_IOBUF) log_debug ("iobuf-%d.%d: fdopen%s `%s'\n", a->no, a->subno, keep_open? "_nc":"", fcx->fname); iobuf_ioctl (a, IOBUF_IOCTL_NO_CACHE, 1, NULL); return a; } /* Create a head iobuf for reading or writing from/to a file Returns: * NULL and sets ERRNO if an error occured. */ iobuf_t iobuf_fdopen (int fd, const char *mode) { return do_iobuf_fdopen (fd, mode, 0); } iobuf_t iobuf_fdopen_nc (int fd, const char *mode) { return do_iobuf_fdopen (fd, mode, 1); } iobuf_t iobuf_sockopen (int fd, const char *mode) { iobuf_t a; #ifdef HAVE_W32_SYSTEM sock_filter_ctx_t *scx; size_t len; a = iobuf_alloc (strchr (mode, 'w') ? 2 : 1, IOBUF_BUFFER_SIZE); scx = xmalloc (sizeof *scx + 25); scx->sock = fd; scx->print_only_name = 1; sprintf (scx->fname, "[sock %d]", fd); a->filter = sock_filter; a->filter_ov = scx; sock_filter (scx, IOBUFCTRL_DESC, NULL, (byte *) & a->desc, &len); sock_filter (scx, IOBUFCTRL_INIT, NULL, NULL, &len); if (DBG_IOBUF) log_debug ("iobuf-%d.%d: sockopen `%s'\n", a->no, a->subno, scx->fname); iobuf_ioctl (a, IOBUF_IOCTL_NO_CACHE, 1, NULL); #else a = iobuf_fdopen (fd, mode); #endif return a; } /**************** * create an iobuf for writing to a file; the file will be created. */ iobuf_t iobuf_create (const char *fname) { iobuf_t a; gnupg_fd_t fp; file_filter_ctx_t *fcx; size_t len; int print_only = 0; int fd; if (!fname || (*fname == '-' && !fname[1])) { fp = FD_FOR_STDOUT; fname = "[stdout]"; print_only = 1; } else if ((fd = check_special_filename (fname)) != -1) return iobuf_fdopen (translate_file_handle (fd, 1), "wb"); else if ((fp = direct_open (fname, "wb")) == GNUPG_INVALID_FD) return NULL; a = iobuf_alloc (2, IOBUF_BUFFER_SIZE); fcx = xmalloc (sizeof *fcx + strlen (fname)); fcx->fp = fp; fcx->print_only_name = print_only; strcpy (fcx->fname, fname); if (!print_only) a->real_fname = xstrdup (fname); a->filter = file_filter; a->filter_ov = fcx; file_filter (fcx, IOBUFCTRL_DESC, NULL, (byte *) & a->desc, &len); file_filter (fcx, IOBUFCTRL_INIT, NULL, NULL, &len); if (DBG_IOBUF) log_debug ("iobuf-%d.%d: create `%s'\n", a->no, a->subno, a->desc?a->desc:"?"); return a; } iobuf_t iobuf_openrw (const char *fname) { iobuf_t a; gnupg_fd_t fp; file_filter_ctx_t *fcx; size_t len; if (!fname) return NULL; else if ((fp = direct_open (fname, "r+b")) == GNUPG_INVALID_FD) return NULL; a = iobuf_alloc (2, IOBUF_BUFFER_SIZE); fcx = xmalloc (sizeof *fcx + strlen (fname)); fcx->fp = fp; strcpy (fcx->fname, fname); a->real_fname = xstrdup (fname); a->filter = file_filter; a->filter_ov = fcx; file_filter (fcx, IOBUFCTRL_DESC, NULL, (byte *) & a->desc, &len); file_filter (fcx, IOBUFCTRL_INIT, NULL, NULL, &len); if (DBG_IOBUF) log_debug ("iobuf-%d.%d: openrw `%s'\n", a->no, a->subno, a->desc?a->desc:"?"); return a; } int iobuf_ioctl (iobuf_t a, iobuf_ioctl_t cmd, int intval, void *ptrval) { if (cmd == IOBUF_IOCTL_KEEP_OPEN) { /* Keep system filepointer/descriptor open. This was used in the past by http.c; this ioctl is not directly used anymore. */ if (DBG_IOBUF) log_debug ("iobuf-%d.%d: ioctl `%s' keep_open=%d\n", a ? a->no : -1, a ? a->subno : -1, a && a->desc ? a->desc : "?", intval); for (; a; a = a->chain) if (!a->chain && a->filter == file_filter) { file_filter_ctx_t *b = a->filter_ov; b->keep_open = intval; return 0; } #ifdef HAVE_W32_SYSTEM else if (!a->chain && a->filter == sock_filter) { sock_filter_ctx_t *b = a->filter_ov; b->keep_open = intval; return 0; } #endif } else if (cmd == IOBUF_IOCTL_INVALIDATE_CACHE) { if (DBG_IOBUF) log_debug ("iobuf-*.*: ioctl `%s' invalidate\n", ptrval ? (char *) ptrval : "?"); if (!a && !intval && ptrval) { if (fd_cache_invalidate (ptrval)) return -1; return 0; } } else if (cmd == IOBUF_IOCTL_NO_CACHE) { if (DBG_IOBUF) log_debug ("iobuf-%d.%d: ioctl `%s' no_cache=%d\n", a ? a->no : -1, a ? a->subno : -1, a && a->desc? a->desc : "?", intval); for (; a; a = a->chain) if (!a->chain && a->filter == file_filter) { file_filter_ctx_t *b = a->filter_ov; b->no_cache = intval; return 0; } #ifdef HAVE_W32_SYSTEM else if (!a->chain && a->filter == sock_filter) { sock_filter_ctx_t *b = a->filter_ov; b->no_cache = intval; return 0; } #endif } else if (cmd == IOBUF_IOCTL_FSYNC) { /* Do a fsync on the open fd and return any errors to the caller of iobuf_ioctl. Note that we work on a file name here. */ if (DBG_IOBUF) log_debug ("iobuf-*.*: ioctl `%s' fsync\n", ptrval? (const char*)ptrval:""); if (!a && !intval && ptrval) { return fd_cache_synchronize (ptrval); } } return -1; } /**************** * Register an i/o filter. */ int iobuf_push_filter (iobuf_t a, int (*f) (void *opaque, int control, iobuf_t chain, byte * buf, size_t * len), void *ov) { return iobuf_push_filter2 (a, f, ov, 0); } int iobuf_push_filter2 (iobuf_t a, int (*f) (void *opaque, int control, iobuf_t chain, byte * buf, size_t * len), void *ov, int rel_ov) { iobuf_t b; size_t dummy_len = 0; int rc = 0; if (a->directfp) BUG (); if (a->use == 2 && (rc = iobuf_flush (a))) return rc; /* make a copy of the current stream, so that * A is the new stream and B the original one. * The contents of the buffers are transferred to the * new stream. */ b = xmalloc (sizeof *b); memcpy (b, a, sizeof *b); /* fixme: it is stupid to keep a copy of the name at every level * but we need the name somewhere because the name known by file_filter * may have been released when we need the name of the file */ b->real_fname = a->real_fname ? xstrdup (a->real_fname) : NULL; /* remove the filter stuff from the new stream */ a->filter = NULL; a->filter_ov = NULL; a->filter_ov_owner = 0; a->filter_eof = 0; if (a->use == 3) a->use = 2; /* make a write stream from a temp stream */ if (a->use == 2) { /* allocate a fresh buffer for the original stream */ b->d.buf = xmalloc (a->d.size); b->d.len = 0; b->d.start = 0; } else { /* allocate a fresh buffer for the new stream */ a->d.buf = xmalloc (a->d.size); a->d.len = 0; a->d.start = 0; } /* disable nlimit for the new stream */ a->ntotal = b->ntotal + b->nbytes; a->nlimit = a->nbytes = 0; a->nofast &= ~1; /* make a link from the new stream to the original stream */ a->chain = b; a->opaque = b->opaque; /* setup the function on the new stream */ a->filter = f; a->filter_ov = ov; a->filter_ov_owner = rel_ov; a->subno = b->subno + 1; f (ov, IOBUFCTRL_DESC, NULL, (byte *) & a->desc, &dummy_len); if (DBG_IOBUF) { log_debug ("iobuf-%d.%d: push `%s'\n", a->no, a->subno, a->desc?a->desc:"?"); print_chain (a); } /* now we can initialize the new function if we have one */ if (a->filter && (rc = a->filter (a->filter_ov, IOBUFCTRL_INIT, a->chain, NULL, &dummy_len))) log_error ("IOBUFCTRL_INIT failed: %s\n", gpg_strerror (rc)); return rc; } /**************** * Remove an i/o filter. */ static int pop_filter (iobuf_t a, int (*f) (void *opaque, int control, iobuf_t chain, byte * buf, size_t * len), void *ov) { iobuf_t b; size_t dummy_len = 0; int rc = 0; if (a->directfp) BUG (); if (DBG_IOBUF) log_debug ("iobuf-%d.%d: pop `%s'\n", a->no, a->subno, a->desc?a->desc:"?"); if (!a->filter) { /* this is simple */ b = a->chain; assert (b); xfree (a->d.buf); xfree (a->real_fname); memcpy (a, b, sizeof *a); xfree (b); return 0; } for (b = a; b; b = b->chain) if (b->filter == f && (!ov || b->filter_ov == ov)) break; if (!b) log_bug ("pop_filter(): filter function not found\n"); /* flush this stream if it is an output stream */ if (a->use == 2 && (rc = iobuf_flush (b))) { log_error ("iobuf_flush failed in pop_filter: %s\n", gpg_strerror (rc)); return rc; } /* and tell the filter to free it self */ if (b->filter && (rc = b->filter (b->filter_ov, IOBUFCTRL_FREE, b->chain, NULL, &dummy_len))) { log_error ("IOBUFCTRL_FREE failed: %s\n", gpg_strerror (rc)); return rc; } if (b->filter_ov && b->filter_ov_owner) { xfree (b->filter_ov); b->filter_ov = NULL; } /* and see how to remove it */ if (a == b && !b->chain) log_bug ("can't remove the last filter from the chain\n"); else if (a == b) { /* remove the first iobuf from the chain */ /* everything from b is copied to a. This is save because * a flush has been done on the to be removed entry */ b = a->chain; xfree (a->d.buf); xfree (a->real_fname); memcpy (a, b, sizeof *a); xfree (b); if (DBG_IOBUF) log_debug ("iobuf-%d.%d: popped filter\n", a->no, a->subno); } else if (!b->chain) { /* remove the last iobuf from the chain */ log_bug ("Ohh jeee, trying to remove a head filter\n"); } else { /* remove an intermediate iobuf from the chain */ log_bug ("Ohh jeee, trying to remove an intermediate filter\n"); } return rc; } /**************** * read underflow: read more bytes into the buffer and return * the first byte or -1 on EOF. */ static int underflow (iobuf_t a) { size_t len; int rc; assert (a->d.start == a->d.len); if (a->use == 3) return -1; /* EOF because a temp buffer can't do an underflow */ if (a->filter_eof) { if (a->chain) { iobuf_t b = a->chain; if (DBG_IOBUF) log_debug ("iobuf-%d.%d: pop `%s' in underflow\n", a->no, a->subno, a->desc?a->desc:"?"); xfree (a->d.buf); xfree (a->real_fname); memcpy (a, b, sizeof *a); xfree (b); print_chain (a); } else a->filter_eof = 0; /* for the top level filter */ if (DBG_IOBUF) log_debug ("iobuf-%d.%d: underflow: eof (due to filter eof)\n", a->no, a->subno); return -1; /* return one(!) EOF */ } if (a->error) { if (DBG_IOBUF) log_debug ("iobuf-%d.%d: error\n", a->no, a->subno); return -1; } if (a->directfp) { FILE *fp = a->directfp; len = fread (a->d.buf, 1, a->d.size, fp); if (len < a->d.size) { if (ferror (fp)) a->error = gpg_error_from_syserror (); } a->d.len = len; a->d.start = 0; return len ? a->d.buf[a->d.start++] : -1; } if (a->filter) { len = a->d.size; if (DBG_IOBUF) log_debug ("iobuf-%d.%d: underflow: req=%lu\n", a->no, a->subno, (ulong) len); rc = a->filter (a->filter_ov, IOBUFCTRL_UNDERFLOW, a->chain, a->d.buf, &len); if (DBG_IOBUF) { log_debug ("iobuf-%d.%d: underflow: got=%lu rc=%d\n", a->no, a->subno, (ulong) len, rc); /* if( a->no == 1 ) */ /* log_hexdump (" data:", a->d.buf, len); */ } if (a->use == 1 && rc == -1) { /* EOF: we can remove the filter */ size_t dummy_len = 0; /* and tell the filter to free itself */ if ((rc = a->filter (a->filter_ov, IOBUFCTRL_FREE, a->chain, NULL, &dummy_len))) log_error ("IOBUFCTRL_FREE failed: %s\n", gpg_strerror (rc)); if (a->filter_ov && a->filter_ov_owner) { xfree (a->filter_ov); a->filter_ov = NULL; } a->filter = NULL; a->desc = NULL; a->filter_ov = NULL; a->filter_eof = 1; if (!len && a->chain) { iobuf_t b = a->chain; if (DBG_IOBUF) log_debug ("iobuf-%d.%d: pop in underflow (!len)\n", a->no, a->subno); xfree (a->d.buf); xfree (a->real_fname); memcpy (a, b, sizeof *a); xfree (b); print_chain (a); } } else if (rc) a->error = rc; if (!len) { if (DBG_IOBUF) log_debug ("iobuf-%d.%d: underflow: eof\n", a->no, a->subno); return -1; } a->d.len = len; a->d.start = 0; return a->d.buf[a->d.start++]; } else { if (DBG_IOBUF) log_debug ("iobuf-%d.%d: underflow: eof (no filter)\n", a->no, a->subno); return -1; /* no filter; return EOF */ } } int iobuf_flush (iobuf_t a) { size_t len; int rc; if (a->directfp) return 0; if (a->use == 3) { /* increase the temp buffer */ unsigned char *newbuf; size_t newsize = a->d.size + IOBUF_BUFFER_SIZE; if (DBG_IOBUF) log_debug ("increasing temp iobuf from %lu to %lu\n", (ulong) a->d.size, (ulong) newsize); newbuf = xmalloc (newsize); memcpy (newbuf, a->d.buf, a->d.len); xfree (a->d.buf); a->d.buf = newbuf; a->d.size = newsize; return 0; } else if (a->use != 2) log_bug ("flush on non-output iobuf\n"); else if (!a->filter) log_bug ("iobuf_flush: no filter\n"); len = a->d.len; rc = a->filter (a->filter_ov, IOBUFCTRL_FLUSH, a->chain, a->d.buf, &len); if (!rc && len != a->d.len) { log_info ("iobuf_flush did not write all!\n"); rc = GPG_ERR_INTERNAL; } else if (rc) a->error = rc; a->d.len = 0; return rc; } /**************** * Read a byte from the iobuf; returns -1 on EOF */ int iobuf_readbyte (iobuf_t a) { int c; if (a->nlimit && a->nbytes >= a->nlimit) return -1; /* forced EOF */ if (a->d.start < a->d.len) { c = a->d.buf[a->d.start++]; } else if ((c = underflow (a)) == -1) return -1; /* EOF */ a->nbytes++; return c; } int iobuf_read (iobuf_t a, void *buffer, unsigned int buflen) { unsigned char *buf = (unsigned char *)buffer; int c, n; if (a->nlimit) { /* Handle special cases. */ for (n = 0; n < buflen; n++) { if ((c = iobuf_readbyte (a)) == -1) { if (!n) return -1; /* eof */ break; } else if (buf) *buf = c; if (buf) buf++; } return n; } n = 0; do { if (n < buflen && a->d.start < a->d.len) { unsigned size = a->d.len - a->d.start; if (size > buflen - n) size = buflen - n; if (buf) memcpy (buf, a->d.buf + a->d.start, size); n += size; a->d.start += size; if (buf) buf += size; } if (n < buflen) { if ((c = underflow (a)) == -1) { a->nbytes += n; return n ? n : -1 /*EOF*/; } if (buf) *buf++ = c; n++; } } while (n < buflen); a->nbytes += n; return n; } /**************** * Have a look at the iobuf. * NOTE: This only works in special cases. */ int iobuf_peek (iobuf_t a, byte * buf, unsigned buflen) { int n = 0; if (a->filter_eof) return -1; if (!(a->d.start < a->d.len)) { if (underflow (a) == -1) return -1; /* And unget this character. */ assert (a->d.start == 1); a->d.start = 0; } for (n = 0; n < buflen && (a->d.start + n) < a->d.len; n++, buf++) *buf = a->d.buf[n]; return n; } int iobuf_writebyte (iobuf_t a, unsigned int c) { int rc; if (a->directfp) BUG (); if (a->d.len == a->d.size) if ((rc=iobuf_flush (a))) return rc; assert (a->d.len < a->d.size); a->d.buf[a->d.len++] = c; return 0; } int iobuf_write (iobuf_t a, const void *buffer, unsigned int buflen) { const unsigned char *buf = (const unsigned char *)buffer; int rc; if (a->directfp) BUG (); do { if (buflen && a->d.len < a->d.size) { unsigned size = a->d.size - a->d.len; if (size > buflen) size = buflen; memcpy (a->d.buf + a->d.len, buf, size); buflen -= size; buf += size; a->d.len += size; } if (buflen) { rc = iobuf_flush (a); if (rc) return rc; } } while (buflen); return 0; } int iobuf_writestr (iobuf_t a, const char *buf) { int rc; for (; *buf; buf++) if ((rc=iobuf_writebyte (a, *buf))) return rc; return 0; } /**************** * copy the contents of TEMP to A. */ int iobuf_write_temp (iobuf_t a, iobuf_t temp) { while (temp->chain) pop_filter (temp, temp->filter, NULL); return iobuf_write (a, temp->d.buf, temp->d.len); } /**************** * copy the contents of the temp io stream to BUFFER. */ size_t iobuf_temp_to_buffer (iobuf_t a, byte * buffer, size_t buflen) { size_t n = a->d.len; if (n > buflen) n = buflen; memcpy (buffer, a->d.buf, n); return n; } /**************** * Call this function to terminate processing of the temp stream * without closing it. This removes all filters from the stream * makes sure that iobuf_get_temp_{buffer,length}() returns correct * values. */ void iobuf_flush_temp (iobuf_t temp) { while (temp->chain) pop_filter (temp, temp->filter, NULL); } /**************** * Set a limit on how many bytes may be read from the input stream A. * Setting the limit to 0 disables this feature. */ void iobuf_set_limit (iobuf_t a, off_t nlimit) { if (nlimit) a->nofast |= 1; else a->nofast &= ~1; a->nlimit = nlimit; a->ntotal += a->nbytes; a->nbytes = 0; } /* Return the length of an open file A. IF OVERFLOW is not NULL it will be set to true if the file is larger than what off_t can cope with. The function return 0 on error or on overflow condition. */ off_t iobuf_get_filelength (iobuf_t a, int *overflow) { struct stat st; if (overflow) *overflow = 0; if ( a->directfp ) { FILE *fp = a->directfp; if ( !fstat(fileno(fp), &st) ) return st.st_size; log_error("fstat() failed: %s\n", strerror(errno) ); return 0; } /* Hmmm: file_filter may have already been removed */ for ( ; a; a = a->chain ) if ( !a->chain && a->filter == file_filter ) { file_filter_ctx_t *b = a->filter_ov; gnupg_fd_t fp = b->fp; #if defined(HAVE_W32_SYSTEM) ulong size; static int (* __stdcall get_file_size_ex) (void *handle, LARGE_INTEGER *r_size); static int get_file_size_ex_initialized; if (!get_file_size_ex_initialized) { void *handle; handle = dlopen ("kernel32.dll", RTLD_LAZY); if (handle) { get_file_size_ex = dlsym (handle, "GetFileSizeEx"); if (!get_file_size_ex) dlclose (handle); } get_file_size_ex_initialized = 1; } if (get_file_size_ex) { /* This is a newer system with GetFileSizeEx; we use this then because it seem that GetFileSize won't return a proper error in case a file is larger than 4GB. */ LARGE_INTEGER exsize; if (get_file_size_ex (fp, &exsize)) { if (!exsize.u.HighPart) return exsize.u.LowPart; if (overflow) *overflow = 1; return 0; } } else { if ((size=GetFileSize (fp, NULL)) != 0xffffffff) return size; } log_error ("GetFileSize for handle %p failed: %s\n", fp, w32_strerror (0)); #else if ( !fstat (FD2INT (fp), &st) ) return st.st_size; log_error("fstat() failed: %s\n", strerror(errno) ); #endif break/*the for loop*/; } return 0; } /* Return the file descriptor of the underlying file or -1 if it is not available. */ int iobuf_get_fd (iobuf_t a) { if (a->directfp) return fileno ( (FILE*)a->directfp ); for ( ; a; a = a->chain ) if (!a->chain && a->filter == file_filter) { file_filter_ctx_t *b = a->filter_ov; gnupg_fd_t fp = b->fp; return FD2INT (fp); } return -1; } /**************** * Tell the file position, where the next read will take place */ off_t iobuf_tell (iobuf_t a) { return a->ntotal + a->nbytes; } #if !defined(HAVE_FSEEKO) && !defined(fseeko) #ifdef HAVE_LIMITS_H # include #endif #ifndef LONG_MAX # define LONG_MAX ((long) ((unsigned long) -1 >> 1)) #endif #ifndef LONG_MIN # define LONG_MIN (-1 - LONG_MAX) #endif /**************** * A substitute for fseeko, for hosts that don't have it. */ static int fseeko (FILE * stream, off_t newpos, int whence) { while (newpos != (long) newpos) { long pos = newpos < 0 ? LONG_MIN : LONG_MAX; if (fseek (stream, pos, whence) != 0) return -1; newpos -= pos; whence = SEEK_CUR; } return fseek (stream, (long) newpos, whence); } #endif /**************** * This is a very limited implementation. It simply discards all internal * buffering and removes all filters but the first one. */ int iobuf_seek (iobuf_t a, off_t newpos) { file_filter_ctx_t *b = NULL; if (a->directfp) { FILE *fp = a->directfp; if (fseeko (fp, newpos, SEEK_SET)) { log_error ("can't seek: %s\n", strerror (errno)); return -1; } clearerr (fp); } else { for (; a; a = a->chain) { if (!a->chain && a->filter == file_filter) { b = a->filter_ov; break; } } if (!a) return -1; #ifdef HAVE_W32_SYSTEM if (SetFilePointer (b->fp, newpos, NULL, FILE_BEGIN) == 0xffffffff) { log_error ("SetFilePointer failed on handle %p: ec=%d\n", b->fp, (int) GetLastError ()); return -1; } #else if (lseek (b->fp, newpos, SEEK_SET) == (off_t) - 1) { log_error ("can't lseek: %s\n", strerror (errno)); return -1; } #endif } a->d.len = 0; /* discard buffer */ a->d.start = 0; a->nbytes = 0; a->nlimit = 0; a->nofast &= ~1; a->ntotal = newpos; a->error = 0; /* remove filters, but the last */ if (a->chain) log_debug ("pop_filter called in iobuf_seek - please report\n"); while (a->chain) pop_filter (a, a->filter, NULL); return 0; } /**************** * Retrieve the real filename. This is the filename actually used on * disk and not a made up one. Returns NULL if no real filename is * available. */ const char * iobuf_get_real_fname (iobuf_t a) { if (a->real_fname) return a->real_fname; /* the old solution */ for (; a; a = a->chain) if (!a->chain && a->filter == file_filter) { file_filter_ctx_t *b = a->filter_ov; return b->print_only_name ? NULL : b->fname; } return NULL; } /**************** * Retrieve the filename. This name should only be used in diagnostics. */ const char * iobuf_get_fname (iobuf_t a) { for (; a; a = a->chain) if (!a->chain && a->filter == file_filter) { file_filter_ctx_t *b = a->filter_ov; return b->fname; } return NULL; } /* Same as iobuf_get_fname but never returns NULL. */ const char * iobuf_get_fname_nonnull (iobuf_t a) { const char *fname; fname = iobuf_get_fname (a); return fname? fname : "[?]"; } /**************** * enable partial block mode as described in the OpenPGP draft. * LEN is the first length byte on read, but ignored on writes. */ void iobuf_set_partial_block_mode (iobuf_t a, size_t len) { block_filter_ctx_t *ctx = xcalloc (1, sizeof *ctx); assert (a->use == 1 || a->use == 2); ctx->use = a->use; if (!len) { if (a->use == 1) log_debug ("pop_filter called in set_partial_block_mode" " - please report\n"); pop_filter (a, block_filter, NULL); } else { ctx->partial = 1; ctx->size = 0; ctx->first_c = len; iobuf_push_filter (a, block_filter, ctx); } } /**************** * Same as fgets() but if the buffer is too short a larger one will * be allocated up to some limit *max_length. * A line is considered a byte stream ending in a LF. * Returns the length of the line. EOF is indicated by a line of * length zero. The last LF may be missing due to an EOF. * is max_length is zero on return, the line has been truncated. * * Note: The buffer is allocated with enough space to append a CR,LF,EOL */ unsigned int iobuf_read_line (iobuf_t a, byte ** addr_of_buffer, unsigned *length_of_buffer, unsigned *max_length) { int c; char *buffer = (char *)*addr_of_buffer; unsigned length = *length_of_buffer; unsigned nbytes = 0; unsigned maxlen = *max_length; char *p; if (!buffer) { /* must allocate a new buffer */ length = 256; buffer = xmalloc (length); *addr_of_buffer = (unsigned char *)buffer; *length_of_buffer = length; } length -= 3; /* reserve 3 bytes (cr,lf,eol) */ p = buffer; while ((c = iobuf_get (a)) != -1) { if (nbytes == length) { /* increase the buffer */ if (length > maxlen) { /* this is out limit */ /* skip the rest of the line */ while (c != '\n' && (c = iobuf_get (a)) != -1) ; *p++ = '\n'; /* always append a LF (we have reserved space) */ nbytes++; *max_length = 0; /* indicate truncation */ break; } length += 3; /* correct for the reserved byte */ length += length < 1024 ? 256 : 1024; buffer = xrealloc (buffer, length); *addr_of_buffer = (unsigned char *)buffer; *length_of_buffer = length; length -= 3; /* and reserve again */ p = buffer + nbytes; } *p++ = c; nbytes++; if (c == '\n') break; } *p = 0; /* make sure the line is a string */ return nbytes; } static int translate_file_handle (int fd, int for_write) { #ifdef HAVE_W32_SYSTEM { int x; (void)for_write; if (fd == 0) x = (int) GetStdHandle (STD_INPUT_HANDLE); else if (fd == 1) x = (int) GetStdHandle (STD_OUTPUT_HANDLE); else if (fd == 2) x = (int) GetStdHandle (STD_ERROR_HANDLE); else x = fd; if (x == -1) log_debug ("GetStdHandle(%d) failed: ec=%d\n", fd, (int) GetLastError ()); fd = x; } #else (void)for_write; #endif return fd; } void iobuf_skip_rest (iobuf_t a, unsigned long n, int partial) { if ( partial ) { for (;;) { if (a->nofast || a->d.start >= a->d.len) { if (iobuf_readbyte (a) == -1) { break; } } else { unsigned long count = a->d.len - a->d.start; a->nbytes += count; a->d.start = a->d.len; } } } else { unsigned long remaining = n; while (remaining > 0) { if (a->nofast || a->d.start >= a->d.len) { if (iobuf_readbyte (a) == -1) { break; } --remaining; } else { unsigned long count = a->d.len - a->d.start; if (count > remaining) { count = remaining; } a->nbytes += count; a->d.start += count; remaining -= count; } } } } diff --git a/jnlib/libjnlib-config.h b/common/libjnlib-config.h similarity index 100% rename from jnlib/libjnlib-config.h rename to common/libjnlib-config.h diff --git a/common/localename.c b/common/localename.c index cb7fcc2f7..5c46ddd34 100644 --- a/common/localename.c +++ b/common/localename.c @@ -1,116 +1,116 @@ /* localename.c - Determine the current selected locale. Copyright (C) 1995-1999, 2000-2003, 2007, 2008 Free Software Foundation, Inc. This program 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, 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 Library General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program; if not, see . */ /* Written by Ulrich Drepper , 1995. */ /* Win32 code written by Tor Lillqvist . */ /* Modified for GpgOL use by Werner Koch , 2005. */ /* Modified for GnuPG use by Werner Koch , 2007 */ #ifdef HAVE_CONFIG_H # include #endif #include #include #ifdef HAVE_LOCALE_H #include #endif -#include "../jnlib/w32help.h" +#include "../common/w32help.h" /* XPG3 defines the result of 'setlocale (category, NULL)' as: "Directs 'setlocale()' to query 'category' and return the current setting of 'local'." However it does not specify the exact format. Neither do SUSV2 and ISO C 99. So we can use this feature only on selected systems (e.g. those using GNU C Library). */ #if defined _LIBC || (defined __GNU_LIBRARY__ && __GNU_LIBRARY__ >= 2) # define HAVE_LOCALE_NULL #endif /* Use a dummy value for LC_MESSAGES in case it is not defined. This works becuase we always test for HAVE_LC_MESSAGES and the core fucntion takes the category as a string as well. */ #ifndef HAVE_LC_MESSAGES #define LC_MESSAGES 0 #endif /* Determine the current locale's name, and canonicalize it into XPG syntax language[_territory[.codeset]][@modifier] The codeset part in the result is not reliable; the locale_charset() should be used for codeset information instead. The result must not be freed; it is statically allocated. */ #ifndef HAVE_W32_SYSTEM static const char * do_nl_locale_name (int category, const char *categoryname) { const char *retval; /* Use the POSIX methods of looking to 'LC_ALL', 'LC_xxx', and 'LANG'. On some systems this can be done by the 'setlocale' function itself. */ # if defined HAVE_SETLOCALE && defined HAVE_LC_MESSAGES && defined HAVE_LOCALE_NULL (void)categoryname; retval = setlocale (category, NULL); # else /* Setting of LC_ALL overwrites all other. */ retval = getenv ("LC_ALL"); if (retval == NULL || retval[0] == '\0') { /* Next comes the name of the desired category. */ retval = getenv (categoryname); if (retval == NULL || retval[0] == '\0') { /* Last possibility is the LANG environment variable. */ retval = getenv ("LANG"); if (retval == NULL || retval[0] == '\0') /* We use C as the default domain. POSIX says this is implementation defined. */ retval = "C"; } } # endif return retval; } #endif /* HAVE_W32_SYSTEM */ /* Return the locale used for translatable messages. The standard C and POSIX are locale names are mapped to an empty string. If a locale can't be found an empty string will be returned. */ const char * gnupg_messages_locale_name (void) { const char *s; #ifdef HAVE_W32_SYSTEM - /* We use the localname function from ../jnlib/w32-gettext.c. */ + /* We use the localname function from ../common/w32-gettext.c. */ s = gettext_localename (); #else s = do_nl_locale_name (LC_MESSAGES, "LC_MESSAGES"); #endif if (!s) s = ""; else if (!strcmp (s, "C") || !strcmp (s, "POSIX")) s = ""; return s; } diff --git a/jnlib/logging.c b/common/logging.c similarity index 100% rename from jnlib/logging.c rename to common/logging.c diff --git a/jnlib/logging.h b/common/logging.h similarity index 100% rename from jnlib/logging.h rename to common/logging.h diff --git a/jnlib/mischelp.c b/common/mischelp.c similarity index 100% rename from jnlib/mischelp.c rename to common/mischelp.c diff --git a/jnlib/mischelp.h b/common/mischelp.h similarity index 98% rename from jnlib/mischelp.h rename to common/mischelp.h index 52781e12f..5a0132aa6 100644 --- a/jnlib/mischelp.h +++ b/common/mischelp.h @@ -1,102 +1,102 @@ /* mischelp.h - Miscellaneous helper macros and functions * Copyright (C) 1999, 2000, 2001, 2002, 2003, * 2006, 2007, 2009 Free Software Foundation, Inc. * * This file is part of JNLIB. * * JNLIB 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 3 of * the License, or (at your option) any later version. * * JNLIB is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this program; if not, see . */ #ifndef LIBJNLIB_MISCHELP_H #define LIBJNLIB_MISCHHELP_H /* Because we can't use the internal jnlib_free macro in inline - functions we provide a wrapper fucntion as well. */ + functions we provide a wrapper function as well. */ void _jnlib_free (void *p); /* Check whether the files NAME1 and NAME2 are identical. This is for example achieved by comparing the inode numbers of the files. */ int same_file_p (const char *name1, const char *name2); #ifndef HAVE_TIMEGM #include time_t timegm (struct tm *tm); #endif /*!HAVE_TIMEGM*/ #define DIM(v) (sizeof(v)/sizeof((v)[0])) #define DIMof(type,member) DIM(((type *)0)->member) #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 5 ) # define JNLIB_GCC_M_FUNCTION 1 # define JNLIB_GCC_A_NR __attribute__ ((noreturn)) # define JNLIB_GCC_A_PRINTF( f, a ) __attribute__ ((format (printf,f,a))) # define JNLIB_GCC_A_NR_PRINTF( f, a ) \ __attribute__ ((noreturn, format (printf,f,a))) #else # define JNLIB_GCC_A_NR # define JNLIB_GCC_A_PRINTF( f, a ) # define JNLIB_GCC_A_NR_PRINTF( f, a ) #endif /* To avoid that a compiler optimizes certain memset calls away, these macros may be used instead. */ #define wipememory2(_ptr,_set,_len) do { \ volatile char *_vptr=(volatile char *)(_ptr); \ size_t _vlen=(_len); \ while(_vlen) { *_vptr=(_set); _vptr++; _vlen--; } \ } while(0) #define wipememory(_ptr,_len) wipememory2(_ptr,0,_len) /* Include hacks which are mainly required for Slowaris. */ #ifdef JNLIB_NEED_AFLOCAL #ifndef HAVE_W32_SYSTEM # include # include #else # include #endif #ifndef PF_LOCAL # ifdef PF_UNIX # define PF_LOCAL PF_UNIX # else # define PF_LOCAL AF_UNIX # endif #endif /*PF_LOCAL*/ #ifndef AF_LOCAL # define AF_LOCAL AF_UNIX #endif /*AF_UNIX*/ /* We used to avoid this macro in GnuPG and inlined the AF_LOCAL name length computation directly with the little twist of adding 1 extra byte. It seems that this was needed once on an old HP/UX box and there are also rumours that 4.3 Reno and DEC systems need it. This one-off buglet did not harm any current system until it came to Mac OS X where the kernel (as of May 2009) exhibited a strange bug: The systems basically froze in the connect call if the passed name contained an invalid directory part. Ignore the old Unices. */ #ifndef SUN_LEN # define SUN_LEN(ptr) ((size_t) (((struct sockaddr_un *) 0)->sun_path) \ + strlen ((ptr)->sun_path)) #endif /*SUN_LEN*/ #endif /*JNLIB_NEED_AFLOCAL*/ #endif /*LIBJNLIB_MISCHELP_H*/ diff --git a/common/simple-pwquery.c b/common/simple-pwquery.c index 3598b3598..fd48b6f5a 100644 --- a/common/simple-pwquery.c +++ b/common/simple-pwquery.c @@ -1,690 +1,690 @@ /* simple-pwquery.c - A simple password query client for gpg-agent * Copyright (C) 2002, 2004, 2007 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 3 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, see . */ /* This module is intended as a standalone client implementation to gpg-agent's GET_PASSPHRASE command. In particular it does not use the Assuan library and can only cope with an already running gpg-agent. Some stuff is configurable in the header file. */ #ifdef HAVE_CONFIG_H #include #endif #include #include #include #include #include #ifdef HAVE_W32_SYSTEM #include #else #include #include #endif #ifdef HAVE_LOCALE_H #include #endif #define JNLIB_NEED_AFLOCAL -#include "../jnlib/mischelp.h" +#include "../common/mischelp.h" #ifdef HAVE_W32_SYSTEM -#include "../jnlib/w32-afunix.h" +#include "../common/w32-afunix.h" #endif #define SIMPLE_PWQUERY_IMPLEMENTATION 1 #include "simple-pwquery.h" #if defined(SPWQ_USE_LOGGING) && !defined(HAVE_JNLIB_LOGGING) # undef SPWQ_USE_LOGGING #endif #ifndef _ #define _(a) (a) #endif #if !defined (hexdigitp) && !defined (xtoi_2) #define digitp(p) (*(p) >= '0' && *(p) <= '9') #define hexdigitp(a) (digitp (a) \ || (*(a) >= 'A' && *(a) <= 'F') \ || (*(a) >= 'a' && *(a) <= 'f')) #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)) #endif /* Name of the socket to be used if GPG_AGENT_INFO has not been set. No default socket is used if this is NULL. */ static char *default_gpg_agent_info; #ifndef HAVE_STPCPY static char * my_stpcpy(char *a,const char *b) { while( *b ) *a++ = *b++; *a = 0; return (char*)a; } #define stpcpy(a,b) my_stpcpy((a), (b)) #endif /* Write NBYTES of BUF to file descriptor FD. */ static int writen (int fd, const void *buf, size_t nbytes) { size_t nleft = nbytes; int nwritten; while (nleft > 0) { #ifdef HAVE_W32_SYSTEM nwritten = send (fd, buf, nleft, 0); #else nwritten = write (fd, buf, nleft); #endif if (nwritten < 0) { if (errno == EINTR) nwritten = 0; else { #ifdef SPWQ_USE_LOGGING log_error ("write failed: %s\n", strerror (errno)); #endif return SPWQ_IO_ERROR; } } nleft -= nwritten; buf = (const char*)buf + nwritten; } return 0; } /* Read an entire line and return number of bytes read. */ static int readline (int fd, char *buf, size_t buflen) { size_t nleft = buflen; char *p; int nread = 0; while (nleft > 0) { #ifdef HAVE_W32_SYSTEM int n = recv (fd, buf, nleft, 0); #else int n = read (fd, buf, nleft); #endif if (n < 0) { if (errno == EINTR) continue; return -(SPWQ_IO_ERROR); } else if (!n) { return -(SPWQ_PROTOCOL_ERROR); /* incomplete line */ } p = buf; nleft -= n; buf += n; nread += n; for (; n && *p != '\n'; n--, p++) ; if (n) { break; /* At least one full line available - that's enough. This function is just a simple implementation, so it is okay to forget about pending bytes. */ } } return nread; } /* Send an option to the agent */ static int agent_send_option (int fd, const char *name, const char *value) { char buf[200]; int nread; char *line; int i; line = spwq_malloc (7 + strlen (name) + 1 + strlen (value) + 2); if (!line) return SPWQ_OUT_OF_CORE; strcpy (stpcpy (stpcpy (stpcpy ( stpcpy (line, "OPTION "), name), "="), value), "\n"); i = writen (fd, line, strlen (line)); spwq_free (line); if (i) return i; /* get response */ nread = readline (fd, buf, DIM(buf)-1); if (nread < 0) return -nread; if (nread < 3) return SPWQ_PROTOCOL_ERROR; if (buf[0] == 'O' && buf[1] == 'K' && (buf[2] == ' ' || buf[2] == '\n')) return 0; /* okay */ return SPWQ_ERR_RESPONSE; } /* Send all available options to the agent. */ static int agent_send_all_options (int fd) { char *dft_display = NULL; char *dft_ttyname = NULL; char *dft_ttytype = NULL; char *dft_xauthority = NULL; char *dft_pinentry_user_data = NULL; int rc = 0; dft_display = getenv ("DISPLAY"); if (dft_display) { if ((rc = agent_send_option (fd, "display", dft_display))) return rc; } dft_ttyname = getenv ("GPG_TTY"); #ifndef HAVE_W32_SYSTEM if ((!dft_ttyname || !*dft_ttyname) && ttyname (0)) dft_ttyname = ttyname (0); #endif if (dft_ttyname && *dft_ttyname) { if ((rc=agent_send_option (fd, "ttyname", dft_ttyname))) return rc; } dft_ttytype = getenv ("TERM"); if (dft_ttyname && dft_ttytype) { if ((rc = agent_send_option (fd, "ttytype", dft_ttytype))) return rc; } #if defined(HAVE_SETLOCALE) { char *old_lc = NULL; char *dft_lc = NULL; #if defined(LC_CTYPE) old_lc = setlocale (LC_CTYPE, NULL); if (old_lc) { char *p = spwq_malloc (strlen (old_lc)+1); if (!p) return SPWQ_OUT_OF_CORE; strcpy (p, old_lc); old_lc = p; } dft_lc = setlocale (LC_CTYPE, ""); if (dft_ttyname && dft_lc) rc = agent_send_option (fd, "lc-ctype", dft_lc); if (old_lc) { setlocale (LC_CTYPE, old_lc); spwq_free (old_lc); } if (rc) return rc; #endif #if defined(LC_MESSAGES) old_lc = setlocale (LC_MESSAGES, NULL); if (old_lc) { char *p = spwq_malloc (strlen (old_lc)+1); if (!p) return SPWQ_OUT_OF_CORE; strcpy (p, old_lc); old_lc = p; } dft_lc = setlocale (LC_MESSAGES, ""); if (dft_ttyname && dft_lc) rc = agent_send_option (fd, "lc-messages", dft_lc); if (old_lc) { setlocale (LC_MESSAGES, old_lc); spwq_free (old_lc); } if (rc) return rc; #endif } #endif /*HAVE_SETLOCALE*/ /* Send the XAUTHORITY variable. */ dft_xauthority = getenv ("XAUTHORITY"); if (dft_xauthority) { /* We ignore errors here because older gpg-agents don't support this option. */ agent_send_option (fd, "xauthority", dft_xauthority); } /* Send the PINENTRY_USER_DATA variable. */ dft_pinentry_user_data = getenv ("PINENTRY_USER_DATA"); if (dft_pinentry_user_data) { /* We ignore errors here because older gpg-agents don't support this option. */ agent_send_option (fd, "pinentry-user-data", dft_pinentry_user_data); } return 0; } /* Try to open a connection to the agent, send all options and return the file descriptor for the connection. Return -1 in case of error. */ static int agent_open (int *rfd) { int rc; int fd; char *infostr, *p; struct sockaddr_un client_addr; size_t len; int prot; char line[200]; int nread; *rfd = -1; infostr = getenv ( "GPG_AGENT_INFO" ); if ( !infostr || !*infostr ) infostr = default_gpg_agent_info; if ( !infostr || !*infostr ) { #ifdef SPWQ_USE_LOGGING log_error (_("gpg-agent is not available in this session\n")); #endif return SPWQ_NO_AGENT; } p = spwq_malloc (strlen (infostr)+1); if (!p) return SPWQ_OUT_OF_CORE; strcpy (p, infostr); infostr = p; if ( !(p = strchr ( infostr, PATHSEP_C)) || p == infostr || (p-infostr)+1 >= sizeof client_addr.sun_path ) { #ifdef SPWQ_USE_LOGGING log_error ( _("malformed GPG_AGENT_INFO environment variable\n")); #endif return SPWQ_NO_AGENT; } *p++ = 0; while (*p && *p != PATHSEP_C) p++; prot = *p? atoi (p+1) : 0; if ( prot != 1) { #ifdef SPWQ_USE_LOGGING log_error (_("gpg-agent protocol version %d is not supported\n"),prot); #endif return SPWQ_PROTOCOL_ERROR; } #ifdef HAVE_W32_SYSTEM fd = _w32_sock_new (AF_UNIX, SOCK_STREAM, 0); #else fd = socket (AF_UNIX, SOCK_STREAM, 0); #endif if (fd == -1) { #ifdef SPWQ_USE_LOGGING log_error ("can't create socket: %s\n", strerror(errno) ); #endif return SPWQ_SYS_ERROR; } memset (&client_addr, 0, sizeof client_addr); client_addr.sun_family = AF_UNIX; strcpy (client_addr.sun_path, infostr); len = SUN_LEN (&client_addr); #ifdef HAVE_W32_SYSTEM rc = _w32_sock_connect (fd, (struct sockaddr*)&client_addr, len ); #else rc = connect (fd, (struct sockaddr*)&client_addr, len ); #endif if (rc == -1) { #ifdef SPWQ_USE_LOGGING log_error ( _("can't connect to `%s': %s\n"), infostr, strerror (errno)); #endif close (fd ); return SPWQ_IO_ERROR; } nread = readline (fd, line, DIM(line)); if (nread < 3 || !(line[0] == 'O' && line[1] == 'K' && (line[2] == '\n' || line[2] == ' ')) ) { #ifdef SPWQ_USE_LOGGING log_error ( _("communication problem with gpg-agent\n")); #endif close (fd ); return SPWQ_PROTOCOL_ERROR; } rc = agent_send_all_options (fd); if (rc) { #ifdef SPWQ_USE_LOGGING log_error (_("problem setting the gpg-agent options\n")); #endif close (fd); return rc; } *rfd = fd; return 0; } /* Copy text to BUFFER and escape as required. Return a pointer to the end of the new buffer. Note that BUFFER must be large enough to keep the entire text; allocataing it 3 times the size of TEXT is sufficient. */ static char * copy_and_escape (char *buffer, const char *text) { int i; const unsigned char *s = (unsigned char *)text; char *p = buffer; for (i=0; s[i]; i++) { if (s[i] < ' ' || s[i] == '+') { sprintf (p, "%%%02X", s[i]); p += 3; } else if (s[i] == ' ') *p++ = '+'; else *p++ = s[i]; } return p; } /* Set the name of the default socket to NAME. */ int simple_pw_set_socket (const char *name) { spwq_free (default_gpg_agent_info); if (name) { default_gpg_agent_info = spwq_malloc (strlen (name) + 4 + 1); if (!default_gpg_agent_info) return SPWQ_OUT_OF_CORE; /* We don't know the PID thus we use 0. */ strcpy (stpcpy (default_gpg_agent_info, name), PATHSEP_S "0" PATHSEP_S "1"); } else default_gpg_agent_info = NULL; return 0; } /* Ask the gpg-agent for a passphrase and present the user with a DESCRIPTION, a PROMPT and optionally with a TRYAGAIN extra text. If a CACHEID is not NULL it is used to locate the passphrase in in the cache and store it under this ID. If OPT_CHECK is true gpg-agent is asked to apply some checks on the passphrase security. If ERRORCODE is not NULL it should point a variable receiving an errorcode; this error code might be 0 if the user canceled the operation. The function returns NULL to indicate an error. */ char * simple_pwquery (const char *cacheid, const char *tryagain, const char *prompt, const char *description, int opt_check, int *errorcode) { int fd = -1; int nread; char *result = NULL; char *pw = NULL; char *p; int rc, i; rc = agent_open (&fd); if (rc) goto leave; if (!cacheid) cacheid = "X"; if (!tryagain) tryagain = "X"; if (!prompt) prompt = "X"; if (!description) description = "X"; { char *line; /* We allocate 3 times the needed space so that there is enough space for escaping. */ line = spwq_malloc (15 + 10 + 3*strlen (cacheid) + 1 + 3*strlen (tryagain) + 1 + 3*strlen (prompt) + 1 + 3*strlen (description) + 1 + 2); if (!line) { rc = SPWQ_OUT_OF_CORE; goto leave; } strcpy (line, "GET_PASSPHRASE "); p = line+15; if (opt_check) p = stpcpy (p, "--check "); p = copy_and_escape (p, cacheid); *p++ = ' '; p = copy_and_escape (p, tryagain); *p++ = ' '; p = copy_and_escape (p, prompt); *p++ = ' '; p = copy_and_escape (p, description); *p++ = '\n'; rc = writen (fd, line, p - line); spwq_free (line); if (rc) goto leave; } /* get response */ pw = spwq_secure_malloc (500); nread = readline (fd, pw, 499); if (nread < 0) { rc = -nread; goto leave; } if (nread < 3) { rc = SPWQ_PROTOCOL_ERROR; goto leave; } if (pw[0] == 'O' && pw[1] == 'K' && pw[2] == ' ') { /* we got a passphrase - convert it back from hex */ size_t pwlen = 0; for (i=3; i < nread && hexdigitp (pw+i); i+=2) pw[pwlen++] = xtoi_2 (pw+i); pw[pwlen] = 0; /* make a C String */ result = pw; pw = NULL; } else if ((nread > 7 && !memcmp (pw, "ERR 111", 7) && (pw[7] == ' ' || pw[7] == '\n') ) || ((nread > 4 && !memcmp (pw, "ERR ", 4) && (strtoul (pw+4, NULL, 0) & 0xffff) == 99)) ) { /* 111 is the old Assuan code for canceled which might still be in use by old installations. 99 is GPG_ERR_CANCELED as used by modern gpg-agents; 0xffff is used to mask out the error source. */ #ifdef SPWQ_USE_LOGGING log_info (_("canceled by user\n") ); #endif *errorcode = 0; /* Special error code to indicate Cancel. */ } else if (nread > 4 && !memcmp (pw, "ERR ", 4)) { switch ( (strtoul (pw+4, NULL, 0) & 0xffff) ) { case 85: rc = SPWQ_NO_PIN_ENTRY; break; default: rc = SPWQ_GENERAL_ERROR; break; } } else { #ifdef SPWQ_USE_LOGGING log_error (_("problem with the agent\n")); #endif rc = SPWQ_ERR_RESPONSE; } leave: if (errorcode) *errorcode = rc; if (fd != -1) close (fd); if (pw) spwq_secure_free (pw); return result; } /* Ask the gpg-agent to clear the passphrase for the cache ID CACHEID. */ int simple_pwclear (const char *cacheid) { char line[500]; char *p; /* We need not more than 50 characters for the command and the terminating nul. */ if (strlen (cacheid) * 3 > sizeof (line) - 50) return SPWQ_PROTOCOL_ERROR; strcpy (line, "CLEAR_PASSPHRASE "); p = line + 17; p = copy_and_escape (p, cacheid); *p++ = '\n'; *p++ = '\0'; return simple_query (line); } /* Perform the simple query QUERY (which must be new-line and 0 terminated) and return the error code. */ int simple_query (const char *query) { int fd = -1; int nread; char response[500]; int rc; rc = agent_open (&fd); if (rc) goto leave; rc = writen (fd, query, strlen (query)); if (rc) goto leave; /* get response */ nread = readline (fd, response, 499); if (nread < 0) { rc = -nread; goto leave; } if (nread < 3) { rc = SPWQ_PROTOCOL_ERROR; goto leave; } if (response[0] == 'O' && response[1] == 'K') /* OK, do nothing. */; else if ((nread > 7 && !memcmp (response, "ERR 111", 7) && (response[7] == ' ' || response[7] == '\n') ) || ((nread > 4 && !memcmp (response, "ERR ", 4) && (strtoul (response+4, NULL, 0) & 0xffff) == 99)) ) { /* 111 is the old Assuan code for canceled which might still be in use by old installations. 99 is GPG_ERR_CANCELED as used by modern gpg-agents; 0xffff is used to mask out the error source. */ #ifdef SPWQ_USE_LOGGING log_info (_("canceled by user\n") ); #endif } else { #ifdef SPWQ_USE_LOGGING log_error (_("problem with the agent\n")); #endif rc = SPWQ_ERR_RESPONSE; } leave: if (fd != -1) close (fd); return rc; } diff --git a/common/simple-pwquery.h b/common/simple-pwquery.h index 8de9b1bd2..edd834ef4 100644 --- a/common/simple-pwquery.h +++ b/common/simple-pwquery.h @@ -1,115 +1,115 @@ /* simple-pwquery.c - A simple password query cleint for gpg-agent * 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 3 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, see . */ #ifndef SIMPLE_PWQUERY_H #define SIMPLE_PWQUERY_H #ifdef SIMPLE_PWQUERY_IMPLEMENTATION /* Begin configuration stuff. */ /* Include whatever files you need. */ #include -#include "../jnlib/logging.h" +#include "../common/logging.h" /* Try to write error message using the standard log mechanism. The current implementation requires that the HAVE_JNLIB_LOGGING is also defined. */ #define SPWQ_USE_LOGGING 1 /* Memory allocation functions used by the implementation. Note, that the returned value is expected to be freed with spwq_secure_free. */ #define spwq_malloc(a) gcry_malloc (a) #define spwq_free(a) gcry_free (a) #define spwq_secure_malloc(a) gcry_malloc_secure (a) #define spwq_secure_free(a) gcry_free (a) #endif /*SIMPLE_PWQUERY_IMPLEMENTATION*/ /* End configuration stuff. */ /* Ask the gpg-agent for a passphrase and present the user with a DESCRIPTION, a PROMPT and optiaonlly with a TRYAGAIN extra text. If a CACHEID is not NULL it is used to locate the passphrase in in the cache and store it under this ID. If OPT_CHECK is true gpg-agent is asked to apply some checks on the passphrase security. If ERRORCODE is not NULL it should point a variable receiving an errorcode; this errocode might be 0 if the user canceled the operation. The function returns NULL to indicate an error. */ char *simple_pwquery (const char *cacheid, const char *tryagain, const char *prompt, const char *description, int opt_check, int *errorcode); /* Ask the gpg-agent to clear the passphrase for the cache ID CACHEID. */ int simple_pwclear (const char *cacheid); /* Perform the simple query QUERY (which must be new-line and 0 terminated) and return the error code. */ int simple_query (const char *query); /* Set the name of the standard socket to be used if GPG_AGENT_INFO is not defined. The use of this function is optional but if it needs to be called before any other function. Returns 0 on success. */ int simple_pw_set_socket (const char *name); #define SPWQ_OUT_OF_CORE 1 #define SPWQ_IO_ERROR 2 #define SPWQ_PROTOCOL_ERROR 3 #define SPWQ_ERR_RESPONSE 4 #define SPWQ_NO_AGENT 5 #define SPWQ_SYS_ERROR 6 #define SPWQ_GENERAL_ERROR 7 #define SPWQ_NO_PIN_ENTRY 8 /* We often need to map error codes to gpg-error style error codes. To have a consistent mapping this macro may be used to implemt the mapping function. */ #define MAP_SPWQ_ERROR_IMPL \ static gpg_error_t \ map_spwq_error (int err) \ { \ switch (err) \ { \ case 0: \ return 0; \ case SPWQ_OUT_OF_CORE: \ return gpg_error_from_errno (ENOMEM); \ case SPWQ_IO_ERROR: \ return gpg_error_from_errno (EIO); \ case SPWQ_PROTOCOL_ERROR: \ return gpg_error (GPG_ERR_PROTOCOL_VIOLATION); \ case SPWQ_ERR_RESPONSE: \ return gpg_error (GPG_ERR_INV_RESPONSE); \ case SPWQ_NO_AGENT: \ return gpg_error (GPG_ERR_NO_AGENT); \ case SPWQ_SYS_ERROR: \ return gpg_error_from_syserror (); \ case SPWQ_NO_PIN_ENTRY: \ return gpg_error (GPG_ERR_NO_PIN_ENTRY); \ case SPWQ_GENERAL_ERROR: \ default: \ return gpg_error (GPG_ERR_GENERAL); \ } \ } /* End of MAP_SPWQ_ERROR_IMPL. */ #endif /*SIMPLE_PWQUERY_H*/ diff --git a/jnlib/stringhelp.c b/common/stringhelp.c similarity index 100% rename from jnlib/stringhelp.c rename to common/stringhelp.c diff --git a/jnlib/stringhelp.h b/common/stringhelp.h similarity index 100% rename from jnlib/stringhelp.h rename to common/stringhelp.h diff --git a/jnlib/strlist.c b/common/strlist.c similarity index 100% rename from jnlib/strlist.c rename to common/strlist.c diff --git a/jnlib/strlist.h b/common/strlist.h similarity index 100% rename from jnlib/strlist.h rename to common/strlist.h diff --git a/common/sysutils.h b/common/sysutils.h index fd4340f3d..6f34b9791 100644 --- a/common/sysutils.h +++ b/common/sysutils.h @@ -1,59 +1,59 @@ /* sysutils.h - System utility functions for Gnupg * 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 3 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, see . */ #ifndef GNUPG_COMMON_SYSUTILS_H #define GNUPG_COMMON_SYSUTILS_H /* Because we use system handles and not libc low level file descriptors on W32, we need to declare them as HANDLE (which actually is a plain pointer). This is required to eventually support 64 bits Windows systems. */ #ifdef HAVE_W32_SYSTEM typedef void *gnupg_fd_t; #define GNUPG_INVALID_FD ((void*)(-1)) #define INT2FD(s) ((void *)(s)) #define FD2INT(h) ((unsigned int)(h)) #else typedef int gnupg_fd_t; #define GNUPG_INVALID_FD (-1) #define INT2FD(s) (s) #define FD2INT(h) (h) #endif void trap_unaligned (void); int disable_core_dumps (void); int enable_core_dumps (void); const unsigned char *get_session_marker (size_t *rlen); /*int check_permissions (const char *path,int extension,int checkonly);*/ void gnupg_sleep (unsigned int seconds); int translate_sys2libc_fd (gnupg_fd_t fd, int for_write); int translate_sys2libc_fd_int (int fd, int for_write); FILE *gnupg_tmpfile (void); void gnupg_reopen_std (const char *pgmname); void gnupg_allow_set_foregound_window (pid_t pid); #ifdef HAVE_W32_SYSTEM -#include "../jnlib/w32help.h" +#include "../common/w32help.h" #endif /*HAVE_W32_SYSTEM*/ #endif /*GNUPG_COMMON_SYSUTILS_H*/ diff --git a/jnlib/t-stringhelp.c b/common/t-stringhelp.c similarity index 100% rename from jnlib/t-stringhelp.c rename to common/t-stringhelp.c diff --git a/jnlib/t-support.c b/common/t-support.c similarity index 100% rename from jnlib/t-support.c rename to common/t-support.c diff --git a/jnlib/t-support.h b/common/t-support.h similarity index 100% rename from jnlib/t-support.h rename to common/t-support.h diff --git a/jnlib/t-timestuff.c b/common/t-timestuff.c similarity index 100% rename from jnlib/t-timestuff.c rename to common/t-timestuff.c diff --git a/jnlib/t-w32-reg.c b/common/t-w32-reg.c similarity index 100% rename from jnlib/t-w32-reg.c rename to common/t-w32-reg.c diff --git a/common/ttyio.c b/common/ttyio.c index fc274070c..ec26b06e8 100644 --- a/common/ttyio.c +++ b/common/ttyio.c @@ -1,690 +1,689 @@ /* ttyio.c - tty i/O functions * Copyright (C) 1998,1999,2000,2001,2002,2003,2004,2006,2007, * 2009 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 3 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, see . */ #include #include #include #include #include #include #ifdef HAVE_TCGETATTR #include #else #ifdef HAVE_TERMIO_H /* simulate termios with termio */ #include #define termios termio #define tcsetattr ioctl #define TCSAFLUSH TCSETAF #define tcgetattr(A,B) ioctl(A,TCGETA,B) #define HAVE_TCGETATTR #endif #endif #ifdef _WIN32 /* use the odd Win32 functions */ #include #ifdef HAVE_TCGETATTR #error mingw32 and termios #endif #endif #include #include #include "util.h" #include "ttyio.h" -#include "estream-printf.h" #include "common-defs.h" #define CONTROL_D ('D' - 'A' + 1) #ifdef _WIN32 /* use the odd Win32 functions */ static struct { HANDLE in, out; } con; #define DEF_INPMODE (ENABLE_LINE_INPUT|ENABLE_ECHO_INPUT \ |ENABLE_PROCESSED_INPUT ) #define HID_INPMODE (ENABLE_LINE_INPUT|ENABLE_PROCESSED_INPUT ) #define DEF_OUTMODE (ENABLE_WRAP_AT_EOL_OUTPUT|ENABLE_PROCESSED_OUTPUT) #else /* yeah, we have a real OS */ static FILE *ttyfp = NULL; #endif static int initialized; static int last_prompt_len; static int batchmode; static int no_terminal; #ifdef HAVE_TCGETATTR static struct termios termsave; static int restore_termios; #endif /* Hooks set by gpgrlhelp.c if required. */ static void (*my_rl_set_completer) (rl_completion_func_t *); static void (*my_rl_inhibit_completion) (int); static void (*my_rl_cleanup_after_signal) (void); static void (*my_rl_init_stream) (FILE *); static char *(*my_rl_readline) (const char*); static void (*my_rl_add_history) (const char*); /* This is a wrapper around ttyname so that we can use it even when the standard streams are redirected. It figures the name out the first time and returns it in a statically allocated buffer. */ const char * tty_get_ttyname (void) { static char *name; /* On a GNU system ctermid() always return /dev/tty, so this does not make much sense - however if it is ever changed we do the Right Thing now. */ #ifdef HAVE_CTERMID static int got_name; if (!got_name) { const char *s; /* Note that despite our checks for these macros the function is not necessarily thread save. We mainly do this for portability reasons, in case L_ctermid is not defined. */ # if defined(_POSIX_THREAD_SAFE_FUNCTIONS) || defined(_POSIX_TRHEADS) char buffer[L_ctermid]; s = ctermid (buffer); # else s = ctermid (NULL); # endif if (s) name = strdup (s); got_name = 1; } #endif /*HAVE_CTERMID*/ /* Assume the standard tty on memory error or when tehre is no certmid. */ return name? name : "/dev/tty"; } #ifdef HAVE_TCGETATTR static void cleanup(void) { if( restore_termios ) { restore_termios = 0; /* do it prios in case it is interrupted again */ if( tcsetattr(fileno(ttyfp), TCSAFLUSH, &termsave) ) log_error("tcsetattr() failed: %s\n", strerror(errno) ); } } #endif static void init_ttyfp(void) { if( initialized ) return; #if defined(_WIN32) { SECURITY_ATTRIBUTES sa; memset(&sa, 0, sizeof(sa)); sa.nLength = sizeof(sa); sa.bInheritHandle = TRUE; con.out = CreateFileA( "CONOUT$", GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE, &sa, OPEN_EXISTING, 0, 0 ); if( con.out == INVALID_HANDLE_VALUE ) log_fatal("open(CONOUT$) failed: rc=%d", (int)GetLastError() ); memset(&sa, 0, sizeof(sa)); sa.nLength = sizeof(sa); sa.bInheritHandle = TRUE; con.in = CreateFileA( "CONIN$", GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE, &sa, OPEN_EXISTING, 0, 0 ); if( con.in == INVALID_HANDLE_VALUE ) log_fatal("open(CONIN$) failed: rc=%d", (int)GetLastError() ); } SetConsoleMode(con.in, DEF_INPMODE ); SetConsoleMode(con.out, DEF_OUTMODE ); #elif defined(__EMX__) ttyfp = stdout; /* Fixme: replace by the real functions: see wklib */ if (my_rl_init_stream) my_rl_init_stream (ttyfp); #else ttyfp = batchmode? stderr : fopen (tty_get_ttyname (), "r+"); if( !ttyfp ) { log_error("cannot open `%s': %s\n", tty_get_ttyname (), strerror(errno) ); exit(2); } if (my_rl_init_stream) my_rl_init_stream (ttyfp); #endif #ifdef HAVE_TCGETATTR atexit( cleanup ); #endif initialized = 1; } int tty_batchmode( int onoff ) { int old = batchmode; if( onoff != -1 ) batchmode = onoff; return old; } int tty_no_terminal(int onoff) { int old = no_terminal; no_terminal = onoff ? 1 : 0; return old; } void tty_printf( const char *fmt, ... ) { va_list arg_ptr; if (no_terminal) return; if( !initialized ) init_ttyfp(); va_start( arg_ptr, fmt ) ; #ifdef _WIN32 { char *buf = NULL; int n; DWORD nwritten; n = vasprintf(&buf, fmt, arg_ptr); if( !buf ) log_bug("vasprintf() failed\n"); if( !WriteConsoleA( con.out, buf, n, &nwritten, NULL ) ) log_fatal("WriteConsole failed: rc=%d", (int)GetLastError() ); if( n != nwritten ) log_fatal("WriteConsole failed: %d != %d\n", n, (int)nwritten ); last_prompt_len += n; xfree (buf); } #else last_prompt_len += vfprintf(ttyfp,fmt,arg_ptr) ; fflush(ttyfp); #endif va_end(arg_ptr); } /* Same as tty_printf but if FP is not NULL, behave like a regular fprintf. */ void tty_fprintf (FILE *fp, const char *fmt, ... ) { va_list arg_ptr; if (fp) { va_start (arg_ptr, fmt) ; vfprintf (fp, fmt, arg_ptr ); va_end (arg_ptr); return; } if (no_terminal) return; if( !initialized ) init_ttyfp(); va_start( arg_ptr, fmt ) ; #ifdef _WIN32 { char *buf = NULL; int n; DWORD nwritten; n = vasprintf(&buf, fmt, arg_ptr); if( !buf ) log_bug("vasprintf() failed\n"); if( !WriteConsoleA( con.out, buf, n, &nwritten, NULL ) ) log_fatal("WriteConsole failed: rc=%d", (int)GetLastError() ); if( n != nwritten ) log_fatal("WriteConsole failed: %d != %d\n", n, (int)nwritten ); last_prompt_len += n; xfree (buf); } #else last_prompt_len += vfprintf(ttyfp,fmt,arg_ptr) ; fflush(ttyfp); #endif va_end(arg_ptr); } /**************** * Print a string, but filter all control characters out. */ void tty_print_string ( const byte *p, size_t n ) { if (no_terminal) return; if( !initialized ) init_ttyfp(); #ifdef _WIN32 /* not so effective, change it if you want */ for( ; n; n--, p++ ) if( iscntrl( *p ) ) { if( *p == '\n' ) tty_printf("\\n"); else if( !*p ) tty_printf("\\0"); else tty_printf("\\x%02x", *p); } else tty_printf("%c", *p); #else for( ; n; n--, p++ ) if( iscntrl( *p ) ) { putc('\\', ttyfp); if( *p == '\n' ) putc('n', ttyfp); else if( !*p ) putc('0', ttyfp); else fprintf(ttyfp, "x%02x", *p ); } else putc(*p, ttyfp); #endif } void tty_print_utf8_string2( const byte *p, size_t n, size_t max_n ) { size_t i; char *buf; if (no_terminal) return; /* we can handle plain ascii simpler, so check for it first */ for(i=0; i < n; i++ ) { if( p[i] & 0x80 ) break; } if( i < n ) { buf = utf8_to_native( (const char *)p, n, 0 ); if( max_n && (strlen( buf ) > max_n )) { buf[max_n] = 0; } /*(utf8 conversion already does the control character quoting)*/ tty_printf("%s", buf ); xfree( buf ); } else { if( max_n && (n > max_n) ) { n = max_n; } tty_print_string( p, n ); } } void tty_print_utf8_string( const byte *p, size_t n ) { tty_print_utf8_string2( p, n, 0 ); } static char * do_get( const char *prompt, int hidden ) { char *buf; #ifndef __riscos__ byte cbuf[1]; #endif int c, n, i; if( batchmode ) { log_error("Sorry, we are in batchmode - can't get input\n"); exit(2); } if (no_terminal) { log_error("Sorry, no terminal at all requested - can't get input\n"); exit(2); } if( !initialized ) init_ttyfp(); last_prompt_len = 0; tty_printf( "%s", prompt ); buf = xmalloc((n=50)); i = 0; #ifdef _WIN32 /* windoze version */ if( hidden ) SetConsoleMode(con.in, HID_INPMODE ); for(;;) { DWORD nread; if( !ReadConsoleA( con.in, cbuf, 1, &nread, NULL ) ) log_fatal("ReadConsole failed: rc=%d", (int)GetLastError() ); if( !nread ) continue; if( *cbuf == '\n' ) break; if( !hidden ) last_prompt_len++; c = *cbuf; if( c == '\t' ) c = ' '; else if( c > 0xa0 ) ; /* we don't allow 0xa0, as this is a protected blank which may * confuse the user */ else if( iscntrl(c) ) continue; if( !(i < n-1) ) { n += 50; buf = xrealloc (buf, n); } buf[i++] = c; } if( hidden ) SetConsoleMode(con.in, DEF_INPMODE ); #elif defined(__riscos__) do { c = riscos_getchar(); if (c == 0xa || c == 0xd) { /* Return || Enter */ c = (int) '\n'; } else if (c == 0x8 || c == 0x7f) { /* Backspace || Delete */ if (i>0) { i--; if (!hidden) { last_prompt_len--; fputc(8, ttyfp); fputc(32, ttyfp); fputc(8, ttyfp); fflush(ttyfp); } } else { fputc(7, ttyfp); fflush(ttyfp); } continue; } else if (c == (int) '\t') { /* Tab */ c = ' '; } else if (c > 0xa0) { ; /* we don't allow 0xa0, as this is a protected blank which may * confuse the user */ } else if (iscntrl(c)) { continue; } if(!(i < n-1)) { n += 50; buf = xrealloc (buf, n); } buf[i++] = c; if (!hidden) { last_prompt_len++; fputc(c, ttyfp); fflush(ttyfp); } } while (c != '\n'); i = (i>0) ? i-1 : 0; #else /* unix version */ if( hidden ) { #ifdef HAVE_TCGETATTR struct termios term; if( tcgetattr(fileno(ttyfp), &termsave) ) log_fatal("tcgetattr() failed: %s\n", strerror(errno) ); restore_termios = 1; term = termsave; term.c_lflag &= ~(ECHO | ECHOE | ECHOK | ECHONL); if( tcsetattr( fileno(ttyfp), TCSAFLUSH, &term ) ) log_fatal("tcsetattr() failed: %s\n", strerror(errno) ); #endif } /* fixme: How can we avoid that the \n is echoed w/o disabling * canonical mode - w/o this kill_prompt can't work */ while( read(fileno(ttyfp), cbuf, 1) == 1 && *cbuf != '\n' ) { if( !hidden ) last_prompt_len++; c = *cbuf; if( c == CONTROL_D ) log_info("control d found\n"); if( c == '\t' ) c = ' '; else if( c > 0xa0 ) ; /* we don't allow 0xa0, as this is a protected blank which may * confuse the user */ else if( iscntrl(c) ) continue; if( !(i < n-1) ) { n += 50; buf = xrealloc (buf, n ); } buf[i++] = c; } if( *cbuf != '\n' ) { buf[0] = CONTROL_D; i = 1; } if( hidden ) { #ifdef HAVE_TCGETATTR if( tcsetattr(fileno(ttyfp), TCSAFLUSH, &termsave) ) log_error("tcsetattr() failed: %s\n", strerror(errno) ); restore_termios = 0; #endif } #endif /* end unix version */ buf[i] = 0; return buf; } char * tty_get( const char *prompt ) { if (!batchmode && !no_terminal && my_rl_readline && my_rl_add_history) { char *line; char *buf; if (!initialized) init_ttyfp(); last_prompt_len = 0; line = my_rl_readline (prompt?prompt:""); /* We need to copy it to memory controlled by our malloc implementations; further we need to convert an EOF to our convention. */ buf = xmalloc(line? strlen(line)+1:2); if (line) { strcpy (buf, line); trim_spaces (buf); if (strlen (buf) > 2 ) my_rl_add_history (line); /* Note that we test BUF but add LINE. */ free (line); } else { buf[0] = CONTROL_D; buf[1] = 0; } return buf; } else return do_get ( prompt, 0 ); } /* Variable argument version of tty_get. The prompt is is actually a format string with arguments. */ char * tty_getf (const char *promptfmt, ... ) { va_list arg_ptr; char *prompt; char *answer; va_start (arg_ptr, promptfmt); if (estream_vasprintf (&prompt, promptfmt, arg_ptr) < 0) log_fatal ("estream_vasprintf failed: %s\n", strerror (errno)); va_end (arg_ptr); answer = tty_get (prompt); xfree (prompt); return answer; } char * tty_get_hidden( const char *prompt ) { return do_get( prompt, 1 ); } void tty_kill_prompt() { if ( no_terminal ) return; if( !initialized ) init_ttyfp(); if( batchmode ) last_prompt_len = 0; if( !last_prompt_len ) return; #ifdef _WIN32 tty_printf("\r%*s\r", last_prompt_len, ""); #else { int i; putc('\r', ttyfp); for(i=0; i < last_prompt_len; i ++ ) putc(' ', ttyfp); putc('\r', ttyfp); fflush(ttyfp); } #endif last_prompt_len = 0; } int tty_get_answer_is_yes( const char *prompt ) { int yes; char *p = tty_get( prompt ); tty_kill_prompt(); yes = answer_is_yes(p); xfree(p); return yes; } /* Called by gnupg_rl_initialize to setup the readline support. */ void tty_private_set_rl_hooks (void (*init_stream) (FILE *), void (*set_completer) (rl_completion_func_t*), void (*inhibit_completion) (int), void (*cleanup_after_signal) (void), char *(*readline_fun) (const char*), void (*add_history_fun) (const char*)) { my_rl_init_stream = init_stream; my_rl_set_completer = set_completer; my_rl_inhibit_completion = inhibit_completion; my_rl_cleanup_after_signal = cleanup_after_signal; my_rl_readline = readline_fun; my_rl_add_history = add_history_fun; } #ifdef HAVE_LIBREADLINE void tty_enable_completion (rl_completion_func_t *completer) { if (no_terminal || !my_rl_set_completer ) return; if (!initialized) init_ttyfp(); my_rl_set_completer (completer); } void tty_disable_completion (void) { if (no_terminal || !my_rl_inhibit_completion) return; if (!initialized) init_ttyfp(); my_rl_inhibit_completion (1); } #endif void tty_cleanup_after_signal (void) { #ifdef HAVE_TCGETATTR cleanup (); #endif } void tty_cleanup_rl_after_signal (void) { if (my_rl_cleanup_after_signal) my_rl_cleanup_after_signal (); } diff --git a/jnlib/types.h b/common/types.h similarity index 100% rename from jnlib/types.h rename to common/types.h diff --git a/jnlib/utf8conv.c b/common/utf8conv.c similarity index 100% rename from jnlib/utf8conv.c rename to common/utf8conv.c diff --git a/jnlib/utf8conv.h b/common/utf8conv.h similarity index 100% rename from jnlib/utf8conv.h rename to common/utf8conv.h diff --git a/common/util.h b/common/util.h index 56678620b..32d4085e7 100644 --- a/common/util.h +++ b/common/util.h @@ -1,337 +1,338 @@ /* util.h - Utility functions for GnuPG * Copyright (C) 2001, 2002, 2003, 2004, 2009 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 3 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, see . */ #ifndef GNUPG_COMMON_UTIL_H #define GNUPG_COMMON_UTIL_H #include /* We need this for the memory function protos. */ #include /* We need time_t. */ #include /* We need errno. */ #include /* We need gpg_error_t. */ /* Add error codes available only in newer versions of libgpg-error. */ #ifndef GPG_ERR_NOT_ENABLED #define GPG_ERR_NOT_ENABLED 179 #endif /* Hash function used with libksba. */ #define HASH_FNC ((void (*)(void *, const void*,size_t))gcry_md_write) +/* Estream replaces most uses of stdio. */ +#include "../common/estream.h" +#include "../common/estream-printf.h" + /* Get all the stuff from jnlib. */ -#include "../jnlib/logging.h" -#include "../jnlib/argparse.h" -#include "../jnlib/stringhelp.h" -#include "../jnlib/mischelp.h" -#include "../jnlib/strlist.h" -#include "../jnlib/dotlock.h" -#include "../jnlib/utf8conv.h" -#include "../jnlib/dynload.h" +#include "../common/logging.h" +#include "../common/argparse.h" +#include "../common/stringhelp.h" +#include "../common/mischelp.h" +#include "../common/strlist.h" +#include "../common/dotlock.h" +#include "../common/utf8conv.h" +#include "../common/dynload.h" #include "init.h" /* Redefine asprintf by our estream version which uses our own memory allocator.. */ -#include "estream-printf.h" #define asprintf estream_asprintf #define vasprintf estream_vasprintf -/* Due to a bug in mingw32's snprintf related to the 'l' modifier we - better use our snprintf. */ -#ifdef HAVE_W32_SYSTEM +/* Due to a bug in mingw32's snprintf related to the 'l' modifier and + for increased portability we use our snprintf on all systems. */ #define snprintf estream_snprintf -#endif /* GCC attributes. */ #if __GNUC__ >= 4 # define GNUPG_GCC_A_SENTINEL(a) __attribute__ ((sentinel(a))) #else # define GNUPG_GCC_A_SENTINEL(a) #endif /* We need this type even if we are not using libreadline and or we did not include libreadline in the current file. */ #ifndef GNUPG_LIBREADLINE_H_INCLUDED typedef char **rl_completion_func_t (const char *, int, int); #endif /*!GNUPG_LIBREADLINE_H_INCLUDED*/ /* Handy malloc macros - please use only them. */ #define xtrymalloc(a) gcry_malloc ((a)) #define xtrymalloc_secure(a) gcry_malloc_secure ((a)) #define xtrycalloc(a,b) gcry_calloc ((a),(b)) #define xtrycalloc_secure(a,b) gcry_calloc_secure ((a),(b)) #define xtryrealloc(a,b) gcry_realloc ((a),(b)) #define xtrystrdup(a) gcry_strdup ((a)) #define xfree(a) gcry_free ((a)) #define xmalloc(a) gcry_xmalloc ((a)) #define xmalloc_secure(a) gcry_xmalloc_secure ((a)) #define xcalloc(a,b) gcry_xcalloc ((a),(b)) #define xcalloc_secure(a,b) gcry_xcalloc_secure ((a),(b)) #define xrealloc(a,b) gcry_xrealloc ((a),(b)) #define xstrdup(a) gcry_xstrdup ((a)) /* For compatibility with gpg 1.4 we also define these: */ #define xmalloc_clear(a) gcry_xcalloc (1, (a)) #define xmalloc_secure_clear(a) gcry_xcalloc_secure (1, (a)) /* Convenience function to return a gpg-error code for memory allocation failures. This function makes sure that an error will be returned even if accidently ERRNO is not set. */ static inline gpg_error_t out_of_core (void) { return gpg_error_from_syserror (); } /* A type to hold the ISO time. Note that this this is the same as the the KSBA type ksba_isotime_t. */ typedef char gnupg_isotime_t[16]; /*-- gettime.c --*/ time_t gnupg_get_time (void); void gnupg_get_isotime (gnupg_isotime_t timebuf); void gnupg_set_time (time_t newtime, int freeze); int gnupg_faked_time_p (void); u32 make_timestamp (void); u32 scan_isodatestr (const char *string); time_t isotime2epoch (const char *string); void epoch2isotime (gnupg_isotime_t timebuf, time_t atime); u32 add_days_to_timestamp (u32 stamp, u16 days); const char *strtimevalue (u32 stamp); const char *strtimestamp (u32 stamp); /* GMT */ const char *isotimestamp (u32 stamp); /* GMT */ const char *asctimestamp (u32 stamp); /* localized */ gpg_error_t add_seconds_to_isotime (gnupg_isotime_t atime, int nseconds); gpg_error_t add_days_to_isotime (gnupg_isotime_t atime, int ndays); gpg_error_t check_isotime (const gnupg_isotime_t atime); void dump_isotime (const gnupg_isotime_t atime); /* Copy one ISO date to another, this is inline so that we can do a minimal sanity check. A null date (empty string) is allowed. */ static inline void gnupg_copy_time (gnupg_isotime_t d, const gnupg_isotime_t s) { if (*s) { if ((strlen (s) != 15 || s[8] != 'T')) BUG(); memcpy (d, s, 15); d[15] = 0; } else *d = 0; } /*-- signal.c --*/ void gnupg_init_signals (int mode, void (*fast_cleanup)(void)); void gnupg_pause_on_sigusr (int which); void gnupg_block_all_signals (void); void gnupg_unblock_all_signals (void); /*-- yesno.c --*/ int answer_is_yes (const char *s); int answer_is_yes_no_default (const char *s, int def_answer); int answer_is_yes_no_quit (const char *s); int answer_is_okay_cancel (const char *s, int def_answer); /*-- xreadline.c --*/ ssize_t read_line (FILE *fp, char **addr_of_buffer, size_t *length_of_buffer, size_t *max_length); /*-- b64enc.c and b64dec.c --*/ struct b64state { unsigned int flags; int idx; int quad_count; FILE *fp; char *title; unsigned char radbuf[4]; u32 crc; int stop_seen:1; int invalid_encoding:1; }; gpg_error_t b64enc_start (struct b64state *state, FILE *fp, const char *title); gpg_error_t b64enc_write (struct b64state *state, const void *buffer, size_t nbytes); gpg_error_t b64enc_finish (struct b64state *state); gpg_error_t b64dec_start (struct b64state *state, const char *title); gpg_error_t b64dec_proc (struct b64state *state, void *buffer, size_t length, size_t *r_nbytes); gpg_error_t b64dec_finish (struct b64state *state); /*-- sexputil.c */ gpg_error_t make_canon_sexp (gcry_sexp_t sexp, unsigned char **r_buffer, size_t *r_buflen); gpg_error_t keygrip_from_canon_sexp (const unsigned char *key, size_t keylen, unsigned char *grip); int cmp_simple_canon_sexp (const unsigned char *a, const unsigned char *b); unsigned char *make_simple_sexp_from_hexstr (const char *line, size_t *nscanned); int hash_algo_from_sigval (const unsigned char *sigval); unsigned char *make_canon_sexp_from_rsa_pk (const void *m, size_t mlen, const void *e, size_t elen, size_t *r_len); gpg_error_t get_rsa_pk_from_canon_sexp (const unsigned char *keydata, size_t keydatalen, unsigned char const **r_n, size_t *r_nlen, unsigned char const **r_e, size_t *r_elen); gpg_error_t get_pk_algo_from_canon_sexp (const unsigned char *keydata, size_t keydatalen, int *r_algo); /*-- convert.c --*/ int hex2bin (const char *string, void *buffer, size_t length); int hexcolon2bin (const char *string, void *buffer, size_t length); char *bin2hex (const void *buffer, size_t length, char *stringbuf); char *bin2hexcolon (const void *buffer, size_t length, char *stringbuf); const char *hex2str (const char *hexstring, char *buffer, size_t bufsize, size_t *buflen); char *hex2str_alloc (const char *hexstring, size_t *r_count); /*-- percent.c --*/ char *percent_plus_escape (const char *string); char *percent_plus_unescape (const char *string, int nulrepl); char *percent_unescape (const char *string, int nulrepl); size_t percent_plus_unescape_inplace (char *string, int nulrepl); size_t percent_unescape_inplace (char *string, int nulrepl); /*-- homedir.c --*/ const char *standard_homedir (void); const char *default_homedir (void); const char *gnupg_sysconfdir (void); const char *gnupg_bindir (void); const char *gnupg_libexecdir (void); const char *gnupg_libdir (void); const char *gnupg_datadir (void); const char *gnupg_localedir (void); const char *dirmngr_socket_name (void); /* All module names. We also include gpg and gpgsm for the sake for gpgconf. */ #define GNUPG_MODULE_NAME_AGENT 1 #define GNUPG_MODULE_NAME_PINENTRY 2 #define GNUPG_MODULE_NAME_SCDAEMON 3 #define GNUPG_MODULE_NAME_DIRMNGR 4 #define GNUPG_MODULE_NAME_PROTECT_TOOL 5 #define GNUPG_MODULE_NAME_CHECK_PATTERN 6 #define GNUPG_MODULE_NAME_GPGSM 7 #define GNUPG_MODULE_NAME_GPG 8 #define GNUPG_MODULE_NAME_CONNECT_AGENT 9 #define GNUPG_MODULE_NAME_GPGCONF 10 const char *gnupg_module_name (int which); /*-- gpgrlhelp.c --*/ void gnupg_rl_initialize (void); /*-- helpfile.c --*/ char *gnupg_get_help_string (const char *key, int only_current_locale); /*-- localename.c --*/ const char *gnupg_messages_locale_name (void); /*-- miscellaneous.c --*/ /* This function is called at startup to tell libgcrypt to use our own logging subsystem. */ void setup_libgcrypt_logging (void); /* Same as estream_asprintf but die on memory failure. */ char *xasprintf (const char *fmt, ...) JNLIB_GCC_A_PRINTF(1,2); /* This is now an alias to estream_asprintf. */ char *xtryasprintf (const char *fmt, ...) JNLIB_GCC_A_PRINTF(1,2); const char *print_fname_stdout (const char *s); const char *print_fname_stdin (const char *s); void print_string (FILE *fp, const byte *p, size_t n, int delim); void print_utf8_string2 ( FILE *fp, const byte *p, size_t n, int delim); void print_utf8_string (FILE *fp, const byte *p, size_t n); void print_hexstring (FILE *fp, const void *buffer, size_t length, int reserved); char *make_printable_string (const void *p, size_t n, int delim); int is_file_compressed (const char *s, int *ret_rc); int match_multistr (const char *multistr,const char *match); /*-- Simple replacement functions. */ #ifndef HAVE_TTYNAME /* Systems without ttyname (W32) will merely return NULL. */ static inline char * ttyname (int fd) { (void)fd; return NULL; } #endif /* !HAVE_TTYNAME */ #ifdef HAVE_W32CE_SYSTEM #define getpid() GetCurrentProcessId () char *_gnupg_getenv (const char *name); /* See sysutils.c */ #define getenv(a) _gnupg_getenv ((a)) #endif /*-- Macros to replace ctype ones to avoid locale problems. --*/ #define spacep(p) (*(p) == ' ' || *(p) == '\t') #define digitp(p) (*(p) >= '0' && *(p) <= '9') #define hexdigitp(a) (digitp (a) \ || (*(a) >= 'A' && *(a) <= 'F') \ || (*(a) >= 'a' && *(a) <= 'f')) /* Note this isn't identical to a C locale isspace() without \f and \v, but works for the purposes used here. */ #define ascii_isspace(a) ((a)==' ' || (a)=='\n' || (a)=='\r' || (a)=='\t') /* The atoi macros assume that the buffer has only valid digits. */ #define atoi_1(p) (*(p) - '0' ) #define atoi_2(p) ((atoi_1(p) * 10) + atoi_1((p)+1)) #define atoi_4(p) ((atoi_2(p) * 100) + atoi_2((p)+2)) #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)) #define xtoi_4(p) ((xtoi_2(p) * 256) + xtoi_2((p)+2)) /*-- Forward declaration of the commonly used server control structure. */ /* (We need it here as it is used by some callback prototypes.) */ struct server_control_s; typedef struct server_control_s *ctrl_t; #endif /*GNUPG_COMMON_UTIL_H*/ diff --git a/jnlib/w32-afunix.c b/common/w32-afunix.c similarity index 100% rename from jnlib/w32-afunix.c rename to common/w32-afunix.c diff --git a/jnlib/w32-afunix.h b/common/w32-afunix.h similarity index 100% rename from jnlib/w32-afunix.h rename to common/w32-afunix.h diff --git a/jnlib/w32-reg.c b/common/w32-reg.c similarity index 100% rename from jnlib/w32-reg.c rename to common/w32-reg.c diff --git a/jnlib/w32help.h b/common/w32help.h similarity index 100% rename from jnlib/w32help.h rename to common/w32help.h diff --git a/common/xasprintf.c b/common/xasprintf.c index 9774d06de..f16410dbd 100644 --- a/common/xasprintf.c +++ b/common/xasprintf.c @@ -1,62 +1,61 @@ /* xasprintf.c * Copyright (C) 2003, 2005 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 3 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, see . */ #include #include #include #include "util.h" #include "iobuf.h" -#include "estream-printf.h" #if !defined(_ESTREAM_PRINTF_MALLOC) || !defined(_ESTREAM_PRINTF_FREE) #error Need to define ESTREAM_PRINTF_MALLOC and _FREE #endif /* Same as asprintf but return an allocated buffer suitable to be freed using xfree. This function simply dies on memory failure, thus no extra check is required. */ char * xasprintf (const char *fmt, ...) { va_list ap; char *buf; va_start (ap, fmt); if (estream_vasprintf (&buf, fmt, ap) < 0) log_fatal ("estream_asprintf failed: %s\n", strerror (errno)); va_end (ap); return buf; } /* Same as above but return NULL on memory failure. */ char * xtryasprintf (const char *fmt, ...) { int rc; va_list ap; char *buf; va_start (ap, fmt); rc = estream_vasprintf (&buf, fmt, ap); va_end (ap); if (rc < 0) return NULL; return buf; } diff --git a/jnlib/xmalloc.c b/common/xmalloc.c similarity index 100% rename from jnlib/xmalloc.c rename to common/xmalloc.c diff --git a/jnlib/xmalloc.h b/common/xmalloc.h similarity index 100% rename from jnlib/xmalloc.h rename to common/xmalloc.h diff --git a/configure.ac b/configure.ac index 03d41fc19..c02fb1423 100644 --- a/configure.ac +++ b/configure.ac @@ -1,1538 +1,1534 @@ # configure.ac - for GnuPG 2.1 # Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, # 2006, 2007, 2008, 2009 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 3 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, see . # Process this file with autoconf to produce a configure script. AC_PREREQ(2.61) min_automake_version="1.10" # Remember to change the version number immediately *after* a release. # Set my_issvn to "yes" for non-released code. Remember to run an # "svn up" and "autogen.sh" right before creating a distribution. m4_define([my_version], [2.1.0]) m4_define([my_issvn], [yes]) m4_define([svn_revision], m4_esyscmd([printf "%d" $(svn info 2>/dev/null \ | sed -n '/^Revision:/ s/[^0-9]//gp'|head -1)])) AC_INIT([gnupg], [my_version[]m4_if(my_issvn,[yes],[-svn[]svn_revision])], [http://bugs.gnupg.org]) # Set development_version to yes if the minor number is odd or you # feel that the default check for a development version is not # sufficient. development_version=no NEED_GPG_ERROR_VERSION=1.4 NEED_LIBGCRYPT_API=1 NEED_LIBGCRYPT_VERSION=1.4.0 NEED_LIBASSUAN_API=2 -NEED_LIBASSUAN_VERSION=1.1.0 +NEED_LIBASSUAN_VERSION=2.0.0 NEED_KSBA_API=1 NEED_KSBA_VERSION=1.0.2 PACKAGE=$PACKAGE_NAME PACKAGE_GT=${PACKAGE_NAME}2 VERSION=$PACKAGE_VERSION AC_CONFIG_AUX_DIR(scripts) AC_CONFIG_SRCDIR(sm/gpgsm.c) AM_CONFIG_HEADER(config.h) AM_INIT_AUTOMAKE($PACKAGE, $VERSION) AC_CANONICAL_HOST AB_INIT AC_GNU_SOURCE # Some status variables. have_gpg_error=no have_libgcrypt=no have_libassuan=no have_ksba=no have_pth=no have_libusb=no have_adns=no use_bzip2=yes use_exec=yes disable_keyserver_path=no use_ccid_driver=yes GNUPG_BUILD_PROGRAM(gpg, yes) GNUPG_BUILD_PROGRAM(gpgsm, yes) GNUPG_BUILD_PROGRAM(agent, yes) GNUPG_BUILD_PROGRAM(scdaemon, yes) GNUPG_BUILD_PROGRAM(g13, yes) GNUPG_BUILD_PROGRAM(tools, yes) GNUPG_BUILD_PROGRAM(doc, yes) GNUPG_BUILD_PROGRAM(symcryptrun, no) AC_SUBST(PACKAGE) AC_SUBST(PACKAGE_GT) AC_SUBST(VERSION) AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of this package]) AC_DEFINE_UNQUOTED(PACKAGE_GT, "$PACKAGE_GT", [Name of this package for gettext]) AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version of this package]) AC_DEFINE_UNQUOTED(PACKAGE_BUGREPORT, "$PACKAGE_BUGREPORT", [Bug report address]) AC_DEFINE_UNQUOTED(NEED_LIBGCRYPT_VERSION, "$NEED_LIBGCRYPT_VERSION", [Required version of Libgcrypt]) AC_DEFINE_UNQUOTED(NEED_KSBA_VERSION, "$NEED_KSBA_VERSION", [Required version of Libksba]) # The default is to use the modules from this package and the few # other packages in a standard place; i.e where this package gets # installed. With these options it is possible to override these # ${prefix} depended values with fixed paths, which can't be replaced # at make time. See also am/cmacros.am and the defaults in AH_BOTTOM. AC_ARG_WITH(agent-pgm, [ --with-agent-pgm=PATH Use PATH as the default for the agent)], GNUPG_AGENT_PGM="$withval", GNUPG_AGENT_PGM="" ) AC_SUBST(GNUPG_AGENT_PGM) AM_CONDITIONAL(GNUPG_AGENT_PGM, test -n "$GNUPG_AGENT_PGM") show_gnupg_agent_pgm="(default)" test -n "$GNUPG_AGENT_PGM" && show_gnupg_agent_pgm="$GNUPG_AGENT_PGM" AC_ARG_WITH(pinentry-pgm, [ --with-pinentry-pgm=PATH Use PATH as the default for the pinentry)], GNUPG_PINENTRY_PGM="$withval", GNUPG_PINENTRY_PGM="" ) AC_SUBST(GNUPG_PINENTRY_PGM) AM_CONDITIONAL(GNUPG_PINENTRY_PGM, test -n "$GNUPG_PINENTRY_PGM") show_gnupg_pinentry_pgm="(default)" test -n "$GNUPG_PINENTRY_PGM" && show_gnupg_pinentry_pgm="$GNUPG_PINENTRY_PGM" AC_ARG_WITH(scdaemon-pgm, [ --with-scdaemon-pgm=PATH Use PATH as the default for the scdaemon)], GNUPG_SCDAEMON_PGM="$withval", GNUPG_SCDAEMON_PGM="" ) AC_SUBST(GNUPG_SCDAEMON_PGM) AM_CONDITIONAL(GNUPG_SCDAEMON_PGM, test -n "$GNUPG_SCDAEMON_PGM") show_gnupg_scdaemon_pgm="(default)" test -n "$GNUPG_SCDAEMON_PGM" && show_gnupg_scdaemon_pgm="$GNUPG_SCDAEMON_PGM" AC_ARG_WITH(dirmngr-pgm, [ --with-dirmngr-pgm=PATH Use PATH as the default for the dirmngr)], GNUPG_DIRMNGR_PGM="$withval", GNUPG_DIRMNGR_PGM="" ) AC_SUBST(GNUPG_DIRMNGR_PGM) AM_CONDITIONAL(GNUPG_DIRMNGR_PGM, test -n "$GNUPG_DIRMNGR_PGM") show_gnupg_dirmngr_pgm="(default)" test -n "$GNUPG_DIRMNGR_PGM" && show_gnupg_dirmngr_pgm="$GNUPG_DIRMNGR_PGM" AC_ARG_WITH(protect-tool-pgm, [ --with-protect-tool-pgm=PATH Use PATH as the default for the protect-tool)], GNUPG_PROTECT_TOOL_PGM="$withval", GNUPG_PROTECT_TOOL_PGM="" ) AC_SUBST(GNUPG_PROTECT_TOOL_PGM) AM_CONDITIONAL(GNUPG_PROTECT_TOOL_PGM, test -n "$GNUPG_PROTECT_TOOL_PGM") show_gnupg_protect_tool_pgm="(default)" test -n "$GNUPG_PROTECT_TOOL_PGM" \ && show_gnupg_protect_tool_pgm="$GNUPG_PROTECT_TOOL_PGM" # Some folks want to use only the agent from this packet. Make it # easier for them by providing the configure option # --enable-only-agent. AC_ARG_ENABLE(agent-only, AC_HELP_STRING([--enable-agent-only],[build only the gpg-agent]), build_agent_only=$enableval) # SELinux support includes tracking of sensitive files to avoid # leaking their contents through processing these files by gpg itself AC_MSG_CHECKING([whether SELinux support is requested]) AC_ARG_ENABLE(selinux-support, AC_HELP_STRING([--enable-selinux-support], [enable SELinux support]), selinux_support=$enableval, selinux_support=no) AC_MSG_RESULT($selinux_support) # Allow disabling of bzib2 support. # It is defined only after we confirm the library is available later AC_MSG_CHECKING([whether to enable the BZIP2 compression algorithm]) AC_ARG_ENABLE(bzip2, AC_HELP_STRING([--disable-bzip2],[disable the BZIP2 compression algorithm]), use_bzip2=$enableval) AC_MSG_RESULT($use_bzip2) # Configure option to allow or disallow execution of external # programs, like a photo viewer. AC_MSG_CHECKING([whether to enable external program execution]) AC_ARG_ENABLE(exec, AC_HELP_STRING([--disable-exec],[disable all external program execution]), use_exec=$enableval) AC_MSG_RESULT($use_exec) if test "$use_exec" = no ; then AC_DEFINE(NO_EXEC,1,[Define to disable all external program execution]) fi if test "$use_exec" = yes ; then AC_MSG_CHECKING([whether to enable photo ID viewing]) AC_ARG_ENABLE(photo-viewers, [ --disable-photo-viewers disable photo ID viewers], [if test "$enableval" = no ; then AC_DEFINE(DISABLE_PHOTO_VIEWER,1,[define to disable photo viewing]) fi],enableval=yes) gnupg_cv_enable_photo_viewers=$enableval AC_MSG_RESULT($enableval) if test "$gnupg_cv_enable_photo_viewers" = yes ; then AC_MSG_CHECKING([whether to use a fixed photo ID viewer]) AC_ARG_WITH(photo-viewer, [ --with-photo-viewer=FIXED_VIEWER set a fixed photo ID viewer], [if test "$withval" = yes ; then withval=no elif test "$withval" != no ; then AC_DEFINE_UNQUOTED(FIXED_PHOTO_VIEWER,"$withval", [if set, restrict photo-viewer to this]) fi],withval=no) AC_MSG_RESULT($withval) fi AC_MSG_CHECKING([whether to enable external keyserver helpers]) AC_ARG_ENABLE(keyserver-helpers, [ --disable-keyserver-helpers disable all external keyserver support], [if test "$enableval" = no ; then AC_DEFINE(DISABLE_KEYSERVER_HELPERS,1, [define to disable keyserver helpers]) fi],enableval=yes) gnupg_cv_enable_keyserver_helpers=$enableval AC_MSG_RESULT($enableval) if test "$gnupg_cv_enable_keyserver_helpers" = yes ; then # LDAP is defined only after we confirm the library is available later AC_MSG_CHECKING([whether LDAP keyserver support is requested]) AC_ARG_ENABLE(ldap, AC_HELP_STRING([--disable-ldap],[disable LDAP keyserver interface only]), try_ldap=$enableval, try_ldap=yes) AC_MSG_RESULT($try_ldap) AC_MSG_CHECKING([whether HKP keyserver support is requested]) AC_ARG_ENABLE(hkp, AC_HELP_STRING([--disable-hkp],[disable HKP keyserver interface only]), try_hkp=$enableval, try_hkp=yes) AC_MSG_RESULT($try_hkp) AC_MSG_CHECKING([whether finger key fetching support is requested]) AC_ARG_ENABLE(finger, AC_HELP_STRING([--disable-finger], [disable finger key fetching interface only]), try_finger=$enableval, try_finger=yes) AC_MSG_RESULT($try_finger) AC_MSG_CHECKING([whether generic object key fetching support is requested]) AC_ARG_ENABLE(generic, AC_HELP_STRING([--disable-generic], [disable generic object key fetching interface only]), try_generic=$enableval, try_generic=yes) AC_MSG_RESULT($try_generic) AC_MSG_CHECKING([whether email keyserver support is requested]) AC_ARG_ENABLE(mailto, AC_HELP_STRING([--enable-mailto], [enable email keyserver interface only]), try_mailto=$enableval, try_mailto=no) AC_MSG_RESULT($try_mailto) fi AC_MSG_CHECKING([whether keyserver exec-path is enabled]) AC_ARG_ENABLE(keyserver-path, AC_HELP_STRING([--disable-keyserver-path], [disable the exec-path option for keyserver helpers]), [if test "$enableval" = no ; then disable_keyserver_path=yes fi],enableval=yes) AC_MSG_RESULT($enableval) fi # # Check for the key/uid cache size. This can't be zero, but can be # pretty small on embedded systems. This is used for the gpg part. # AC_MSG_CHECKING([for the size of the key and uid cache]) AC_ARG_ENABLE(key-cache, AC_HELP_STRING([--enable-key-cache=SIZE], [Set key cache to SIZE (default 4096)]),,enableval=4096) if test "$enableval" = "no"; then enableval=5 elif test "$enableval" = "yes" || test "$enableval" = ""; then enableval=4096 fi changequote(,)dnl key_cache_size=`echo "$enableval" | sed 's/[A-Za-z]//g'` changequote([,])dnl if test "$enableval" != "$key_cache_size" || test "$key_cache_size" -lt 5; then AC_MSG_ERROR([invalid key-cache size]) fi AC_MSG_RESULT($key_cache_size) AC_DEFINE_UNQUOTED(PK_UID_CACHE_SIZE,$key_cache_size, [Size of the key and UID caches]) # # Check whether we want to use Linux capabilities # AC_MSG_CHECKING([whether use of capabilities is requested]) AC_ARG_WITH(capabilities, [ --with-capabilities use linux capabilities [default=no]], [use_capabilities="$withval"],[use_capabilities=no]) AC_MSG_RESULT($use_capabilities) # # Allow disabling of internal CCID support. # It is defined only after we confirm the library is available later # AC_MSG_CHECKING([whether to enable the internal CCID driver]) AC_ARG_ENABLE(ccid-driver, AC_HELP_STRING([--disable-ccid-driver], [disable the internal CCID driver]), use_ccid_driver=$enableval) AC_MSG_RESULT($use_ccid_driver) # # To avoid double inclusion of config.h which might happen at some # places, we add the usual double inclusion protection at the top of # config.h. # AH_TOP([ #ifndef GNUPG_CONFIG_H_INCLUDED #define GNUPG_CONFIG_H_INCLUDED ]) # # Stuff which goes at the bottom of config.h. # AH_BOTTOM([ /* This is the major version number of GnuPG so that source included files can test for this. Note, that we use 2 here even for GnuPG 1.9.x. */ #define GNUPG_MAJOR_VERSION 2 /* Now to separate file name parts. Please note that the string version must not contain more than one character because the code assumes strlen()==1 */ #ifdef HAVE_DOSISH_SYSTEM #define DIRSEP_C '\\' #define DIRSEP_S "\\" #define EXTSEP_C '.' #define EXTSEP_S "." #define PATHSEP_C ';' #define PATHSEP_S ";" #define EXEEXT_S ".exe" #else #define DIRSEP_C '/' #define DIRSEP_S "/" #define EXTSEP_C '.' #define EXTSEP_S "." #define PATHSEP_C ':' #define PATHSEP_S ":" #define EXEEXT_S "" #endif /* This is the same as VERSION, but should be overridden if the platform cannot handle things like dots '.' in filenames. Set SAFE_VERSION_DOT and SAFE_VERSION_DASH to whatever SAFE_VERSION uses for dots and dashes. */ #define SAFE_VERSION VERSION #define SAFE_VERSION_DOT '.' #define SAFE_VERSION_DASH '-' /* Some global constants. */ #ifdef HAVE_DRIVE_LETTERS #define GNUPG_DEFAULT_HOMEDIR "c:/gnupg" #elif defined(__VMS) #define GNUPG_DEFAULT_HOMEDIR "/SYS\$LOGIN/gnupg" #else #define GNUPG_DEFAULT_HOMEDIR "~/.gnupg" #endif #define GNUPG_PRIVATE_KEYS_DIR "private-keys-v1.d" /* For some systems (DOS currently), we hardcode the path here. For POSIX systems the values are constructed by the Makefiles, so that the values may be overridden by the make invocations; this is to comply with the GNU coding standards. */ #ifdef HAVE_DRIVE_LETTERS /* FIXME: We need to use a function to determine these values depending on the actual installation directory. */ #define GNUPG_BINDIR "c:\\gnupg" #define GNUPG_LIBEXECDIR "c:\\gnupg" #define GNUPG_LIBDIR "c:\\gnupg" #define GNUPG_DATADIR "c:\\gnupg" #define GNUPG_SYSCONFDIR "c:\\gnupg" #endif /* Derive some other constants. */ #if !(defined(HAVE_FORK) && defined(HAVE_PIPE) && defined(HAVE_WAITPID)) #define EXEC_TEMPFILE_ONLY #endif /* We didn't define endianness above, so get it from OS macros. This is intended for making fat binary builds on OS X. */ #if !defined(BIG_ENDIAN_HOST) && !defined(LITTLE_ENDIAN_HOST) #if defined(__BIG_ENDIAN__) #define BIG_ENDIAN_HOST 1 #elif defined(__LITTLE_ENDIAN__) #define LITTLE_ENDIAN_HOST 1 #else #error "No endianness found" #endif #endif /* Hack used for W32: ldap.m4 also tests for the ASCII version of ldap_start_tls_s because that is the actual symbol used in the library. winldap.h redefines it to our commonly used value, thus we define our usual macro here. */ #ifdef HAVE_LDAP_START_TLS_SA # ifndef HAVE_LDAP_START_TLS_S # define HAVE_LDAP_START_TLS_S 1 # endif #endif /* Tell libgcrypt not to use its own libgpg-error implementation. */ #define USE_LIBGPG_ERROR 1 /* We use jnlib, so tell other modules about it. */ #define HAVE_JNLIB_LOGGING 1 /* Our HTTP code is used in estream mode. */ #define HTTP_USE_ESTREAM 1 /* Under W32 we do an explicit socket initialization, thus we need to avoid the on-demand initialization which would also install an atexit handler. */ #define HTTP_NO_WSASTARTUP /* We always include support for the OpenPGP card. */ #define ENABLE_CARD_SUPPORT 1 /* We explicitly need to disable PTH's soft mapping as Debian currently enables it by default for no reason. */ #define PTH_SYSCALL_SOFT 0 /* We want to use the libgcrypt provided memory allocation for asprintf. */ #define _ESTREAM_PRINTF_MALLOC gcry_malloc #define _ESTREAM_PRINTF_FREE gcry_free -#define _ESTREAM_PRINTF_EXTRA_INCLUDE "util.h" +#define _ESTREAM_PRINTF_EXTRA_INCLUDE "../common/util.h" /* Under Windows we use the gettext code from libgpg-error. */ #define GPG_ERR_ENABLE_GETTEXT_MACROS #endif /*GNUPG_CONFIG_H_INCLUDED*/ ]) AM_MAINTAINER_MODE # Checks for programs. AC_MSG_NOTICE([checking for programs]) AC_PROG_MAKE_SET AM_SANITY_CHECK missing_dir=`cd $ac_aux_dir && pwd` AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir) AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir) AM_MISSING_PROG(AUTOMAKE, automake, $missing_dir) AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir) AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir) AC_PROG_AWK AC_PROG_CC AC_PROG_CPP AM_PROG_CC_C_O if test "x$ac_cv_prog_cc_c89" = "xno" ; then AC_MSG_ERROR([[No C-89 compiler found]]) fi AC_PROG_INSTALL AC_PROG_LN_S AC_PROG_RANLIB AC_CHECK_TOOL(AR, ar, :) AC_PATH_PROG(PERL,"perl") AC_CHECK_TOOL(WINDRES, windres, :) AC_ISC_POSIX gl_EARLY AC_SYS_LARGEFILE GNUPG_CHECK_FAQPROG GNUPG_CHECK_USTAR # We need to compile and run a program on the build machine. A # comment in libgpg-error says that the AC_PROG_CC_FOR_BUILD macro in # the AC archive is broken for autoconf 2.57. Given that tehre is no # newer version of that macro, we assume that it is also broken for # autoconf 2.61 and thus we use a simple but usually sufficient # approach. AC_MSG_CHECKING(for cc for build) if test "$cross_compiling" = "yes"; then CC_FOR_BUILD="${CC_FOR_BUILD-cc}" else CC_FOR_BUILD="${CC_FOR_BUILD-$CC}" fi AC_MSG_RESULT($CC_FOR_BUILD) AC_ARG_VAR(CC_FOR_BUILD,[build system C compiler]) try_gettext=yes have_dosish_system=no have_w32_system=no have_w32ce_system=no use_simple_gettext=no case "${host}" in *-mingw32*) # special stuff for Windoze NT ac_cv_have_dev_random=no AC_DEFINE(USE_ONLY_8DOT3,1, [set this to limit filenames to the 8.3 format]) AC_DEFINE(HAVE_DRIVE_LETTERS,1, [defined if we must run on a stupid file system]) AC_DEFINE(USE_SIMPLE_GETTEXT,1, [because the Unix gettext has too much overhead on MingW32 systems and these systems lack Posix functions, we use a simplified version of gettext]) disable_keyserver_path=yes have_dosish_system=yes have_w32_system=yes case "${host}" in *-mingw32ce*) have_w32ce_system=yes ;; esac try_gettext="no" use_simple_gettext=yes ;; i?86-emx-os2 | i?86-*-os2*emx ) # OS/2 with the EMX environment ac_cv_have_dev_random=no AC_DEFINE(HAVE_DRIVE_LETTERS) have_dosish_system=yes try_gettext="no" ;; i?86-*-msdosdjgpp*) # DOS with the DJGPP environment ac_cv_have_dev_random=no AC_DEFINE(HAVE_DRIVE_LETTERS) have_dosish_system=yes try_gettext="no" ;; *-*-freebsd*) # FreeBSD CPPFLAGS="$CPPFLAGS -I/usr/local/include" LDFLAGS="$LDFLAGS -L/usr/local/lib" ;; *-*-hpux*) if test -z "$GCC" ; then CFLAGS="$CFLAGS -Ae -D_HPUX_SOURCE" fi ;; *-dec-osf4*) if test -z "$GCC" ; then # Suppress all warnings # to get rid of the unsigned/signed char mismatch warnings. CFLAGS="$CFLAGS -w" fi ;; *-dec-osf5*) if test -z "$GCC" ; then # Use the newer compiler `-msg_disable ptrmismatch1' to # get rid of the unsigned/signed char mismatch warnings. # Using this may hide other pointer mismatch warnings, but # it at least lets other warning classes through CFLAGS="$CFLAGS -msg_disable ptrmismatch1" fi ;; m68k-atari-mint) ;; *) ;; esac if test "$have_dosish_system" = yes; then AC_DEFINE(HAVE_DOSISH_SYSTEM,1, [Defined if we run on some of the PCDOS like systems (DOS, Windoze. OS/2) with special properties like no file modes]) fi AM_CONDITIONAL(HAVE_DOSISH_SYSTEM, test "$have_dosish_system" = yes) AM_CONDITIONAL(USE_SIMPLE_GETTEXT, test x"$use_simple_gettext" = xyes) if test "$have_w32_system" = yes; then AC_DEFINE(HAVE_W32_SYSTEM,1, [Defined if we run on a W32 API based system]) if test "$have_w32ce_system" = yes; then AC_DEFINE(HAVE_W32CE_SYSTEM,1,[Defined if we run on WindowsCE]) fi fi AM_CONDITIONAL(HAVE_W32_SYSTEM, test "$have_w32_system" = yes) AM_CONDITIONAL(HAVE_W32CE_SYSTEM, test "$have_w32ce_system" = yes) if test "$disable_keyserver_path" = yes; then AC_DEFINE(DISABLE_KEYSERVER_PATH,1, [Defined to disable exec-path for keyserver helpers]) fi # (These need to go after AC_PROG_CC so that $EXEEXT is defined) AC_DEFINE_UNQUOTED(EXEEXT,"$EXEEXT",[The executable file extension, if any]) if test x"$try_hkp" = xyes ; then AC_SUBST(GPGKEYS_HKP,"gpg2keys_hkp$EXEEXT") fi if test x"$try_finger" = xyes ; then AC_SUBST(GPGKEYS_FINGER,"gpg2keys_finger$EXEEXT") fi # # Checks for libraries. # AC_MSG_NOTICE([checking for libraries]) # # libgpg-error is a library with error codes shared between GnuPG # related projects. # AM_PATH_GPG_ERROR("$NEED_GPG_ERROR_VERSION", have_gpg_error=yes,have_gpg_error=no) # # Libgcrypt is our generic crypto library # AM_PATH_LIBGCRYPT("$NEED_LIBGCRYPT_API:$NEED_LIBGCRYPT_VERSION", have_libgcrypt=yes,have_libgcrypt=no) # # libassuan is used for IPC # AM_PATH_LIBASSUAN("$NEED_LIBASSUAN_API:$NEED_LIBASSUAN_VERSION", have_libassuan=yes,have_libassuan=no) if test "$have_libassuan" = "yes"; then - have_libassuan=no - AM_PATH_LIBASSUAN("$NEED_LIBASSUAN_API:$NEED_LIBASSUAN_VERSION", - have_libassuan=yes,have_libassuan=no) AC_DEFINE_UNQUOTED(GNUPG_LIBASSUAN_VERSION, "$libassuan_version", [version of the libassuan library]) fi # # libksba is our X.509 support library # AM_PATH_KSBA("$NEED_KSBA_API:$NEED_KSBA_VERSION",have_ksba=yes,have_ksba=no) # # libusb allows us to use the integrated CCID smartcard reader driver. # # FiXME: Use GNUPG_CHECK_LIBUSB and modify to use separate AC_SUBSTs. if test "$use_ccid_driver" = yes ; then AC_CHECK_LIB(usb, usb_bulk_write, [ LIBUSB_LIBS="$LIBUSB_LIBS -lusb" AC_DEFINE(HAVE_LIBUSB,1, [defined if libusb is available]) have_libusb=yes ]) AC_CHECK_FUNCS(usb_create_match) fi AC_SUBST(LIBUSB_LIBS) # # Check wether it is necessary to link against libdl. # gnupg_dlopen_save_libs="$LIBS" LIBS="" AC_SEARCH_LIBS(dlopen, c dl,,,) DL_LIBS=$LIBS AC_SUBST(DL_LIBS) LIBS="$gnupg_dlopen_save_libs" # Checks for g13 AC_PATH_PROG(ENCFS, encfs, /usr/bin/encfs) AC_DEFINE_UNQUOTED(ENCFS, "${ENCFS}", [defines the filename of the encfs program]) AC_PATH_PROG(FUSERMOUNT, fusermount, /usr/bin/fusermount) AC_DEFINE_UNQUOTED(FUSERMOUNT, "${FUSERMOUNT}", [defines the filename of the fusermount program]) # # Checks for symcryptrun: # # libutil has openpty() and login_tty(). AC_CHECK_LIB(util, openpty, [ LIBUTIL_LIBS="$LIBUTIL_LIBS -lutil" AC_DEFINE(HAVE_LIBUTIL,1, [defined if libutil is available]) ]) AC_SUBST(LIBUTIL_LIBS) # shred is used to clean temporary plain text files. AC_PATH_PROG(SHRED, shred, /usr/bin/shred) AC_DEFINE_UNQUOTED(SHRED, "${SHRED}", [defines the filename of the shred program]) # # Check whether the GNU Pth library is available # Note, that we include a Pth emulation for W32. # GNUPG_PATH_PTH if test "$have_pth" = "yes"; then AC_DEFINE(USE_GNU_PTH, 1, [Defined if the GNU Portable Thread Library should be used]) else AC_MSG_WARN([[ *** *** To support concurrent access to the gpg-agent and the SCdaemon *** we need the support of the GNU Portable Threads Library. *** Download it from ftp://ftp.gnu.org/gnu/pth/ *** On a Debian GNU/Linux system you might want to try *** apt-get install libpth-dev ***]]) fi AC_MSG_NOTICE([checking for networking options]) # # Must check for network library requirements before doing link tests # for ldap, for example. If ldap libs are static (or dynamic and without # ELF runtime link paths), then link will fail and LDAP support won't # be detected. # AC_CHECK_FUNC(gethostbyname, , AC_CHECK_LIB(nsl, gethostbyname, [NETLIBS="-lnsl $NETLIBS"])) AC_CHECK_FUNC(setsockopt, , AC_CHECK_LIB(socket, setsockopt, [NETLIBS="-lsocket $NETLIBS"])) # # Check for ADNS. # _cppflags="${CPPFLAGS}" _ldflags="${LDFLAGS}" AC_ARG_WITH(adns, AC_HELP_STRING([--with-adns=DIR], [look for the adns library in DIR]), [if test -d "$withval"; then CPPFLAGS="${CPPFLAGS} -I$withval/include" LDFLAGS="${LDFLAGS} -L$withval/lib" fi]) if test "$with_adns" != "no"; then AC_CHECK_HEADERS(adns.h, AC_CHECK_LIB(adns, adns_init, [have_adns=yes], [CPPFLAGS=${_cppflags} LDFLAGS=${_ldflags}]), [CPPFLAGS=${_cppflags} LDFLAGS=${_ldflags}]) fi if test "$have_adns" = "yes"; then ADNSLIBS="-ladns" fi AC_SUBST(ADNSLIBS) # Newer adns versions feature a free function to be used under W32. AC_CHECK_FUNCS(adns_free) # # Now try for the resolver functions so we can use DNS for SRV, PA and CERT. # if test x"$try_hkp" = xyes || test x"$try_http" = xyes ; then AC_ARG_ENABLE(dns-srv, AC_HELP_STRING([--disable-dns-srv], [disable the use of DNS SRV in HKP and HTTP]), use_dns_srv=$enableval,use_dns_srv=yes) fi AC_ARG_ENABLE(dns-pka, AC_HELP_STRING([--disable-dns-pka], [disable the use of PKA records in DNS]), use_dns_pka=$enableval,use_dns_pka=yes) AC_ARG_ENABLE(dns-cert, AC_HELP_STRING([--disable-dns-cert], [disable the use of CERT records in DNS]), use_dns_cert=$enableval,use_dns_cert=yes) if test x"$use_dns_pka" = xyes || test x"$use_dns_srv" = xyes \ || test x"$use_dns_cert" = xyes; then _dns_save_libs=$LIBS LIBS="" # the double underscore thing is a glibc-ism? AC_SEARCH_LIBS(res_query,resolv bind,, AC_SEARCH_LIBS(__res_query,resolv bind,,have_resolver=no)) AC_SEARCH_LIBS(dn_expand,resolv bind,, AC_SEARCH_LIBS(__dn_expand,resolv bind,,have_resolver=no)) AC_SEARCH_LIBS(dn_skipname,resolv bind,, AC_SEARCH_LIBS(__dn_skipname,resolv bind,,have_resolver=no)) if test x"$have_resolver" != xno ; then # Make sure that the BIND 4 resolver interface is workable before # enabling any code that calls it. At some point I'll rewrite the # code to use the BIND 8 resolver API. # We might also want to use adns instead. Problem with ADNS is that # it does not support v6. AC_MSG_CHECKING([whether the resolver is usable]) AC_LINK_IFELSE([AC_LANG_PROGRAM([#include #include #include #include ], [[unsigned char answer[PACKETSZ]; res_query("foo.bar",C_IN,T_A,answer,PACKETSZ); dn_skipname(0,0); dn_expand(0,0,0,0,0); ]])],have_resolver=yes,have_resolver=no) AC_MSG_RESULT($have_resolver) # This is Apple-specific and somewhat bizarre as they changed the # define in bind 8 for some reason. if test x"$have_resolver" != xyes ; then AC_MSG_CHECKING( [whether I can make the resolver usable with BIND_8_COMPAT]) AC_LINK_IFELSE([AC_LANG_PROGRAM([#define BIND_8_COMPAT #include #include #include #include ], [[unsigned char answer[PACKETSZ]; res_query("foo.bar",C_IN,T_A,answer,PACKETSZ); dn_skipname(0,0); dn_expand(0,0,0,0,0); ]])],[have_resolver=yes ; need_compat=yes]) AC_MSG_RESULT($have_resolver) fi fi if test x"$have_resolver" = xyes ; then DNSLIBS=$LIBS if test x"$use_dns_srv" = xyes ; then AC_DEFINE(USE_DNS_SRV,1,[define to use DNS SRV]) fi if test x"$use_dns_pka" = xyes ; then AC_DEFINE(USE_DNS_PKA,1,[define to use our experimental DNS PKA]) fi if test x"$use_dns_cert" = xyes ; then AC_DEFINE(USE_DNS_CERT,1,[define to use DNS CERT]) fi if test x"$need_compat" = xyes ; then AC_DEFINE(BIND_8_COMPAT,1,[an Apple OSXism]) fi else # If we have no resolver library but ADNS (e.g. under W32) enable the # code parts which can be used with ADNS. if test x"$have_adns" = xyes ; then DNSLIBS="$ADNSLIBS" AC_DEFINE(USE_ADNS,1,[Use ADNS as resolver library.]) if test x"$use_dns_srv" = xyes ; then AC_DEFINE(USE_DNS_SRV,1) fi if test x"$use_dns_pka" = xyes ; then AC_DEFINE(USE_DNS_PKA,1) fi if test x"$use_dns_cert" = xyes ; then AC_DEFINE(USE_DNS_CERT,1,[define to use DNS CERT]) fi else use_dns_srv=no use_dns_pka=no use_dns_cert=no fi fi LIBS=$_dns_save_libs fi AC_SUBST(DNSLIBS) AM_CONDITIONAL(USE_DNS_SRV, test x"$use_dns_srv" = xyes) # # Check for LDAP # if test "$try_ldap" = yes ; then GNUPG_CHECK_LDAP($NETLIBS) fi # # Check for curl. We fake the curl API if libcurl isn't installed. # We require 7.10 or later as we use curl_version_info(). # LIBCURL_CHECK_CONFIG([yes],[7.10],,[fake_curl=yes]) AM_CONDITIONAL(FAKE_CURL,test x"$fake_curl" = xyes) # Generic, for us, means curl if test x"$try_generic" = xyes ; then AC_SUBST(GPGKEYS_CURL,"gpg2keys_curl$EXEEXT") fi # # Check for sendmail # # This isn't necessarily sendmail itself, but anything that gives a # sendmail-ish interface to the outside world. That includes Exim, # Postfix, etc. Basically, anything that can handle "sendmail -t". if test "$try_mailto" = yes ; then AC_ARG_WITH(mailprog, AC_HELP_STRING([--with-mailprog=NAME], [use "NAME -t" for mail transport]), ,with_mailprog=yes) if test x"$with_mailprog" = xyes ; then AC_PATH_PROG(SENDMAIL,sendmail,,$PATH:/usr/sbin:/usr/libexec:/usr/lib) if test "$ac_cv_path_SENDMAIL" ; then GPGKEYS_MAILTO="gpg2keys_mailto" fi elif test x"$with_mailprog" != xno ; then AC_MSG_CHECKING([for a mail transport program]) AC_SUBST(SENDMAIL,$with_mailprog) AC_MSG_RESULT($with_mailprog) GPGKEYS_MAILTO="gpg2keys_mailto" fi fi AC_SUBST(GPGKEYS_MAILTO) # # Construct a printable name of the OS # case "${host}" in *-mingw32ce*) PRINTABLE_OS_NAME="W32CE" ;; *-mingw32*) PRINTABLE_OS_NAME="MingW32" ;; *-*-cygwin*) PRINTABLE_OS_NAME="Cygwin" ;; i?86-emx-os2 | i?86-*-os2*emx ) PRINTABLE_OS_NAME="OS/2" ;; i?86-*-msdosdjgpp*) PRINTABLE_OS_NAME="MSDOS/DJGPP" try_dynload=no ;; *-linux*) PRINTABLE_OS_NAME="GNU/Linux" ;; *) PRINTABLE_OS_NAME=`uname -s || echo "Unknown"` ;; esac AC_DEFINE_UNQUOTED(PRINTABLE_OS_NAME, "$PRINTABLE_OS_NAME", [A human readable text with the name of the OS]) # # Checking for iconv # AM_ICONV # # Check for gettext # # This is "GNU gnupg" - The project-id script from gettext # needs this string # AC_MSG_NOTICE([checking for gettext]) AM_PO_SUBDIRS AM_GNU_GETTEXT_VERSION([0.17]) if test "$try_gettext" = yes; then AM_GNU_GETTEXT([external],[need-ngettext]) # gettext requires some extra checks. These really should be part of # the basic AM_GNU_GETTEXT macro. TODO: move other gettext-specific # function checks to here. AC_CHECK_FUNCS(strchr) else USE_NLS=no USE_INCLUDED_LIBINTL=no BUILD_INCLUDED_LIBINTL=no POSUB=po AC_SUBST(USE_NLS) AC_SUBST(USE_INCLUDED_LIBINTL) AC_SUBST(BUILD_INCLUDED_LIBINTL) AC_SUBST(POSUB) fi # We use HAVE_LANGINFO_CODESET in a couple of places. AM_LANGINFO_CODESET # Checks required for our use locales gt_LC_MESSAGES # # SELinux support # if test "$selinux_support" = yes ; then AC_DEFINE(ENABLE_SELINUX_HACKS,1,[Define to enable SELinux support]) fi # # Checks for header files. # AC_MSG_NOTICE([checking for header files]) AC_HEADER_STDC AC_CHECK_HEADERS([string.h unistd.h langinfo.h termio.h locale.h getopt.h \ pty.h pwd.h inttypes.h signal.h]) AC_HEADER_TIME # # Checks for typedefs, structures, and compiler characteristics. # AC_MSG_NOTICE([checking for system characteristics]) AC_C_CONST AC_C_INLINE AC_C_VOLATILE AC_TYPE_SIZE_T AC_TYPE_MODE_T AC_TYPE_SIGNAL AC_DECL_SYS_SIGLIST gl_HEADER_SYS_SOCKET gl_TYPE_SOCKLEN_T AC_ARG_ENABLE(endian-check, AC_HELP_STRING([--disable-endian-check], [disable the endian check and trust the OS provided macros]), endiancheck=$enableval,endiancheck=yes) if test x"$endiancheck" = xyes ; then GNUPG_CHECK_ENDIAN fi # fixme: we should get rid of the byte type GNUPG_CHECK_TYPEDEF(byte, HAVE_BYTE_TYPEDEF) GNUPG_CHECK_TYPEDEF(ushort, HAVE_USHORT_TYPEDEF) GNUPG_CHECK_TYPEDEF(ulong, HAVE_ULONG_TYPEDEF) GNUPG_CHECK_TYPEDEF(u16, HAVE_U16_TYPEDEF) GNUPG_CHECK_TYPEDEF(u32, HAVE_U32_TYPEDEF) AC_CHECK_SIZEOF(unsigned short) AC_CHECK_SIZEOF(unsigned int) AC_CHECK_SIZEOF(unsigned long) AC_CHECK_SIZEOF(unsigned long long) AC_CHECK_SIZEOF(time_t,,[[ #include #if TIME_WITH_SYS_TIME # include # include #else # if HAVE_SYS_TIME_H # include # else # include # endif #endif ]]) # Ensure that we have UINT64_C before we bother to check for uint64_t # Fixme: really needed in gnupg? I think it is only useful in libcgrypt. AC_CACHE_CHECK([for UINT64_C],[gnupg_cv_uint64_c_works], AC_COMPILE_IFELSE(AC_LANG_PROGRAM([#include uint64_t foo=UINT64_C(42);]), gnupg_cv_uint64_c_works=yes,gnupg_cv_uint64_c_works=no)) if test "$gnupg_cv_uint64_c_works" = "yes" ; then AC_CHECK_SIZEOF(uint64_t) fi if test "$ac_cv_sizeof_unsigned_short" = "0" \ || test "$ac_cv_sizeof_unsigned_int" = "0" \ || test "$ac_cv_sizeof_unsigned_long" = "0"; then AC_MSG_WARN([Hmmm, something is wrong with the sizes - using defaults]); fi # # Checks for library functions. # AC_MSG_NOTICE([checking for library functions]) AC_CHECK_DECLS(getpagesize) AC_FUNC_FSEEKO AC_FUNC_VPRINTF AC_FUNC_FORK AC_CHECK_FUNCS([strerror strlwr tcgetattr mmap]) AC_CHECK_FUNCS([strcasecmp strncasecmp ctermid times gmtime_r]) AC_CHECK_FUNCS([unsetenv fcntl ftruncate]) AC_CHECK_FUNCS([gettimeofday getrusage getrlimit setrlimit clock_gettime]) AC_CHECK_FUNCS([atexit raise getpagesize strftime nl_langinfo setlocale]) AC_CHECK_FUNCS([waitpid wait4 sigaction sigprocmask pipe stat getaddrinfo]) AC_CHECK_FUNCS([ttyname rand ftello fsync]) AC_CHECK_TYPES([struct sigaction, sigset_t],,,[#include ]) # -# These are needed by libjnlib - fixme: we should use a jnlib.m4 +# These are needed by the jnlib parts in common. # Note: We already checked pwd.h. AC_CHECK_HEADERS([signal.h]) AC_CHECK_FUNCS([memicmp stpcpy strsep strlwr strtoul memmove stricmp strtol \ memrchr isascii timegm getrusage setrlimit stat setlocale \ flockfile funlockfile fopencookie funopen getpwnam getpwuid \ getenv ]) # # gnulib checks # gl_SOURCE_BASE([gl]) gl_M4_BASE([gl/m4]) gl_MODULES([setenv mkdtemp xsize strpbrk]) gl_INIT # # W32 specific test # GNUPG_FUNC_MKDIR_TAKES_ONE_ARG # # Sanity check regex. Tests adapted from mutt. # AC_MSG_CHECKING([whether regular expression support is requested]) AC_ARG_ENABLE(regex, AC_HELP_STRING([--disable-regex], [do not handle regular expressions in trust signatures]), use_regex=$enableval, use_regex=yes) AC_MSG_RESULT($use_regex) if test "$use_regex" = yes ; then _cppflags="${CPPFLAGS}" _ldflags="${LDFLAGS}" AC_ARG_WITH(regex, AC_HELP_STRING([--with-regex=DIR],[look for regex in DIR]), [ if test -d "$withval" ; then CPPFLAGS="${CPPFLAGS} -I$withval/include" LDFLAGS="${LDFLAGS} -L$withval/lib" fi ],withval="") # Does the system have regex functions at all? AC_SEARCH_LIBS([regcomp], [regex]) AC_CHECK_FUNC(regcomp, gnupg_cv_have_regex=yes, gnupg_cv_have_regex=no) if test $gnupg_cv_have_regex = no; then use_regex=no else if test x"$cross_compiling" = xyes; then AC_MSG_WARN([cross compiling; assuming regexp libray is not broken]) else AC_CACHE_CHECK([whether your system's regexp library is broken], [gnupg_cv_regex_broken], AC_TRY_RUN([ #include #include main() { regex_t blah ; regmatch_t p; p.rm_eo = p.rm_eo; return regcomp(&blah, "foo.*bar", REG_NOSUB) || regexec (&blah, "foobar", 0, NULL, 0); }], gnupg_cv_regex_broken=no, gnupg_cv_regex_broken=yes, gnupg_cv_regex_broken=yes)) if test $gnupg_cv_regex_broken = yes; then AC_MSG_WARN([your regex is broken - disabling regex use]) use_regex=no fi fi fi CPPFLAGS="${_cppflags}" LDFLAGS="${_ldflags}" fi if test "$use_regex" != yes ; then AC_DEFINE(DISABLE_REGEX,1, [Define to disable regular expression support]) fi AM_CONDITIONAL(DISABLE_REGEX, test x"$use_regex" != xyes) # # Do we have zlib? Must do it here because Solaris failed # when compiling a conftest (due to the "-lz" from LIBS). # Note that we combine zlib and bzlib2 in ZLIBS. # _cppflags="${CPPFLAGS}" _ldflags="${LDFLAGS}" AC_ARG_WITH(zlib, [ --with-zlib=DIR use libz in DIR],[ if test -d "$withval"; then CPPFLAGS="${CPPFLAGS} -I$withval/include" LDFLAGS="${LDFLAGS} -L$withval/lib" fi ]) AC_CHECK_HEADER(zlib.h, AC_CHECK_LIB(z, deflateInit2_, ZLIBS="-lz", CPPFLAGS=${_cppflags} LDFLAGS=${_ldflags}), CPPFLAGS=${_cppflags} LDFLAGS=${_ldflags}) # # Check whether we can support bzip2 # if test "$use_bzip2" = yes ; then _cppflags="${CPPFLAGS}" _ldflags="${LDFLAGS}" AC_ARG_WITH(bzip2, AC_HELP_STRING([--with-bzip2=DIR],[look for bzip2 in DIR]), [ if test -d "$withval" ; then CPPFLAGS="${CPPFLAGS} -I$withval/include" LDFLAGS="${LDFLAGS} -L$withval/lib" fi ],withval="") # Checking alongside stdio.h as an early version of bzip2 (1.0) # required stdio.h to be included before bzlib.h, and Solaris 9 is # woefully out of date. if test "$withval" != no ; then AC_CHECK_HEADER(bzlib.h, AC_CHECK_LIB(bz2,BZ2_bzCompressInit, [ have_bz2=yes ZLIBS="$ZLIBS -lbz2" AC_DEFINE(HAVE_BZIP2,1, [Defined if the bz2 compression library is available]) ], CPPFLAGS=${_cppflags} LDFLAGS=${_ldflags}), CPPFLAGS=${_cppflags} LDFLAGS=${_ldflags},[#include ]) fi fi AM_CONDITIONAL(ENABLE_BZIP2_SUPPORT,test x"$have_bz2" = "xyes") AC_SUBST(ZLIBS) # Check for readline support GNUPG_CHECK_READLINE # # Allow users to append something to the version string without # flagging it as development version. The user version parts is # considered everything after a dash. # if test "$development_version" != yes; then changequote(,)dnl tmp_pat='[a-zA-Z]' changequote([,])dnl if echo "$VERSION" | sed 's/-.*//' | grep "$tmp_pat" >/dev/null ; then development_version=yes fi fi if test "$development_version" = yes; then AC_DEFINE(IS_DEVELOPMENT_VERSION,1, [Defined if this is not a regular release]) fi AM_CONDITIONAL(CROSS_COMPILING, test x$cross_compiling = xyes) GNUPG_CHECK_GNUMAKE # Add some extra libs here so that previous tests don't fail for # mysterious reasons - the final link step should bail out. # W32SOCKLIBS is also defined so that if can be used for tools not # requiring any network stuff but linking to code in libcommon which # tracks in winsock stuff (e.g. init_common_subsystems. if test "$have_w32_system" = yes; then W32SOCKLIBS="-lws2_32" NETLIBS="${NETLIBS} ${W32SOCKLIBS}" fi AC_SUBST(NETLIBS) AC_SUBST(W32SOCKLIBS) # # Setup gcc specific options # AC_MSG_NOTICE([checking for cc features]) if test "$GCC" = yes; then # Note that it is okay to use CFLAGS here because this are just # warning options and the user should have a chance of overriding # them. if test "$USE_MAINTAINER_MODE" = "yes"; then CFLAGS="$CFLAGS -O3 -Wall -Wcast-align -Wshadow -Wstrict-prototypes" CFLAGS="$CFLAGS -Wformat -Wno-format-y2k -Wformat-security" AC_MSG_CHECKING([if gcc supports -Wno-missing-field-initializers]) _gcc_cflags_save=$CFLAGS CFLAGS="-Wno-missing-field-initializers" AC_COMPILE_IFELSE(AC_LANG_PROGRAM([]),_gcc_wopt=yes,_gcc_wopt=no) AC_MSG_RESULT($_gcc_wopt) CFLAGS=$_gcc_cflags_save; if test x"$_gcc_wopt" = xyes ; then CFLAGS="$CFLAGS -W -Wno-sign-compare -Wno-missing-field-initializers" fi AC_MSG_CHECKING([if gcc supports -Wdeclaration-after-statement]) _gcc_cflags_save=$CFLAGS CFLAGS="-Wdeclaration-after-statement" AC_COMPILE_IFELSE(AC_LANG_PROGRAM([]),_gcc_wopt=yes,_gcc_wopt=no) AC_MSG_RESULT($_gcc_wopt) CFLAGS=$_gcc_cflags_save; if test x"$_gcc_wopt" = xyes ; then CFLAGS="$CFLAGS -Wdeclaration-after-statement" fi else CFLAGS="$CFLAGS -Wall" fi AC_MSG_CHECKING([if gcc supports -Wno-pointer-sign]) _gcc_cflags_save=$CFLAGS CFLAGS="-Wno-pointer-sign" AC_COMPILE_IFELSE(AC_LANG_PROGRAM([]),_gcc_psign=yes,_gcc_psign=no) AC_MSG_RESULT($_gcc_psign) CFLAGS=$_gcc_cflags_save; if test x"$_gcc_psign" = xyes ; then CFLAGS="$CFLAGS -Wno-pointer-sign" fi AC_MSG_CHECKING([if gcc supports -Wpointer-arith]) _gcc_cflags_save=$CFLAGS CFLAGS="-Wpointer-arith" AC_COMPILE_IFELSE(AC_LANG_PROGRAM([]),_gcc_psign=yes,_gcc_psign=no) AC_MSG_RESULT($_gcc_psign) CFLAGS=$_gcc_cflags_save; if test x"$_gcc_psign" = xyes ; then CFLAGS="$CFLAGS -Wpointer-arith" fi fi # # This is handy for debugging so the compiler doesn't rearrange # things and eliminate variables. # AC_ARG_ENABLE(optimization, AC_HELP_STRING([--disable-optimization], [disable compiler optimization]), [if test $enableval = no ; then CFLAGS=`echo $CFLAGS | sed 's/-O[[0-9]]//'` fi]) # # Prepare building of estream # estream_INIT # # Decide what to build # if test "$have_adns" = "yes"; then AC_SUBST(GPGKEYS_KDNS, "gpg2keys_kdns$EXEEXT") fi missing_pth=no if test $have_ksba = no; then build_gpgsm=no build_scdaemon=no fi build_agent_threaded="" if test "$build_agent" = "yes"; then if test $have_pth = no; then build_agent_threaded="(not multi-threaded)" missing_pth=yes fi fi build_scdaemon_extra="" if test "$build_scdaemon" = "yes"; then tmp="" if test $have_pth = no; then build_scdaemon_extra="not multi-threaded" tmp=", " missing_pth=yes fi if test $have_libusb = no; then build_scdaemon_extra="${tmp}without internal CCID driver" tmp=", " fi if test -n "$build_scdaemon_extra"; then build_scdaemon_extra="(${build_scdaemon_extra})" fi fi if test "$build_agent_only" = "yes" ; then build_gpg=no build_gpgsm=no build_scdaemon=no build_tools=no build_doc=no fi AM_CONDITIONAL(BUILD_GPG, test "$build_gpg" = "yes") AM_CONDITIONAL(BUILD_GPGSM, test "$build_gpgsm" = "yes") AM_CONDITIONAL(BUILD_AGENT, test "$build_agent" = "yes") AM_CONDITIONAL(BUILD_SCDAEMON, test "$build_scdaemon" = "yes") AM_CONDITIONAL(BUILD_G13, test "$build_g13" = "yes") AM_CONDITIONAL(BUILD_TOOLS, test "$build_tools" = "yes") AM_CONDITIONAL(BUILD_DOC, test "$build_doc" = "yes") AM_CONDITIONAL(BUILD_SYMCRYPTRUN, test "$build_symcryptrun" = "yes") AM_CONDITIONAL(RUN_GPG_TESTS, test x$cross_compiling = xno -a "$build_gpg" = yes ) # # Print errors here so that they are visible all # together and the user can acquire them all together. # die=no if test "$have_gpg_error" = "no"; then die=yes AC_MSG_NOTICE([[ *** *** You need libgpg-error to build this program. ** This library is for example available at *** ftp://ftp.gnupg.org/gcrypt/libgpg-error *** (at least version $NEED_GPG_ERROR_VERSION is required.) ***]]) fi if test "$have_libgcrypt" = "no"; then die=yes AC_MSG_NOTICE([[ *** *** You need libgcrypt to build this program. ** This library is for example available at *** ftp://ftp.gnupg.org/gcrypt/libgcrypt/ *** (at least version $NEED_LIBGCRYPT_VERSION using API $NEED_LIBGCRYPT_API is required.) ***]]) fi if test "$have_libassuan" = "no"; then die=yes AC_MSG_NOTICE([[ *** *** You need libassuan to build this program. *** This library is for example available at *** ftp://ftp.gnupg.org/gcrypt/libassuan/ *** (at least version $NEED_LIBASSUAN_VERSION (API $NEED_LIBASSUAN_API) is required). ***]]) fi if test "$have_ksba" = "no"; then AC_MSG_NOTICE([[ *** *** You need libksba to build this program. *** This library is for example available at *** ftp://ftp.gnupg.org/gcrypt/libksba/ *** (at least version $NEED_KSBA_VERSION using API $NEED_KSBA_API is required). ***]]) fi if test "$missing_pth" = "yes"; then AC_MSG_NOTICE([[ *** *** It is now required to build with support for the *** GNU Portable Threads Library (Pth). Please install this *** library first. The library is for example available at *** ftp://ftp.gnu.org/gnu/pth/ *** On a Debian GNU/Linux system you can install it using *** apt-get install libpth-dev *** To build GnuPG for Windows you need to use the W32PTH *** package; available at: *** ftp://ftp.g10code.com/g10code/w32pth/ ***]]) die=yes fi if test "$die" = "yes"; then AC_MSG_ERROR([[ *** *** Required libraries not found. Please consult the above messages *** and install them before running configure again. ***]]) fi AC_CONFIG_FILES([ m4/Makefile Makefile po/Makefile.in gl/Makefile include/Makefile -jnlib/Makefile common/Makefile kbx/Makefile g10/Makefile sm/Makefile agent/Makefile scd/Makefile g13/Makefile keyserver/Makefile keyserver/gpg2keys_mailto keyserver/gpg2keys_test tools/gpg-zip tools/Makefile doc/Makefile tests/Makefile tests/openpgp/Makefile tests/pkits/Makefile ]) AC_OUTPUT echo " GnuPG v${VERSION} has been configured as follows: Platform: $PRINTABLE_OS_NAME ($host) OpenPGP: $build_gpg S/MIME: $build_gpgsm Agent: $build_agent $build_agent_threaded Smartcard: $build_scdaemon $build_scdaemon_extra G13: $build_g13 Protect tool: $show_gnupg_protect_tool_pgm Default agent: $show_gnupg_agent_pgm Default pinentry: $show_gnupg_pinentry_pgm Default scdaemon: $show_gnupg_scdaemon_pgm Default dirmngr: $show_gnupg_dirmngr_pgm " if test x"$use_regex" != xyes ; then echo " Warning: No regular expression support available. OpenPGP trust signatures won't work. gpg-check-pattern will not be build. " fi diff --git a/g10/ChangeLog b/g10/ChangeLog index 121d57356..b77ed8d9c 100644 --- a/g10/ChangeLog +++ b/g10/ChangeLog @@ -1,11087 +1,11093 @@ +2010-03-10 Werner Koch + + * Makefile.am (needed_libs): Remove libjnlib.a. + + * main.h: Remove "estream.h". + 2010-03-08 Werner Koch * main.h: Include "estream.h" * openfile.c (open_outfile): Replace dup/iobuf_fdopen by iobuf_fdopen_nc. * mainproc.c (proc_signature_packets_by_fd): Return error on memory failure. * plaintext.c (hash_datafile_by_fd): Ditto. * verify.c (gpg_verify): Use iobuf_fdopen_nc. Change OUT_FP to an estream_t. * server.c (cmd_verify): Do not dup the fds. Use macros for iobuf_ioctl commands. 2010-02-17 Werner Koch * keygen.c (ask_user_id): Avoid infinite loop in case of invalid data. Fixes bug#1186. 2010-02-02 Werner Koch * keyedit.c (keyedit_menu): Change prompt to "gpg". * card-util.c (card_edit): Change prompt to "gpg/card". 2010-01-11 Werner Koch * sign.c (only_old_style, write_onepass_sig_packets, hash_for) (write_signature_packets, print_status_sig_created) (clearsign_file, make_keysig_packet, mk_notation_policy_etc) (complete_sig, do_sign, update_keysig_packet): Replace all secret key access by the matching public key. * keylist.c (print_seckey_info): Ditto. * revoke.c (gen_desig_revoke): Ditto. * skclist.c (release_sk_list): Ditto. * keyedit.c (sign_uids): Ditto. * misc.c (get_signature_count): Ditto. * main.h (struct expand_args): s/sk/pksk/. Change all users. * keyedit.c (keyedit_passwd): Finish implementation. 2010-01-10 Werner Koch * skclist.c (GCRYCTL_FAKED_RANDOM_P): Remove because we require libgcrypt 1.4. (is_insecure, key_present_in_sk_list): Work with public keys. (build_sk_list): Change to work on public keys. * keydb.h (struct sk_list): Replace field SK by a PK field. * keylist.c (list_keyblock_print): Always look for the public key and ignore all secret key packets. (list_keyblock_colon): Ditto. (print_capabilities): Remove arg SK and all secret key stuff. Adjust all callers. (dump_attribs): Ditto. * getkey.c (getkey_bynames, getkey_next, get_pubkey_end): New. (getkey_byname): New. (getkey_ctx_s): Add WANT_SECRET. (key_byname): Set it. (merge_keys_and_selfsig): Remove all the secret key merging. (lookup): Simplify by removing secret key code. * keylist.c (list_all): Scan public keys and use have_secret_key to filter secret keys. (list_one): Use the new get_key functions. * gpg.h (kbnode_t): Add as alias for KBNODE. * keydb.h (getkey_ctx_t): Add as alias for GETKEY_CTX. 2010-01-09 Werner Koch * getkey.c, keylist.c: Re-indent. 2010-01-08 Werner Koch * cpr.c (write_status_error): Rename to write_status_errcode. Change all callers. (write_status_error): New. * gpg.c: Add option --passwd. (aPasswd): New. (main): Implement. * keyedit.c (keyedit_passwd): New. * gpg.c (oPasswd, oPasswdFD, oPasswdFile, oPasswdRepeat): Change to oPassphrase, oPassphraseFD, oPassphraseFile, oPassphraseRepeat. * options.h (struct): s/passwd_repeat/passphrase_repeat/. * gpg.c (main): Ditto. * passphrase.c (passphrase_to_dek_ext): Ditto. 2009-12-21 Werner Koch * call-agent.c (agent_get_s2k_count): New. * gpg.c (main): Set s2k_count to 0. * (encode_s2k_iterations): Move ... * passphrase.c (encode_s2k_iterations): ... here. Call agent_get_s2k_count if called with a 0 arg. (passphrase_to_dek_ext): Set S2K_COUNT via encode_s2k_iterations. 2009-12-17 Werner Koch * sig-check.c (do_check_messages): Evaluate the HAS_EXPIRED flag. Fixes bug#1059. * gpg.c: Add new option --faked-system-time. 2009-12-15 Werner Koch * keydb.c (keydb_add_resource): s/readonly/read_only/g. * keyring.c (keyring_register_filename): Ditto. * tdbio.c (tdbio_set_dbname): Do not call log_fatal after creating the directory. Fixes bug#1169. Reported by Daniel Leidert. 2009-12-08 Werner Koch * keyring.h: Include userids.h. * gpg.h (KEYDB_SEARCH_DESC): Remove. * packet.h: Include userids.h. (PKT_user_id): Declare using gpg_pkt_user_id_s. * keydb.h (KeydbSearchMode, struct keydb_search_desc): Remove. We now use those in ../kbx. * getkey.c (classify_user_id): Remove. It is now in common/. (key_byname): Adjust for changed classify_user_id. * delkey.c (do_delete_key): Ditto. * trustdb.c (register_trusted_key): Ditto. * revoke.c (gen_desig_revoke, gen_revoke): Ditto. * keyserver.c (parse_keyrec, keyserver_export, keyserver_import) (keyidlist): Ditto. * export.c (do_export_stream): Ditto. * pkclist.c (find_and_check_key): Replace GPG_ERR_INV_NAME by GPG_ERR_INV_USER_ID. 2009-12-04 Werner Koch * keygen.c (DEFAULT_STD_ALGO, DEFAULT_STD_KEYSIZE): New. (ask_keysize): Use new macro. (gen_rsa): Set default size if NBITS is 0. (get_parameter_algo): Add algo name "default". Add arg R_DEFAULT. (proc_parameter_file): Process default flag. 2009-12-03 Werner Koch * gpg.c (set_debug): Allow for numerical debug leveles. Print active debug flags. 2009-11-27 Werner Koch * keyedit.c (cmds, keyedit_menu): New command "checkbkupkey". 2009-11-25 Marcus Brinkmann * server.c (gpg_server): Use assuan_fd_t and assuan_fdopen on fds. 2009-11-23 Werner Koch * gpg.c (gpgconf_list): Add key "default_pubkey_algo". 2009-11-18 Werner Koch * gpg.c: Add option --skip-hidden-recipients and no- variant. * options.h (struct opt): Add field SKIP_HIDDEN_RECIPIENTS. * pubkey-enc.c (get_session_key): Implement that option. 2009-11-04 Werner Koch * server.c (register_commands): Add NULL arg to assuan_register_command. 2009-11-02 Marcus Brinkmann * server.c (reset_notify, input_notify, output_notify): Update to new assuan interface. (register_commands): Use assuan_handler_t. 2009-10-19 Werner Koch * options.h (glo_ctrl): Add field LASTERR. * mainproc.c (proc_encrypted): Set LASTERR. * server.c (cmd_decrypt): Check LASTERR. 2009-10-02 Werner Koch * server.c (cmd_encrypt, cmd_decrypt): Implement. * decrypt.c (decrypt_message_fd): New. * options.h (struct opt): Add field OUTFP. * plaintext.c (handle_plaintext): Support opt.outfp. * encr-data.c: Rename to decrypt-data.c to reflect the action and not the processed packet type. 2009-10-02 Werner Koch * encr-data.c (decode_filter_context_s): Add fields PARTIAL and LENGTH. (decrypt_data): Set them. Simplify premature EOF detection. (mdc_decode_filter): Take fixed length packets in account. (decode_filter): Ditto. Better EOF detection. * parse-packet.c (parse_encrypted): Store ed->LEN without the MDC version byte. 2009-09-30 Werner Koch * parse-packet.c (skip_packet, parse_gpg_control) : Take care of premature EOFs. * gpg.c (main): Remove obsolete GCRYCTL_DISABLE_INTERNAL_LOCKING. 2009-09-29 Werner Koch * openfile.c (open_outfile): Re-indent. Use xstrconcat. (NAME_OF_DEV_NULL): New. (open_outfile): Use it. (overwrite_filep): Use it. Also use case insensitive compare when needed. Re-indent. (open_outfile): Add arg INP_FD. Change all callers. * encrypt.c (encrypt_crypt): Add new args FILEFD, OUTPUTFD and PROVIDED_KEYS. Change all callers. 2009-09-28 Werner Koch * server.c (skip_options, has_option): New. (cmd_recipient): Implement. * keydb.h (pk_list_t): New. * pkclist.c (send_status_inv_recp): New. Replace direct calls. (build_pk_list): Factor some code out to ... (find_and_check_key): ... new. * encode.c: Rename to encrypt.c. Re-indent all. * encrypt.c (encode_symmetric, encode_store, encode_seskey) (encode_simple, encode_crypt, encode_filter) (encode_crypt_files): Rename all to encrypt_*. Change all callers. * trustdb.c (get_validity_info): Take care of a NULL PK. Fixes bug#1138. (get_validity_string): Ditto. 2009-09-25 Werner Koch * pkglue.c (pk_sign, pk_verify, pk_encrypt, pk_decrypt) (pk_check_secret_key): Allow deprecated RSA identifiers 2 and 3. Fixes bug#1139. 2009-09-23 Marcus Brinkmann * call-agent.c: Include "scdaemon.h" before because of GPG_ERR_SOURCE_DEFAULT check. (learn_status_cb, dummy_data_cb, get_serialno_cb, default_inq_cb) (learn_status_cb, inq_writecert_parms, inq_writekey_parms) (scd_genkey_cb, membuf_data_cb): Return gpg_error_t instead of int. * gpg.c: Include "scdaemon.h" before because of GPG_ERR_SOURCE_DEFAULT check. (main): Update to new Assuan API. * server.c: Include "scdaemon.h" before because of GPG_ERR_SOURCE_DEFAULT check. (option_handler, cmd_recipient, cmd_signer, cmd_encrypt) (cmd_decrypt, cmd_verify, cmd_sign, cmd_import, cmd_export) (cmd_delkeys, cmd_message, do_listkeys, cmd_listkeys) (cmd_listsecretkeys, cmd_genkey, cmd_getinfo): Return gpg_error_t instead of int. (register_commands): Allocate assuan context before starting server. (gpg_server): Allocate assuan_context before starting server. 2009-09-04 Werner Koch * keyedit.c (menu_select_uid): Use IDX ==-1 t select all. (menu_select_key): Ditto. (keyedit_menu) : Allow '*' to select all. 2009-09-03 Werner Koch * keyedit.c (menu_adduid): Pass keyblock to generate_user_id. * keygen.c (generate_user_id): Add arg KEYBLOCK. Factor code out to ... (uid_from_string): ... new. (ask_user_id): Add arg KEYBLOCK and check for duplicates. Fix bug#1122. * Makefile.am (uninstall-local): New. * compress-bz2.c (do_uncompress): Detect unexpected EOF. Fix bug#1011. 2009-08-26 Werner Koch * keyedit.c (menu_revsig): Check for signature right away. Fix Debian-bug#543530. 2009-08-20 Daiki Ueno * mainproc.c (proc_encrypted): Clear passphrase cached with S2K cache ID if decryption failed. * passphrase.c (passphrase_to_dek_ext): Set dek->s2k_cacheid. * gpgv.c (passphrase_clear_cache): New stub. 2009-08-11 Werner Koch * call-agent.c (get_serialno_cb): New. From ../agent/call-scd.c. (gpg_agent_get_confirmation): New. (select_openpgp): New. (agent_scd_pkdecrypt, agent_scd_pksign): Use it here. 2009-08-06 Werner Koch * skclist.c (build_sk_list): Print INV_SGNR status line. * seckey-cert.c (do_check): Return G10ERR_UNU_SECKEY instead of general error. 2009-08-05 Werner Koch * card-util.c: Enable readline support also in GnuPG-2. * call-agent.c (agent_learn): Always select the card first. * gpg.c: Add --key-edit alias. * call-agent.c (scd_genkey_cb): Forward progress status lines. * card-util.c (generate_card_keys): Remove special case for GnuPG-2. Ask for the keysize and change it. (card_generate_subkey): Ask for the keysize and change it. (get_info_for_key_operation): Read KEY-ATTR. (show_keysize_warning, ask_card_keysize): New. (do_change_keysize): New. 2009-07-31 David Shaw * gpg.c (main): --pgp6 includes --disable-mdc. 2009-07-23 David Shaw * keyserver.c (keyserver_import_ldap): Try a DNS-SD lookup to find a domain-specific LDAP server before resorting to keys.{domain}. 2009-07-22 Werner Koch * card-util.c (generate_card_keys): Ask for off-card keys only if the card supports it. (get_info_for_key_operation): Read EXTCAP. (card_store_subkey): Check for non matching sizes. * call-agent.h (struct agent_card_info_s): Add field EXTCAP. * call-agent.c (agent_learn): Use a direct SCD command. (did_early_card_test): New. (start_agent): Perform an early test for the card. Add arg FOR_CARD. (status_sc_op_failure): New. (agent_scd_setattr, agent_scd_writekey, agent_scd_genkey) (agent_scd_pksign, agent_scd_pkdecrypt, agent_scd_change_pin) (agent_scd_checkpin): Call new function. (learn_status_cb): Parse KEY_TIME and EXTCAP. * gpg.c (main) : Show commands to run. * trustdb.c (how_to_fix_the_trustdb): New. * tdbio.c (tdbio_invalid): Show commands to re-create the trustdb. Fixes bug#929. 2009-07-20 Werner Koch * keygen.c (generate_keypair): Allow Elgamal > 3072 in BOTH mode. Reported by Jeroen Schot. Fixes bug#1091. 2009-07-17 Werner Koch * keyring.c (keyring_rebuild_cache): Replace the assert by a proper error message and allow to delete a bad keyblock. 2009-07-13 Werner Koch * exec.c: Fix function name indentation. (expand_args): Simplify by using membuf functions. (exec_write): Fix memory leak on error. (w32_system): Use DETACHED_PROCESS so that a new console is not created. 2009-07-09 Werner Koch * card-util.c (card_store_subkey): Do not restrict to 1024 bit keys. Print an error message on write errors. * gpg.c (main): Remove the SHA-1 default from the personal digest list. This was used in the past as a hack to avoid preferring RMD-160. * keygen.c (keygen_set_std_prefs): Remove RMD-160 from the list. Change order to SHA-256, SHA-1, SHA-384, SHA-512, SHA-224. (gen_dsa): Use a 256 bit Q for 2048 bit P. Round to FIPS allowed values in non-expert mode. 2009-07-07 Werner Koch * gpg.c (set_opt_session_env): New. (main): Allocate opt.session_env. Use it for oDisplay, oTTYname, oTTYtype and oXauthority. * options.h: Include session_env.h. (opt): Add field SESSION_ENV, remove obsolete fields. * call-agent.c (start_agent): Adjust start_new_gpg_agent for changed args. 2009-06-24 Werner Koch * keyedit.c (menu_select_key): Remove dead assign to I. (menu_select_uid): Ditto. * keyring.c (keyring_search): Remove dead assign to NAME. * card-util.c (card_edit): Remove useless DID_CHECKPIN. * call-agent.c (unhexify_fpr): Remove dead op on N. * passphrase.c (passphrase_to_dek_ext): Do not deref a NULL PW. * revoke.c (gen_revoke): Remove unused malloc of PK. * parse-packet.c (mpi_read): Init NREAD. Reported by Fabian Keil. 2009-06-17 Werner Koch * parse-packet.c (parse): Use a casted -1 instead of a 32 bit constant to check for a garbled package. Fixes bug#1040. * card-util.c (put_data_to_file, read_cert): New. (card_edit): Add command "readcert". (fetch_url): Allow code also for this gnupg major version 2. * call-agent.c (agent_scd_readcert): New. 2009-06-15 Werner Koch * keyserver.c (keyserver_search_prompt): No prompt in batch+colons mode. 2009-06-09 Werner Koch * card-util.c (write_sc_op_status): New. (change_pin): Use it. (change_url, change_login, change_private_do, change_cert) (change_lang, change_sex, change_cafpr, toggle_forcesig) (check_pin_for_key_operation): Ditto. 2009-06-05 David Shaw * gpg.c (main), misc.c (openpgp_cipher_test_algo): Remove Camellia restriction. * misc.c (map_cipher_openpgp_to_gcry), main.h: Add macros for openpgp_cipher_open, openpgp_cipher_get_algo_keylen, and openpgp_cipher_get_algo_blklen to wrap around the corresponding gcry_* functions, but pass the algorithm number through map_cipher_openpgp_to_gcry. This is needed in case the gcry algorithm number doesn't match the OpenPGP number (c.f. Camellia). * encr-data.c, pubkey-enc.c, mainproc.c, cipher.c, encode.c, seskey.c, passphrase.c, seckey-cert.c: Use new openpgp_cipher_* macros here. 2009-06-02 Werner Koch * card-util.c (get_manufacturer): Add new manufacturer. 2009-05-26 Werner Koch * parse-packet.c (mpi_read): Workaround for zero-length MPI bug in libgcrypt<1.5.0. 2009-05-22 Werner Koch * signal.c (got_fatal_signal): Call new function tty_cleanup_after_signal. 2009-05-20 Werner Koch * gpg.c (main): Fix --fingerprint/--with-fingerprint command detection. Fixes bug#1044. * keygen.c (ask_keysize): Allow selection of DSA key size even without --enable-dsa2. (gen_dsa): Remove size check. * keygen.c (ask_key_flags): Fix bug in the translation check. Fixes bug#1056. 2009-05-18 Daiki Ueno (wk) * encode.c (encode_simple): Tell passphrase_to_dek to cache the passphrase. (setup_symkey): Ditto. * mainproc.c (proc_symkey_enc): Tell passphrase_to_dek to cache the passphrase. (proc_encrypted): Ditto. * passphrase.c (hash_passphrase): Remove arg CREATE. (passphrase_to_dek): New mode 3 and 4 for caching passphrase for symmetric encryption. 2009-05-17 Werner Koch * keygen.c (ask_algo): Add arg R_SUBKEY_ALGO. Change return value semantics. Change presented order of algorithms. Make RSA+RSA the default. (generate_keypair): Adjust for change. (ask_keysize): Add arg PRIMARY_KEYSIZE for subkey creation. Change callers. 2009-05-15 Werner Koch * keygen.c (gen_card_key_with_backup): Get the size of the key from the card. * call-agent.h (struct agent_card_info_s): Add field KEY_ATTR. * call-agent.c (learn_status_cb): Support KEY-ATTR. * card-util.c (card_status): Print key attributes. 2009-05-15 Marcus Brinkmann * gpg.c (gpgconf_list): Remove dead entry "allow-pka-lookup" (a verify option for a couple of years now). 2009-05-14 Werner Koch * call-agent.c (agent_get_passphrase): Add arg CHECK. * passphrase.c (passphrase_get): Pass new arg. * keygen.c (gen_card_key_with_backup): Print a status error. (do_generate_keypair): Ditto. (do_ask_passphrase): Add arg MODE. (generate_raw_key): Call with mode 1. * passphrase.c (ask_passphrase): Remove becuase it is not used. (passphrase_to_dek): Factor code out to ... (passphrase_to_dek_ext): .. New. Add args CUSTDESC and CUSTPROMPT. 2009-05-13 Werner Koch * keygen.c (parse_expire_string): Base ISO date string at noon. Also allow full ISO timestamp. 2009-05-11 Werner Koch * parse-packet.c (parse_key): Print the key id in list mode. * skclist.c (build_sk_list): Use log_info for "duplicated entry". Fixes bug#1045. * encode.c (encode_simple): Print empty file warning only in verbose mode. Closes bug#1039. (encode_crypt): Ditto. * sign.c (write_plaintext_packet): Ditto. 2009-05-10 David Shaw * keyserver.c (keyserver_typemap): gpgkeys_hkp handles hkps as well. From 1.4. 2009-05-06 Werner Koch * getkey.c (finish_lookup): Remove dead code. * keyring.c (keyring_get_keyblock): Fix memory leak due to ring trust packets. Fixes bug#1034. 2009-04-03 Werner Koch * gpgv.c (main): Open keyrings readonly. * keydb.c (keydb_add_resource): Add readonly flag bit. (keydb_rebuild_caches): Don't act on readonly resources. * keyring.c (keyring_register_filename): Add arg READONLY. (struct keyring_name): Add field READONLY. (keyring_is_writable): Implement readonly feature. (keyring_update_keyblock): Return GPG_ERR_EACCES for readonly keyrings. (keyring_insert_keyblock, keyring_delete_keyblock): Ditto. 2009-04-01 Werner Koch * gpg.c (main): Properly handle UTF8 usernames with --sign-key and --lsign-key. From 1.4, David 2008-12-21. 2009-03-20 David Shaw (wk) * keyring.c (rename_tmp_file): Force a fsync (via iobuf_ioctl) on secret keyring files to be extra safe on filesystems that may not sync data and metadata together (ext4). Also check return code from the cache invalidation to make sure we're safe over NFS and similar. 2009-03-31 Werner Koch * passphrase.c (ask_passphrase): Use percent_plus_unescape. * misc.c (unescape_percent_string): Remove. * call-agent.c (unescape_status_string): Chnage to use percent_plus_unescape. 2009-03-25 Werner Koch * mainproc.c (print_pkenc_list): Use snprintf. 2009-03-17 Werner Koch * call-agent.c (my_percent_plus_escape): Remove. (agent_get_passphrase): Rewrite using percent_plus_escape. 2009-03-17 Daiki Ueno * passphrase.c (passphrase_get): Add extra arg REPEAT and adjust callers; remove special treatment for MODE==2. (passphrase_to_dek): Move --passphrase-repeat handling to gpg-agent. * call-agent.c (agent_get_passphrase): Add extra arg REPEAT. * call-agent.h: Ditto. 2009-03-16 Werner Koch * gpg.c (my_strusage): Revert last change. Systems w/o a gpg1 may, and actually do, install gpg2 as gpg. * gpgv.c (my_strusage): Ditto. 2009-03-14 David Shaw * gpg.c (my_strusage): gpg2 and gpgv2 (not gpg and gpgv). * gpgv.c (my_strusage): Same. * gpgv.c (my_strusage): Fix name of program in "Syntax" line. 2009-02-27 Werner Koch * call-agent.c (agent_scd_pksign, agent_scd_pkdecrypt): First send the SERIALNO command. 2009-02-24 Werner Koch * pkglue.c (pk_verify): Return an error for improper DATA instead of calling BUG(). 2009-02-09 Werner Koch * keylist.c (print_capabilities): Take care of cert-only keys. Fixes bug#998. * keyedit.c (show_key_with_all_names_colon): Print the capabilities. 2009-01-26 Werner Koch * card-util.c (card_status): Detect a Geldkarte. 2009-01-13 Werner Koch * call-agent.c (dummy_data_cb): New. (agent_learn): Use it. * card-util.c (card_status): Print type of non-OpenPGP card. * call-agent.h (agent_card_info_s): Add field APPTYPE. 2009-01-12 Werner Koch * getkey.c (finish_lookup): Take care of keys with a zero timestamp. Reported by Peter Gutmann. 2009-01-08 Werner Koch * misc.c (has_invalid_email_chars): Let non-ascii pass through. * cpr.c [USE_SHM_COPROCESSING]: Remove this code. 2008-12-12 Werner Koch * passphrase.c (passphrase_get): Write a STATUS_ERROR. * cpr.c (write_status_error): New. * Makefile.am (common_source): Add rmd160.h. 2008-12-11 Werner Koch * sig-check.c (signature_check2): Change algorithm used to compute the SIG_ID. (check_revocation_keys): Close message digest. * rmd160.c, rmd160.h: New. Based on code from GnuPG-1.4. * t-rmd160.c: New. * Makefile.am: Add support to run tests. * keyid.c (namehash_from_uid): Use rmd160_hash_buffer. 2008-12-10 Werner Koch * trustdb.h (NAMEHASH_HASH): Remove unsued constant. * gpg.c (print_mds): Print RMD160 only is enabled. * keygen.c (keygen_set_std_prefs): Include RMD160 only if available. 2008-12-09 Werner Koch * gpg.c (main) [IS_DEVELOPMENT_VERSION]: Fix strusage use. 2008-12-09 Werner Koch * keygen.c (proc_parameter_file): Check that key and subkey usages are allowed. 2008-12-09 David Shaw (wk) * trustdb.c (validate_one_keyblock): Fix the trust signature calculations so that we lower the trust depth of signatures to fit within the current chain, rather than discarding any signature that does not fit within the trust depth. 2008-12-09 Werner Koch * keyserver.c (show_prompt): Flush stdout. * gpg.c (open_info_file): Add arg BINARY and adjust callers. * gpg.c (main): Call i18n_init before init_common_subsystems. * gpgv.c (main): Ditto. * keylist.c (set_attrib_fd): Do not close ATTRIB_FP if it is the log stream. (set_attrib_fd) [W32]: Set to binary mode. (dump_attribs): Flush the stream after writing. 2008-12-05 Werner Koch * call-agent.c (percent_plus_escape): Rename to my_percent_plus_escape and also escape the percent character. Change all callers. 2008-11-18 Werner Koch * gpg.c (build_lib_list): Remove. (make_libversion): New. (my_strusage): Use it. * gpgv.c (make_libversion): New. (my_strusage): Print libgcrypt version. 2008-11-13 Werner Koch * gpgv.c: Use new ARGPARSE macros and re-indent. 2008-11-11 Werner Koch * gpg.c (opts): Use new ARGPARSE macros for clarity. 2008-10-24 Werner Koch * keyedit.c (change_passphrase): Clear passphrase cache. 2008-10-20 Werner Koch * gpgv.c: Mark all args of the stub fucntions as unused. * card-util.c (generate_card_keys): Remove unused arg SERIALNO and adjust caller. * build-packet.c (write_sign_packet_header): Mark unused arg. * gpg.c (gpg_init_default_ctrl, gpg_deinit_default_ctrl): Ditto. * getkey.c (skip_unusable): Ditto. (write_version): Ditto. * keydb.c (keydb_locate_writable): Ditto. * keyring.c (update_offset_hash_table): Ditto. (keyring_lock): Ditto. * misc.c (register_secured_file): Ditto. (unregister_secured_file): Ditto. (is_secured_file): Ditto. (is_secured_filename): Ditto. * parse-packet.c (parse_marker): Ditto. (parse_key, parse_attribute): Ditto. (parse_trust, parse_compressed, parse_mdc, parse_gpg_control): Ditto. * cpr.c (progress_cb): Ditto. * passphrase.c (passphrase_clear_cache): Ditto. (ask_passphrase): Ditto. * keyedit.c (keyedit_completion): Ditto. * import.c (import_revoke_cert): Ditto. (chk_self_sigs, delete_inv_parts, append_uid): Ditto. (merge_sigs, merge_keysigs, append_key): Ditto. * trustdb.c (list_trust_path): Ditto. (enum_cert_paths, enum_cert_paths_print): Ditto. * tdbdump.c (list_trustdb): Ditto. * keygen.c (keygen_upd_std_prefs): Ditto. (genhelp_factors): Ditto. * call-agent.c (agent_scd_setattr): Ditto. (agent_scd_writekey, agent_scd_change_pin, agent_scd_genkey): Ditto. (agent_clear_pin_cache): Ditto. * server.c (option_handler): Mark non yet used arg. (input_notify, output_notify): Ditto. (cmd_recipient, cmd_signer, cmd_encrypt, cmd_decrypt, cmd_verify) (cmd_sign, cmd_import, cmd_export, cmd_delkeys, do_listkeys) (cmd_genkey): Ditto. * verify.c (gpg_verify): Ditto. 2008-10-17 Werner Koch * main.h (idea_cipher_warn): Use do while construct in place of an empty definition. 2008-10-03 David Shaw * main.h, mainproc.c (check_sig_and_print) * keylist.c (list_keyblock_print) * pkclist.c (do_edit_ownertrust) * keyedit.c (menu_showphoto) * photoid.c (generate_photo_id, show_photos) * misc.c (pct_expando): Add %v and %V expandos so that displaying photo IDs can show the attribute validity tag (%v) and string (%V). Originally by Daniel Gillmor. 2008-09-29 Werner Koch * gpg.c (main): Remove -sat kludge. Note that we printed a warning for two years. * seskey.c (encode_md_value): Remove extra gcry_md_test_algo since it is not needed with Libgcrypt 1.4. * skclist.c (random_is_faked): Simplify. * sign.c (match_dsa_hash): Remove runtime check for SHA224. * gpg.c (print_mds): Use GCRY_MD_SHA224 constant. 2008-09-25 David Shaw * keyedit.c (keyedit_menu): Fix bug where a modified keyring loses its modified status after a "clean" or "minimize" that doesn't need to do anything. 2008-09-25 Werner Koch * parse-packet.c (parse): Remove special treatment for compressed new style packets. Fixes bug#931. * card-util.c (change_pin): Support setting of the reset code. 2008-09-24 Werner Koch * call-agent.h (struct agent_card_info_s): Add field IS_V2. * call-agent.c (learn_status_cb): That that field. * card-util.c (change_pin): Rename first arg to UNBLOCK_v2 and use it this way. (card_edit): Add new command UNBLOCK. 2008-09-23 David Shaw * pkclist.c (select_algo_from_prefs): Redo function to rank prefs and pick a consensus winner across all keys. 2008-09-16 Werner Koch * card-util.c (fpr_is_ff): New. (card_status): Do not print general key info for an all-ff fpr. (change_login, change_private_do): Factor common code out to ... (get_data_from_file): .. new. (change_cert): New. (card_edit): Add command "writecert". * call-agent.c (writecert_parm_s): New. (inq_writecert_parms, agent_scd_writecert): New. 2008-09-04 David Shaw * keyserver.c (keyserver_import_cert): Allow keyserver URLs in addition to full URLs in CERT records. 2008-08-11 Werner Koch * keygen.c (ask_expire_interval): Check for time overflow of an u32. Fixes bug #947. 2008-08-01 Werner Koch * tdbio.c (open_db) [!EROFS]: Move closing parens out of the ifdef. Reported by Ken Takusagawa. 2008-06-25 Marcus Brinkmann * gpg.c (enum cmd_and_opt_values): Remove option oEnableW32HandleTranslation. (opts): Remove option --enable-w32-handle-translation. (main): Remove variable w32_handle_translation. 2008-06-19 Werner Koch * gpg.c (gpgconf_list): Add "group". 2008-06-18 Marcus Brinkmann * gpg.c (enum cmd_and_opt_values): New option oEnableW32HandleTranslation. (opts): New option --enable-w32-handle-translation. (main): New variable w32_handle_translation to keep track of option. 2008-06-16 Werner Koch * keygen.c (output_control_s): Add ASK_PASSPHRASE. (read_parameter_file): Add commands %ask-passphrase and %no-ask-passphrase. 2008-06-11 Werner Koch * gpg.c: Make --fixed-list-mode a dummy. * options.h (struct): Removed FIXED_LIST_MODE. * keyid.c (colon_strtime, colon_datestr_from_pk) (colon_datestr_from_sk, colon_datestr_from_sig) (colon_expirestr_from_sig): Remove fixed_list_mode case. * keylist.c (list_keyblock_colon): Ditto. Remove all now unsed code and reindent. 2008-05-31 Werner Koch * keygen.c (ask_user_id): Change the string printed as header of the user ID generation. Use code to not break existing translations. Suggested by Eric Tetz. 2008-05-08 Werner Koch * sig-check.c (do_check_messages): Print a revocation diagnostic in verbose mode. 2008-05-07 Werner Koch * gpg.c: New command --locate-keys. New options --with-sig-list and --with-sig-check. * keylist.c (locate_one): New. (public_key_list): Add arg LOCATE_MODE and use locate_one. * getkey.c (get_pubkey_byname): Fix nodefault case. Add option RETCTX, change all callers. (struct getkey_ctx_s): Add field extra_ptr; (get_pubkey_end): Free it. 2008-04-18 Werner Koch * misc.c (map_cipher_openpgp_to_gcry, map_cipher_gcry_to_openpgp) (openpgp_cipher_test_algo): Add camellia-192. (openpgp_cipher_blocklen): New. * parse-packet.c (parse_key): Use new function here. 2008-04-15 David Shaw * getkey.c (merge_selfsigs_subkey): If there are multiple 0x19 backsigs, take the most recent one. 2008-04-08 Werner Koch * options.h (opt): Add AKL_NODEFAULT and AKL_LOCAL. * getkey.c (parse_auto_key_locate): Parse them. (get_pubkey_byname): Implement them. Add arg NO_AKL and use that in all cases where a local key is expected. * import.c (import_one): Fill in the fingerprint in all cases. Use log_get_stream. * keyserver.c (keyserver_import_pka): Set FPR to NULL on error. Return G10ERR_NO_PUBKEY if no PKA info is available or no key URI is given in the PKA record.. (keyserver_import_cert): Return G10ERR_NO_PUBKEY if a CERT record was not found. * getkey.c (get_pubkey_byname): Release FPR in the error case. Continue with next mechanism on error. Better diagnostics. 2008-04-07 Werner Koch * keyserver.c (parse_keyserver_uri): Allow a default host name. * getkey.c (get_pubkey_byname): Replace sprintf by bin2hex. 2008-04-02 Werner Koch * gpg.c (main): Do not allow DSA2 with a too old Libgcrypt. 2008-03-26 Werner Koch * tdbio.c (lookup_hashtable): Make cmp args const. (cmp_trec_fpr): Make FPR const. (tdbio_search_trust_byfpr): Remove cast. 2008-03-25 Werner Koch * keyserver.c (parse_keyrec): Take care of char defaulting to unsigned when using hextobyte. 2008-03-25 David Shaw (wk) * import.c (collapse_uids): Fix bug 894: possible memory corruption around deduplication of user IDs. 2008-03-25 Werner Koch * parse-packet.c (parse_key): Parse a secret key encrypted with Camellia. * options.skel: Make the default keyserver keys.gnupg.net. 2008-03-18 Werner Koch * seckey-cert.c (do_check): Use GCRYMPI_FMT_PGP for v3 keys. Reported by Petr Cerny. 2008-03-13 Werner Koch * passphrase.c (PROMPTSTRING): Change string to me more similar to the X.509 prompt. 2008-02-26 Werner Koch * getkey.c (get_pubkey_byname): Fix comment. 2008-02-14 Werner Koch * call-agent.c (default_inq_cb): New. (agent_learn, agent_scd_getattr, agent_scd_pksign) (agent_scd_pkdecrypt, agent_scd_change_pin, agent_scd_checkpin) (agent_get_passphrase, agent_clear_passphrase): Use new callback. (inq_writekey_parms): Fall back to the new callback for other inquiries. (start_agent): Tell agent that we accept pinentry notifications. 2008-02-11 Werner Koch * server.c (cmd_getinfo): New. (register_commands): Register GETINFO. 2008-02-09 Marcus Brinkmann * gpg.c (main): New variable default_configname. Use it if save_configname is NULL (can happen if default configfile does not exist). Move default configname determination to ... (get_default_configname): ... this new function. 2008-01-30 Werner Koch * keydb.c (maybe_create_keyring): Fixed last change. * tdbio.c (tdbio_set_dbname): Also test for forward slash. 2008-01-29 Werner Koch * keydb.c (maybe_create_keyring): Take care of a missing slash. (maybe_create_keyring) [W32]: Also test for forward slash. 2008-01-26 Werner Koch * card-util.c (get_manufacturer): Add vendor 0004. 2008-01-02 Werner Koch * gpg.c: Add --logger-file as an alias for log-file. 2007-12-14 Werner Koch * gpg.c (main): Set opt.no_homedir_creation during the first option parsing pass. 2007-12-12 Werner Koch * misc.c (print_pubkey_algo_note): Print a warning if a type 20 key is used. (openpgp_pk_test_algo, openpgp_pk_test_algo2) (openpgp_pk_algo_usage): Allow type 20 keys only in rfc2440 mode. 2007-12-12 David Shaw (wk) * trustdb.c (sanitize_regexp): New. Protect against dangerous regexps (malloc bombs) by force-commenting any characters aside from the ones we explicitly want. (check_regexp): Use it here before passing the regexp to regcomp(). 2007-12-12 Werner Koch * misc.c (map_cipher_openpgp_to_gcry): New. Used to map Camellia algorithms to Gcrypt. (openpgp_cipher_test_algo): Call new map function. Replace all remaining calls to gcry_cipher_test_algo by a call to this. (openpgp_cipher_algo_name): New. Replace all remaining calls to gcry_cipher_algo_name by a call to this. (map_cipher_gcry_to_openpgp): New. (string_to_cipher_algo): Use it. * gpg.c (main): Print a warning if Camellia support is build in. * gpg.c (print_algo_names): New. From the 1.4 branch by David. (list_config): Use it here for the "ciphername" and "digestname" config items so we can get a script-parseable list of the names. * parse-packet.c (parse_onepass_sig): Sigclass is hex, so include the 0x. * sign.c (match_dsa_hash): Remove conditional builds dending on USE_SHAxxx. We don't need this becuase it can be expected that libgcrypt provides it. However we need to runtime test for SHA244 becuase that is only available with libgcrypt 2.4. 2007-12-11 Werner Koch * mainproc.c (proc_pubkey_enc): Allow type 20 Elgamal key for decryption. 2007-12-10 Werner Koch * import.c (auto_create_card_key_stub): Do not clear the entire fingerprint. This finally makes the stub creation work. My past tests seemed to work because there was a key with a all zero fingerprint available (Elgamal signing keys). 2007-12-08 Werner Koch * misc.c (openpgp_pk_algo_usage): Allow Elgamal type 20 for encryption. 2007-12-04 Werner Koch * helptext.c (get_help_from_file): New. (display_online_help): Use it to geting the help through a file. (helptexts): Remove. 2007-12-03 Werner Koch * keygen.c (ask_key_flags): Add a translation remark and implement a workaround. * gpg.c (reopen_std): Moved to ../common and renamed to gnupg_reopen_std. * gpg.c: Remove second inclusion of fcntl.h. 2007-11-19 Werner Koch * keyedit.c (keyedit_menu): String grammar fix. 2007-11-15 Werner Koch * gpg.c (main): New option --xauthority. * call-agent.c (start_agent): Adjust changed start_new_gpg_agent. 2007-11-12 Werner Koch * cpr.c (do_get_from_fd): s/bool/getbool/ to overcome problems with Mac OS 10.5 which seems to include stdbool.h silently. 2007-11-07 Werner Koch Replace all includes of errors.h by status.h (found in common/). * status.h: Remove. * status.h: Move prototypes to main.h. * status.c: Rename to .. * cpr.c: .. this. (get_status_string): Remove. We take this now from common/. 2007-10-25 David Shaw (wk) From 1.4 (October): * gpg.c (main): Add --require-cross-certification to --openpgp/--rfc4880 mode. * gpg.c (main): Disable --rfc2440-text and --force-v3-sigs by default. Enable --require-cross-certification by default. --openpgp (--rfc4880) is the same as --rfc2440 except with "--enable-dsa2 --no-rfc2440-text --escape-from-lines". * misc.c (compliance_option_string, compliance_failure): Minor cleanup. * armor.c (is_armor_header): Comment about 4880. * options.h, gpg.c (main): Add --rfc4880, and make --openpgp an alias to it. --rfc2440 now stands alone. For now, use the old 2440 defaults for 4880. * misc.c (compliance_option_string): Ditto. * keyedit.c (keyedit_menu): Use compliance_option_string() instead of printing the compliance modes here. 2007-10-25 David Shaw (wk) From 1.4 (September): * import.c (collapse_uids): Significant speedup for de-duping user IDs. 2007-10-25 David Shaw (wk) From 1.4 (July): * armor.c (parse_header_line): Improve test so that the header test only allows "Hash" in the signed data section. * armor.c (is_armor_tag): New. Detect if an armor header matches 2440bis-21. (parse_header_line): Call it here, as bis-21 requires warning the user (but continuing to process the message) when seeing an unknown header. * encode.c (encode_crypt): Missed one call to setup_plaintext_name(). This is bug#809. * sign.c (mk_notation_policy_etc): Expect all sigs that this is called for are >=v4. (write_signature_packets, make_keysig_packet): Only call it for >=v4 sigs. This allows --force-v3-sigs and --force-v4-certs to enable or disable notations, policies, and keyserver URLs. This is bug#800. 2007-10-19 Werner Koch * passphrase.c (passphrase_get): Use new utf8 switching fucntions. 2007-09-14 Werner Koch * gpg.c (build_lib_list): New. (my_strusage): Print lib info. 2007-08-27 Werner Koch * trustdb.c (USE_INTERNAL_REGEX): Remove support. 2007-08-24 Werner Koch * keyring.c (keyring_register_filename): Use same_file_p(). 2007-08-21 Werner Koch * misc.c (openpgp_md_test_algo): Remove rfc2440bis hash algorithms. (openpgp_cipher_test_algo): Likewise for algos 5 and 6. 2007-08-02 Werner Koch * gpg.c: Include gc-opt-flags.h and remove their definition here. 2007-07-17 Werner Koch * gpg.c (gpgconf_list): Declare --encrypt-to and --default-key. * card-util.c (get_manufacturer): Add the unmanaged S/N range. 2007-07-12 Werner Koch * gpg.c (main): Use translate_sys2libc_fd_int when passing an int value. * gpgv.c (main): Ditto. 2007-07-05 Werner Koch * card-util.c (card_generate_subkey, card_store_subkey): Enable the code also for GnuPG-2. * keygen.c (make_backsig): Add arg TIMESTAMP. (write_keybinding): Add arg TIMESTAMP, pass it to make_backsig. (write_direct_sig, write_selfsigs): Add arg TIMESTAMP. (gen_elg, gen_dsa, gen_rsa): Add arg TIMESTAMP. (do_create): Ditto. (do_generate_keypair): Use the same timestamp for key creation time and all key signatures. Return an error if write_direct_sig for the secret key fails. (generate_subkeypair): Ditto. (gen_card_key): New arg TIMESTAMP. (generate_card_subkeypair): Pass current time to gen_card_key. (gen_card_key_with_backup): New arg TIMESTAMP. (read_parameter_file): Add option Creation-Date. (parse_creation_string): New. (do_generate_keypair): Use the Creation-Date if available. (save_unprotected_key_to_card): Use P for P and not D. * call-agent.c (agent_scd_genkey): Add arg CREATETIME. * keyedit.c (menu_backsign): Use the same timestamp for all backsigs. 2007-06-26 Werner Koch * openfile.c (try_make_homedir): Support W32; use standard_homedir. 2007-06-25 Werner Koch * gpg.c, gpgv.c: Include sysutils.h. (main): Replace iobuf_translate_file_handle by translate_sys2libc_fd. 2007-06-21 Werner Koch * main.h: Include util.h. * call-agent.c (start_agent): Factored almost all code out to ../common/asshelp.c. * gpg.h (ctrl_t): Remove. It is now declared in ../common/util.h. 2007-06-20 Werner Koch * misc.c (setsysinfo, trap_unaligned): Remove. It is also in common/sysutils.c. (disable_core_dumps, get_session_marker): * sign.c (sleep): Remove sleep wrapper. 2007-06-18 Marcus Brinkmann * gpg.c (gpgconf_list): Percent escape output of --gpgconf-list. 2007-06-14 Werner Koch * call-agent.c (start_agent): Use gnupg_module_name. 2007-06-12 Werner Koch * openfile.c (copy_options_file): Use gnupg_datadir. * misc.c (get_libexecdir): Remove. Changed all callers to use gnupg_libexecdir. * gpg.c (check_permissions): Use gnupg_libdir. * gpg.c (main): Replace some calls by init_common_subsystems. * gpgv.c (main): Ditto. 2007-06-11 Werner Koch * Makefile.am (needed_libs): Use libcommonstd macro. * gpgv.c (main) [W32]: Call pth_init. * gpg.c (main) [W32]: Call pth_init. 2007-06-08 Werner Koch * Makefile.am (gpg2_LDADD): Syntax fix. 2007-06-06 Werner Koch * passphrase.c (passphrase_get) [!ENABLE_NLS]: Do not define orig_codeset. * Makefile.am (gpgv2_LDADD, gpg2_LDADD): Include LDADD before libgcrypt. * plaintext.c (handle_plaintext): Replace eof by eof_seen as W32's io.h has a symbol with that name. * misc.c: Do not include dynload.h. (w32_shgetfolderpath): Remove. It is now in common/homedir.c. * gpgv.c (i18n_init): Remove. * gpg.c (i18n_init): Remove. (main): Make --load-extension a dummy 2007-05-19 Marcus Brinkmann * passphrase.c (passphrase_get): Use PACKAGE_GT, not PACKAGE. * passphrase.c (passphrase_get): Free ORIG_CODESET on error. 2007-05-16 Werner Koch * sig-check.c (check_backsig): Check the digest algorithm before using it. Fixed bug 797. 2007-05-09 Werner Koch * openfile.c (overwrite_filep, open_outfile) [W32]: Need to use just "nul". Though, I am pretty sure that some MSDOS versions grok the extra /dev/. 2007-05-07 Werner Koch * openfile.c (open_outfile, overwrite_filep) [W32]: Use "/dev/nul". 2007-05-02 David Shaw * packet.h, mainproc.c (reset_literals_seen): New function to reset the literals count. * verify.c (verify_one_file), decrypt.c (decrypt_messages): Call it here so we allow multiple literals in --multifile mode (in different files - not concatenated together). 2007-04-26 Marcus Brinkmann * passphrase.c (passphrase_to_dek): Write missing passphrase status message in case of cancellation. 2007-04-16 Werner Koch * build-packet.c (mpi_write): Made buffer a bit larger. Reported by Alexander Feigl. 2007-04-13 Werner Koch * call-agent.c (start_agent): Don't use log_error when using the fallback hack to start the agent. This is bug 782. 2007-04-05 David Shaw From STABLE-BRANCH-1-4 * parse-packet.c (parse_marker): New. Enforce that the marker contains 'P', 'G', 'P', and nothing but. (parse): Call it here. (skip_packet): No longer need to handle marker packets here. 2007-03-14 David Shaw From STABLE-BRANCH-1-4 * keyserver.c: Windows Vista doesn't grok X_OK and so fails access() tests. Previous versions interpreted X_OK as F_OK anyway, so we'll just use F_OK directly. 2007-03-09 David Shaw From STABLE-BRANCH-1-4 * parse-packet.c (parse_signature): It's hex. * getkey.c (merge_selfsigs_subkey): Avoid listing the contents of a backsig when list mode is on. Noted by Timo Schulz. 2007-03-08 Werner Koch * plaintext.c (handle_plaintext): Add two extra fflush for stdout. 2007-03-08 David Shaw (wk) * keyedit.c (keyedit_menu): If we modify the keyblock (via fix_keyblock() or collapse_uids()) make sure we reprocess the keyblock so the flags are correct. Noted by Robin H. Johnson. * getkey.c (fixup_uidnode): Properly clear flags that don't apply to us (revoked, expired) so that we can reprocess a uid. 2007-03-05 Werner Koch Converted this file to UTF-8. Ported David and my multiple messages changes from 1.4.7. * options.h, gpg.c (main), mainproc.c (check_sig_and_print): Allow multiple sig verification again as this is protected via the multiple-messages code. New option --allow-multiple-messages and --no variant. * status.h (STATUS_ERROR): New status code. * status.c (get_status_string): Ditto. * mainproc.c (proc_plaintext): Emit it if multiple messages are detected. Error out if more than one plaintext packet is encountered. * mainproc.c (literals_seen): New. 2007-02-26 Werner Koch * gpg.c (main): Add verify option show-primary-uid-only. * options.h (VERIFY_SHOW_PRIMARY_UID_ONLY): New. * mainproc.c (check_sig_and_print): Implement it. 2007-02-22 Werner Koch * encr-data.c (decrypt_data): Correctly test for unknown algorithm. * import.c (check_prefs): Ditto. * keyedit.c (show_prefs): Ditto. * mainproc.c (proc_symkey_enc): Ditto. 2007-02-06 Werner Koch * export.c (do_export_stream): Allow reset-subkey-passwd along with sexp-format. 2007-02-04 Werner Koch * parse-packet.c (parse_signature): Limit bytes read for an unknown alogorithm. Fixes Debian bug#402592. 2007-01-31 Werner Koch * verify.c (verify_signatures): Do no dereference a NULL afx. * passphrase.c (passphrase_get): Set the cancel flag on all error from the agent. Fixes a bug reported by Tom Duerbusch. 2007-01-30 Werner Koch * status.c (write_status_begin_signing): New. * sign.c (sign_file, sign_symencrypt_file): Call it. * textfilter.c (copy_clearsig_text): Call it. * call-agent.c (agent_scd_pksign): Pass --hash-rmd160 to SCD if required. * gpg.c (main): Let --no-use-agent and --gpg-agent-info print a warning. * misc.c (obsolete_option): New. 2007-01-29 Werner Koch * pkclist.c (do_we_trust_pre): Issue a user-id-hint status code. 2007-01-15 Werner Koch * parse-packet.c (read_protected_v3_mpi): Make sure to stop reading even for corrupted packets. * keygen.c (generate_user_id): Need to allocate one byte more. Reported by Felix von Leitner. 2006-12-21 Werner Koch * gpg.c (main): New command --server. * gpg.h (struct server_control_s, ctrl_t): New. * server.c: New. * verify.c (gpg_verify): New. * mainproc.c (mainproc_context): Made SIGNED_DATA a structure. (proc_signature_packets_by_fd): New. (proc_compressed_cb): Divert depending on SIGNED_DATA. * plaintext.c (hash_datafile_by_fd): New. * mainproc.c (proc_tree): Use it here. * verify.c (verify_signatures): Init AFX only when needed. Don't leak a context on error. (verify_one_file): Don't leak a context on error. 2006-12-07 Werner Koch * openfile.c (copy_options_file): Use log_info instead of log_error to avoid an error return of gpg due to a missing skeleton file. 2006-12-07 David Shaw * Makefile.am: Link to iconv for jnlib dependency. 2006-12-05 Werner Koch * passphrase.c (passphrase_to_dek): Handle a Cancel request correctly. [Bug#737] * mainproc.c (proc_symkey_enc): Removed workaround for bogus cancel processing. * encode.c (encode_simple): Distinguish error message between cancel and invalid passphrase. (setup_symkey): Ditto. * sign.c (sign_symencrypt_file): Ditto * keyedit.c (change_passphrase): Allow cancellation. * keygen.c (do_ask_passphrase): New arg R_CANCELED. (generate_keypair): Handle a passphrase cancellation. (generate_raw_key): Ditto. (generate_subkeypair): Ditto. 2006-12-04 Werner Koch * filter.h (armor_filter_context_t): New element REFCOUNT. * armor.c (armor_filter): Made static. (push_armor_filter, release_armor_context, new_armor_context): New. (armor_filter): Release the context. * gpg.c (main): Use new armor context functions and push_armor_filter. * export.c (do_export): Ditto. * encode.c (encode_simple, encode_crypt): Ditto. * decrypt.c (decrypt_message, decrypt_messages): Ditto. * dearmor.c (dearmor_file, enarmor_file): Ditto. * verify.c (verify_signatures, verify_one_file): Ditto. * sign.c (sign_file, clearsign_file, sign_symencrypt_file): Ditto. * revoke.c (gen_desig_revoke, gen_revoke): Ditto. * keyserver.c (keyserver_spawn): Ditto. * keygen.c (output_control_s): Turn AFX fields into pointers. (read_parameter_file): Allocate and release AFX fields. (do_generate_keypair): Use push_armor_filter. * import.c (import): Replace iobuf_push_filter2 hack by the new armor context stuff. 2006-12-03 Werner Koch * filter.h: New element REFCOUNT. (handle_progress): Remove prototype. * progress.c (new_progress_context, release_progress_context): New. (progress_filter): Use new function to release context. Made static. (handle_progress): Bumb reference counter. No more check for enabled progress as this is handled by new_progress_context. * verify.c (verify_signatures, verify_one_file): Replace stack based progress context by a heap based one. * sign.c (sign_file, clearsign_file, sign_symencrypt_file): Ditto. * plaintext.c (ask_for_detached_datafile, hash_datafiles): Ditto. * encode.c (encode_simple, encode_crypt): Ditto. * decrypt.c (decrypt_message, decrypt_messages): Ditto. * keyedit.c (menu_clean): Made strings translatable. 2006-12-03 David Shaw * keyedit.c (menu_clean): Show "already minimized" rather than "already clean" when a minimized key is minimized again. From Dirk Traulsen. 2006-12-02 David Shaw * options.h, gpg.c (main), passphrase.c (passphrase_to_dek): Add --passphrase-repeat option to control how many times gpg will re-prompt for a passphrase to ensure the user has typed it correctly. Defaults to 1. 2006-12-02 Werner Koch * encr-data.c: Allocate DFX context on the heap and not on the stack. Changes at several places. Fixes CVE-2006-6235. 2006-11-27 Werner Koch * openfile.c (ask_outfile_name): Fixed buffer overflow occurring if make_printable_string returns a longer string. Fixes bug 728. 2006-11-21 Werner Koch * Makefile.am (needed_libs): libgnu needs to come after libcommon. * keygen.c (ask_expire_interval): Print y2038 warning only for 32 bit time_t. (save_unprotected_key_to_card): Made RSA_N_LEN et al a size_t. Cast printf args. (get_parameter_algo): Allow "ELG" as alias for "ELG-E". * seckey-cert.c (do_check): Made NBYTES a size_t. (do_check): Made NDATA a size_t. (protect_secret_key): Made NARR a size_t. (protect_secret_key): Made NVYES a size_t. * pubkey-enc.c (get_it): Made INDATALEN a size_t. (get_it): Made NFRAME a size_t. * keyid.c (hash_public_key): Made NBITS an unsigned int. * misc.c (checksum_mpi): Made NBYTES a size_t. (openpgp_pk_test_algo2): Made USE_BUF a size_t. * seskey.c (encode_session_key): Made NFRAME a size_t. (do_encode_md): Ditto. (encode_md_value): Cast size_t argument of printf. (encode_md_value): Ditto. 2006-11-10 Werner Koch * parse-packet.c (mpi_read): Changed NREAD to size_t to match the gcry_mpi-scan prototype. (mpi_read): Fixed double increment of bytes read to correctly detect overlong MPIs. 2006-11-05 Werner Koch * gpg.c (main): Remove the default --require-cross-certification. * options.skel: Enable require-cross-certification. 2006-10-31 Werner Koch * pkclist.c (warn_missing_aes_from_pklist): New. * encode.c (encrypt_filter, encode_crypt): Use it here. 2006-10-27 Werner Koch * pkclist.c (warn_missing_mdc_from_pklist): New. * encode.c (use_mdc): Use it here. 2006-10-24 Marcus Brinkmann * Makefile.am (AM_CFLAGS): Add $(LIBASSUAN_CFLAGS). 2006-10-23 Werner Koch * gpg.c (main): New command --gpgconf-test. * Makefile.am (bzip2_source): New. 2006-10-20 Werner Koch * getkey.c (classify_user_id): Reserve '&' for search by keygrip. 2006-10-19 Werner Koch * keygen.c (get_parameter_algo): Add special case for ELG_E which is not supported by libgcrypt's mapping function. 2006-10-18 Werner Koch * keyid.c (v3_keyid): Don't use mempcy as we need to hold the keyids in the native endian format. * import.c (import_print_stats): Use log_printf. * build-packet.c (do_public_key): Care about mpi_write errors. (do_secret_key, do_pubkey_enc, do_signature): Ditto. (mpi_write): Print an extra warning on error. 2006-10-17 Werner Koch * Makefile.am (LDADD): Replaced W32LIBS by NETLIBS. 2006-10-12 David Shaw * parse-packet.c (parse_symkeyenc): Show the unpacked as well as the packed s2k iteration count. * main.h, options.h, gpg.c (encode_s2k_iterations, main), passphrase.c (hash_passphrase): Add --s2k-count option to specify the number of s2k hash iterations. 2006-10-08 Werner Koch * gpgv.c: Remove the tty stubs as we are now required to link to tty anyway (it is included in libcommand and has dependencies to other modules as well). * keyedit.c (keyedit_menu): Use keyedit_completion only if readline is available. It would be better to move this code into gpgrlhelp.c 2006-10-06 Werner Koch * Makefile.am (AM_CFLAGS): Use PTH version of libassuan. 2006-10-06 David Shaw * keyserver.c (keyserver_spawn): Write the 16-digit keyid rather than whatever key selector the user used on the command line. 2006-10-05 Werner Koch * status.c (progress_cb): Changed to libgcrypt API. (set_status_fd): Register the progress cb. * seskey.c (encode_md_value): Check that the hash algo is valid before getting the OID. 2006-10-04 Werner Koch * passphrase.c: Allow for a static passphrase in batch mode. * call-agent.c (agent_havekey): Removed. (percent_plus_escape): New. (agent_get_passphrase): New. (agent_clear_passphrase): New. * passphrase.c: Changed so that we always require the agent. (agent_send_option, agent_send_all_options, agent_open): Removed. (agent_get_passphrase): Cleaned up. Does now use the call-agent functions. Renamed to (passphrase_get): .. this. Changed all callers. (passphrase_clear_cache): Rewritten. (passphrase_to_dek, hash_passphrase): Re-indented. * gpg.c (main): Made --use-agent a dummy option. * seckey-cert.c (check_secret_key): We require the agent, so always allow for 3 tries. * gpg.c (main): Print a warning if -sat has been used. (main): Removed the special treatment of the -k option. -k is now an alias for --list-keys. (main): Removed --list-ownertrust. 2006-10-02 Werner Koch * encr-data.c (decrypt_data, mdc_decode_filter): Check the MDC right here and don't let parse-packet handle the MDC. 2006-09-29 Werner Koch * compress.c (do_uncompress): Removed use of Z_PARTIAL_FLUSH. This is outdated and old zlib versions which still require it have security problems. 2006-09-27 Werner Koch Replaced all STRLIST by strlist_t. 2006-09-21 Werner Koch * signal.c (got_fatal_signal): Replaced readline stuff by a tty function. * Makefile.am (LDADD): Include libgpgrl.a. * gpg.c (main): Call gpg_rl_initialize. * keyedit.c: Removed double inclusion of stdio.h. 2006-09-20 Werner Koch * call-agent.c: Include asshelp.h. (start_agent): Use send_pinentry_environment. 2006-09-14 Werner Koch Replaced all call gpg_error_from_errno(errno) by gpg_error_from_syserror(). 2006-09-13 Werner Koch * gpg.c (main): Made --require-cross-certification the default. 2006-09-06 Marcus Brinkmann * Makefile.am (gpg2_LDADD, gpgv2_LDADD): Replace -lassuan and -lgpg-error with $(LIBASSUAN_LIBS) and $(GPG_ERROR_LIBS). (AM_CFLAGS): Add $(LIBASSUAN_CFLAGS) and $(GPG_ERROR_CFLAGS). 2006-09-06 Werner Koch * gpg.c (main): Enable new assuan API. * call-agent.c: Changed to new Assuan API. 2006-09-01 Werner Koch * call-agent.c: Do not force using the pipe server. * gpg.c (main): Enable card related commands. 2006-08-22 Werner Koch * mainproc.c (proc_plaintext): Fixed a #warning 2006-08-21 Werner Koch * skclist.c (random_is_faked): Implemented. (is_insecure): Also test for the old uppercase version of the insecure string. * gpg.c (main): Renamed --quick-random to debug-quick-quick-random. * gpg.c (print_mds): Do not use the USE_SHA macros. * mainproc.c (proc_encrypted): Remove assign inside condition for better readibility. * packet.h: Moved consts to new header ../common/openpgpdefs.h. 2006-08-16 Werner Koch * keyserver.c (GPGKEYS_PREFIX): Rename to gpg2keys_. This is so that we can install helpers from 1.4 and 2 without conflicts and first of all don't get lost with weird bug reports. * keyid.c (serialno_and_fpr_from_sk): New. Actually lost during the last 1.4 to 1.9 merge. * gpg.c (list_config): Output ccid-reader-id only for gnupg 1. * call-agent.c (agent_scd_writekey): New. (inq_writekey_parms): New. * gpgv.c: Include call-agent.h for use by stubs. * misc.c: Include call-agent.h for use by get_signature_count. 2006-07-27 Werner Koch * parse-packet.c (parse_comment): Cap comments at 65k. (parse_gpg_control): Skip too large control packets. 2006-07-24 David Shaw (wk) * keydb.h, pkclist.c (select_algo_from_prefs, algo_available): Pass a union for preference hints rather than doing void * games. * sign.c (sign_file): Use it here. * sign.c (sign_file): When signing with multiple DSA keys, one being DSA1 and one being DSA2 and encrypting at the same time, if the recipient preferences give a hash that can work with the DSA2 key, then allow the DSA1 key to be promoted rather than giving up and using hash_for(). * pkclist.c (algo_available): Automatically enable DSA2 mode when handling a key that clearly isn't DSA1 (i.e. q!=160). 2006-06-30 Werner Koch * misc.c (checksum_mpi): No need for nbits as they are alredy included in the buffer. 2006-06-29 Werner Koch * parse-packet.c (parse_signature, parse_key): Need store the length of opaque data as number of bits. * card-util.c (card_store_subkey): Ditto. * mainproc.c (print_pkenc_list, check_sig_and_print): Replaced log_get_stream by calls to log_printf. This avoids the extra LFs inserted by the logging function. They are a bit too smart sometimes. * pkclist.c (do_show_revocation_reason): Print final LF through log_printf to avoid extra LFs. * pubkey-enc.c (get_it): Ditto. * seskey.c (encode_md_value): Fix call to gcry. 2006-06-27 Werner Koch Applied patches from 1.4.x (2006-05-22 to 2006-06-23) from David: * keygen.c (keygen_upd_std_prefs, keygen_add_std_prefs) (proc_parameter_file): Add --default-keyserver-url to specify a keyserver URL at key generation time, and "Keyserver:" keyword for doing the same through a batch file. * options.h, gpg.c (main): Ditto. * sign.c (do_sign): For now don't accept a truncated hash even for DSA1 keys (be liberal in what you accept, etc). * import.c (import_one): Add a flag (from_sk) so we don't check prefs on an autoconverted public key. The check should only happen on the sk side. Noted by Dirk Traulsen. * keygen.c (gen_card_key): Add optional argument to return a pointer (not a copy) of the stub secret key for the secret key we just generated on the card. (generate_card_subkeypair): Use it here so that the signing key on the card can use the card to generate the 0x19 backsig on the primary key. Noted by Janko Heilgeist and Jonas Oberg. * parse-packet.c (parse_user_id): Cap the user ID size at 2048 bytes. This prevents a memory allocation attack with a very large user ID. A very large packet length could even cause the allocation (a u32) to wrap around to a small number. Noted by Evgeny Legerov on full-disclosure. * keygen.c (gen_dsa): Allow generating DSA2 keys. Allow specifying sizes > 1024 when --enable-dsa2 is set. The size of q is set automatically based on the key size. (ask_keysize, generate_keypair): Ask for DSA size when --enable-dsa2 is set. * exec.c (make_tempdir) [W32]: Fix bug with a temporary directory on W32 that is over 256 bytes long. Noted by Israel G. Lugo. * gpg.c (reopen_std): New function to reopen fd 0, 1, or 2 if we are called with them closed. This is to protect our keyring/trustdb files from corruption if they get attached to one of the standard fds. Print a warning if possible that this has happened, and fail completely if we cannot reopen (should never happen). (main): Call it here. * parse-packet.c (dump_sig_subpkt, parse_signature): Fix meaning of key expiration and sig expiration subpackets - zero means "never expire" according to 2440, not "expire instantly". * build-packet.c (build_sig_subpkt_from_sig): Ditto. * getkey.c (fixup_uidnode, merge_selfsigs_main) (merge_selfsigs_subkey): Ditto. * keygen.c (keygen_add_key_expire): Ditto. * getkey.c (get_pubkey_byname) * import.c (import_one): Fix key selection problem when auto-key-locate returns a list of keys, not all of which are usable (revoked, expired, etc). Noted by Simon Josefsson. 2006-05-24 Werner Koch * keyid.c (hash_public_key): Do not double hash the length bytes, they are already included by mpi_print. * misc.c (openpgp_pk_test_algo2): Get test call right. * misc.c (string_to_cipher_algo, string_to_digest_algo): New. * keygen.c (keygen_set_std_prefs): use them here. * gpg.c (main): and here. 2006-05-23 Werner Koch * card-util.c (generate_card_keys): Removed temporary kludge for generate_keypair. * call-agent.c (agent_scd_setattr): Add arg SERIALNO. (agent_scd_genkey): Ditto. (agent_scd_change_pin): Ditto. * call-agent.h (struct agent_card_info_s): Updated to match the one of 1.4.3. * Makefile.am (LDADD): Include ZLIBS. * gpgv.c: Removed stubs not anymore useful due to libgcrypt. 2006-05-22 Werner Koch * keyserver.c (keyidlist): Replaced mpi_get_keyid by v3_keyid. * keydb.h (v3_keyid): Added. * import.c (import): Better initialize KEYBLOCK as to quiet compiler warning. * skclist.c (random_is_faked): New. * mainproc.c: Include pka.h. 2006-05-19 Werner Koch * misc.c (openpgp_pk_test_algo2): Need to use gcry_pk_algo_info directly. (string_count_chr): New. * armor.c (parse_header_line): Use renamed function length_sans_trailing_ws. * options.h, gpg.c: Option --strict is not used thus removed code but kept option. 2006-04-28 David Shaw (wk) * keyserver.c (direct_uri_map): New. (keyserver_spawn): Used here to add "_uri" to certain gpgkeys_xxx helpers when the meaning is different if a path is provided (i.e. ldap). (keyserver_import_cert): Show warning if there is a CERT fingerprint, but no --keyserver set. * keyserver.c: Fix build problem with platforms that stick libcurl in a place not in the regular include search path. * options.h, gpg.c (main): Add --enable-dsa2 and --disable-dsa2. Defaults to disable. * pkclist.c (algo_available): If --enable-dsa2 is set, we're allowed to truncate hashes to fit DSA keys. * sign.c (match_dsa_hash): New. Return the best match hash for a given q size. (do_sign, hash_for, sign_file): When signing with a DSA key, if it has q==160, assume it is an old DSA key and don't allow truncation unless --enable-dsa2 is also set. q!=160 always allows truncation since they must be DSA2 keys. (make_keysig_packet): If the user doesn't specify a --cert-digest-algo, use match_dsa_hash to pick the best hash for key signatures. * gpg.c (print_mds): Add SHA-224. * armor.c (armor_filter, parse_hash_header): Add SHA-224. * sign.c (write_plaintext_packet): Factor common literal packet setup code from here, to... * encode.c (encode_simple): .. there. * main.h, plaintext.c (setup_plaintext_name): Here. New. Make sure the literal packet filename field is UTF-8 encoded. * options.h, gpg.c (main): Make sure --set-filename is UTF-8 encoded and note when filenames are already UTF-8. * keyedit.c (menu_backsign): Give some more verbose errors when we have no need to backsign. * getkey.c (parse_auto_key_locate): Fix dupe-removal code. * keyedit.c (menu_backsign): Allow backsigning even if the secret subkey doesn't have a binding signature. * armor.c (radix64_read): Don't report EOF when reading only a pad (=) character. The EOF actually starts after the pad. * gpg.c (main): Make --export, --send-keys, --recv-keys, --refresh-keys, and --fetch-keys follow their arguments from left to right. Suggested by Peter Palfrader. 2006-04-18 Werner Koch * tdbio.c (open_db, migrate_from_v2): Removed feature to migration from old trustdb version 2. * gpg.c, mainproc.c: Removed pipemode feature. * status.c: Removed shared memory coprocess stuff Merged with current gpg 1.4.3 code. * keygen.c, keyid.c, misc.c, openfile.c, verify.c, trustdb.c * textfilter.c, tdbio.c, tdbdump.c, status.c, skclist.c, signal.c * sign.c, sig-check.c, seskey.c, seckey-cert.c, revoke.c * pubkey-enc.c, progress.c, plaintext.c, pkclist.c, photoid.c * passphrase.c, parse-packet.c, mdfilter.c, mainproc.c * keyserver.c, keyring.c, keylist.c, keyedit.c, keydb.c, kbnode.c * import.c, getkey.c, gpgv.c, helptext.c, free-packet.c * build-packet.c, cipher.c, compress.c, dearmor.c, decrypt.c * delkey.c, encr-data.c, encode.c, exec.c, export.c * gpg.c, armor.c: Updated from gnupg-1.4.3 and merged back gcry and gnupg-1.9 related changes. * trustdb.h, tdbio.h, status.h, photoid.h, packet.h, options.h * main.h, keyserver-internal.h, keyring.h, keydb.h, filter.h * exec.h: Ditto. * global.h: Removed after merging constants with gpg.h. * comment.c, pipemode.c: Removed. * card-util.c: Updated from gnupg-1.4.3. * compress-bz2.c: New. 2005-06-15 Werner Koch * g10.c (print_hashline, add_group): Fixes for signed/unsigned pointer mismatch warnings. 2005-06-01 Werner Koch * mkdtemp.c: Removed. * exec.c: Include mkdtemp.h 2004-12-21 Werner Koch * gpgv.c, g10.c (main): Use default_hoemdir (). 2004-12-18 Werner Koch * gpg.h (map_assuan_err): Define in terms of map_assuan_err_with_source. 2004-12-15 Werner Koch * Makefile.am (LDADD): Remove ZLIBS. 2004-10-22 Werner Koch * g10.c (main): Display a bit fat warning that this gpg should not be used. * card-util.c (fetch_url): Disable for gnupg 1.9 (card_generate_subkey): Ditto. (card_store_subkey): Ditto. 2004-09-30 Werner Koch * gpgv.c (i18n_init): Always use LC_ALL. * Makefile.am (LDADD): Adjusted for gettext 0.14. 2004-09-20 Werner Koch * keyedit.c (show_key_with_all_names): Print the card S/N. 2004-09-11 Moritz Schulte * openfile.c (copy_options_file): Fixed last commit (added a `+'). 2004-08-31 Werner Koch * openfile.c (copy_options_file): Use gpg-conf.skel. Better take the length of SKELEXT into account, someone might make it larger. * Makefile.am: Install options.skel as gpg-conf.skel. 2004-08-18 Marcus Brinkmann * passphrase.c (agent_get_passphrase): Fix detection of gpg-agent cancellation. 2004-07-01 Werner Koch * card-util.c (change_login): Kludge to allow reading data from a file. (card_edit): Pass ARG_STRING to change_login. (card_status): Print CA fingerprints. (change_cafpr): New. (card_edit): New command CAFPR. * call-agent.h: Add members for CA fingerprints. * call-agent.c (agent_release_card_info): Invalid them. (learn_status_cb): Store them. 2004-04-30 Werner Koch * g10.c (main) : Use gpg.conf and not /dev/null as default filename. 2004-04-28 Werner Koch * card-util.c (card_edit): Remove PIN verification. (generate_card_keys): New arg SERIALNO. Do PIN verification here after resetting forced_chv1. 2004-04-26 Werner Koch * card-util.c (change_name): Check that the NAME is not too long. (change_url): Likewise. (change_login): Likewise. 2004-03-23 Werner Koch * g10.c: New options --gpgconf-list, --debug-level and --log-file (set_debug): Add arg DEBUG_LEVEL. (main): Look at less and less version specific config files. From gnupg 1.3. 2004-02-17 Werner Koch * call-agent.c (start_agent): Ignore an empty GPG_AGENT_INFO. * passphrase.c (agent_open): Ditto. 2004-02-12 Werner Koch * gpgv.c: Removed g10defs.h. * Makefile.am: Include cmacros.am for common flags. 2004-02-11 Werner Koch * openfile.c (try_make_homedir): Use GNUPG_DEFAULT_HOMEDIR. * gpgv.c (main): Ditto. * g10.c (main): Ditto. 2004-01-19 Moritz Schulte * keygen.c (do_generate_keypair): Print member fname, instead of newfname, again. (do_generate_keypair): Don't try to execute certain pieces of code in case an error occured. (gen_card_key): Don't print out a message, which is already printed by do_generate_keypair(). 2004-01-18 Moritz Schulte * keygen.c (do_generate_keypair): Print member fname, instead of newfname. 2003-12-17 Werner Koch * card-util.c (print_name): Fixed bad format string usage. (print_isoname): Ditto. * trustdb.c (check_regexp): s/exp/expr/. * keyedit.c (trustsig_prompt): Removed a "> 255" term; it is always false due to the data type. * passphrase.c (agent_get_passphrase): Use xasprintf and avoid non-literal format strings. * tdbio.c (upd_hashtable, drop_from_hashtable, lookup_hashtable): Fixed log_error format string bugs. Kudos to the now working gcc-3.3 -Wformat-nonliteral and Florian Weimer's investigations in gnupg 1.2.3. 2003-12-15 Werner Koch * seckey-cert.c (protect_secret_key): Use gry_create_nonce for the IV; there is not need for real strong random here and it even better protect the random bits used for the key. 2003-11-16 Moritz Schulte * signal.c: Removed unused file. 2003-11-10 Moritz Schulte * Makefile.am (INCLUDES): Added: @LIBGCRYPT_CFLAGS@. 2003-10-25 Werner Koch * call-agent.c (learn_status_cb, scd_genkey_cb): Fixed faulty use of !spacep(). 2003-10-20 Werner Koch * card-util.c (card_edit): New command "passwd". Add logic to check the PIN in advance. (card_status): Add new args to return the serial number. Changed all callers. * call-agent.c (agent_scd_checkpin): New. 2003-10-08 Werner Koch * call-agent.c (agent_scd_getattr): Don't clear the passed info structure, so that it can indeed be updated. * card-util.c (fpr_is_zero): New. (generate_card_keys): New. (card_edit): New command "generate". * keygen.c (generate_keypair): New arg CARD_SERIALNO, removed call to check_smartcard. (check_smartcard,show_smartcard): Removed. (show_sha1_fpr,fpr_is_zero): Removed. 2003-10-01 Werner Koch * card-util.c: Tweaked to use this source also under 1.3. 2003-09-30 Werner Koch * keylist.c (print_card_serialno): New. (list_keyblock_print): Use it here. * card-util.c (toggle_forcesig): New. (card_edit): New command "forcesig". * card-util.c (print_name, print_isoname): Use 0 and not LF fro the max_n arg of tty_print_utf8_string2. * call-agent.c (agent_scd_getattr): New. (learn_status_cb): Release values before assignment so that it can be used by getattr to update the structure. * card-util.c (change_pin): Simplified. We now have only a PIN and an Admin PIN. 2003-09-27 Werner Koch * sign.c (do_sign): Removed disabled testcode. 2003-09-26 Timo Schulz * card_status (card_status): Do not use fputs since the fp parameter can be NULL. This fixes a segv. 2003-09-24 Werner Koch * card-util.c (print_isoname,card_status): Handle opt.with_colons. (print_sha1_fpr_colon): New. 2003-09-23 Werner Koch Merged most of David Shaw's changes in 1.3 since 2003-06-03. * Makefile.am: Include W32LIBS where appropriate. * armor.c (parse_hash_header,armor_filter): Drop TIGER/192 support. * g10.c (print_hex,print_mds): Ditto. * pkclist.c (algo_available): Ditto. * armor.c (armor_filter): Allow using --comment multiple times to get multiple Comment header lines. --no-comments resets list. * options.h, g10.c (main): Ditto. Deprecate --default-comment in favor of --no-comments. * g10.c (main): Trim --help to commonly used options. Remove -f. * g10.c (main): Add --multifile as an alias to turn --encrypt into --encrypt-files (plus --verify-files, --decrypt-files). Error out if --multifile is used with the commands that don't support it yet. * encode.c (use_mdc), g10.c (main): Use RFC1991 and RFC2440 directly to check for MDC usability. Do not set the force_mdc or disable_mdc flags since there is no point any longer. * g10.c (main): Use "keyserver-url" instead of "preferred-keyserver" for the sake of short and simple commands. (add_keyserver_url): Clarify a few strings. It's a "preferred keyserver URL". * keyedit.c (keyedit_menu): Ditto. * sign.c (mk_notation_policy_etc): Ditto. * main.h, keygen.c (keygen_add_keyserver_url): Signature callback for adding a keyserver URL. * keyedit.c (keyedit_menu, menu_set_keyserver_url): New command to set preferred keyserver to specified (or all) user IDs. * build-packet.c (build_sig_subpkt): Set preferred keyserver flag while building a preferred keyserver subpacket. * keylist.c (show_policy_url, show_keyserver_url): URLs might be UTF8. * keyedit.c (menu_addrevoker): Fix leaking a few bytes. * keyedit.c (show_key_with_all_names): Use list-option show-long-keyid in main --edit-key display. * keyedit.c (print_and_check_one_sig): Use list-option show-long-keyid in --edit-key "check" function. * passphrase.c (agent_send_all_options): Make use of $GPG_TTY. * g10.c (main): Disable use-agent if passphrase-fd is given later. Suggested by Kurt Garloff. * exec.c, g10.c, gpgv.c, passphrase.c, photoid.c: s/__MINGW32__/_WIN32/ to help building on native Windows compilers. Requested by Brian Gladman. From Werner on stable branch. * options.h, g10.c (main): Add list-option list-preferred-keyserver. * keyedit.c (change_passphrase): When responding 'no' to the blank passphrase question, re-prompt for a new passphrase. This is bug #202. * mainproc.c (check_sig_and_print): Use two different preferred keyserver displays - one if the key is not present (to tell the user where to get the key), the other if it is present (to tell the user where the key can be refreshed). * packet.h, parse-packet.c (parse_signature): Set flag if a preferred keyserver is present. * keylist.c (list_keyblock_print): Show keyserver url in listings with list-option show-keyserver-url. * mainproc.c (check_sig_and_print): Get the uid validity before printing any sig results to avoid munging the output with trustdb warnings. * g10.c (main): Don't include --show-keyring in --help as it is deprecated. * options.skel: Note that keyserver.pgp.com isn't synchronized, and explain the roundrobin a bit better. * sig-check.c (check_key_signature2), import.c (import_one, import_revoke_cert, chk_self_sigs, delete_inv_parts, collapse_uids, merge_blocks): Make much quieter during import of slightly munged, but recoverable, keys. Use log_error for unrecoverable import failures. * keyring.c (keyring_rebuild_cache): Comment. * sign.c (mk_notation_and_policy): Making a v3 signature with notations or policy urls is an error, not an info (i.e. increment the errorcount). Don't print the notation or policy url to stdout since it can be mixed into the output stream when piping and munge the stream. * packet.h, sig-check.c (signature_check2, do_check, do_check_messages): Provide a signing-key-is-revoked flag. Change all callers. * status.h, status.c (get_status_string): New REVKEYSIG status tag for a good signature from a revoked key. * mainproc.c (do_check_sig, check_sig_and_print): Use it here. * import.c (import_revoke_cert, merge_blocks, merge_sigs): Compare actual signatures on import rather than using keyid or class matching. This does not change actual behavior with a key, but does mean that all sigs are imported whether they will be used or not. * parse-packet.c (parse_signature): Don't give "signature packet without xxxx" warnings for experimental pk algorithms. An experimental algorithm may not have a notion of (for example) a keyid (i.e. PGP's x.509 stuff). * options.h, g10.c (main), keylist.c (list_keyblock_print), keyedit.c (print_and_check_one_sig): New "show-sig-expire" list-option to show signature expiration dates (if any). * options.h, g10.c (main, add_keyserver_url): Add --sig-preferred-keyserver to implant a "where to get my key" subpacket into a signature. * sign.c (mk_notation_and_policy): Rename to mk_notation_policy_etc and add preferred keyserver support for signatures. * keygen.c (do_add_key_flags): Don't set the certify flag for subkeys. (ask_algo): Provide key flags for DSA, Elgamal_e, and Elgamal subkeys. (generate_keypair): Provide key flags for the default DSA/Elgamal keys. * sig-check.c (signature_check, signature_check2, check_key_signature, check_key_signature2): Allow passing NULLs for unused parameters in the x2 form of each function to avoid the need for dummy variables. getkey.c, mainproc.c: Change all callers. * trustdb.h, trustdb.c (read_trust_options): New. Returns items from the trustdb version record. * keylist.c (public_key_list): Use it here for the new "tru" record. * gpgv.c (read_trust_options): Stub. * keyedit.c (show_key_with_all_names): Use list-option show-validity in --edit-key interface as well. * options.h, g10.c (main), mainproc.c (check_sig_and_print): Add verify-options "show-validity" and "show-long-keyid" to show trustdb validity and long keyids during (file) signature verification. * packet.h, main.h, sig-check.c (signature_check2) (check_key_signature2, do_check): If ret_pk is set, fill in the pk used to verify the signature. Change all callers in getkey.c, mainproc.c, and sig-check.c. * keylist.c (list_keyblock_colon): Use the ret_pk from above to put the fingerprint of the signing key in "sig" records during a --with-colons --check-sigs. This requires --no-sig-cache as well since we don't cache fingerprints. * parse-packet.c (parse_signature): No need to reserve 8 bytes for the unhashed signature cache any longer. * misc.c (pct_expando): Add two new expandos - signer's fingerprint (%g), and signer's primary fingerprint (%p). * g10.c (main): Add --rfc2440 alias for --openpgp since in a few months, they won't be the same thing. * keyserver.c (parse_keyserver_uri): Accept "http" as an alias for "hkp", since it is occasionally written that way. (keyserver_spawn): Use ascii_isspace to avoid locale issues. * keygen.c (ask_user_id): Make --allow-freeform-uid apply to the email field as well as the name field, and allow mixing fields when it is set. * trustdb.c (validate_one_keyblock): Certifications on revoked or expired uids do not count in the web of trust. * signal.c (init_one_signal, pause_on_sigusr, do_block): Only use sigprocmask() if we have sigset_t, and only use sigaction() if we have struct sigaction. This is for Forte c89 on Solaris which seems to define only the function call half of the two pairs by default. (pause_on_sigusr): Typo. (do_block): If we can't use sigprocmask() and sigset_t, try to get the number of signals from NSIG as well as MAXSIG, and if we can't, fail with an explanation. * signal.c, tdbio.c: Comment out the transaction code. It was not used in this version, and was causing some build problems on quasi-posix platforms (Solaris and Forte c89). * keylist.c (list_keyblock_colon): Don't include validity values when listing secret keys since they can be incorrect and/or misleading. This is a temporary kludge, and will be handled properly in 1.9/2.0. * mainproc.c (check_sig_and_print): Only show the "key available from" preferred keyserver line if the key is not currently present. * keyedit.c (sign_uids): Do not sign expired uids without --expert (same behavior as revoked uids). Do not allow signing a user ID without a self-signature. --expert overrides. Add additional prompt to the signature level question. (menu_expire): When changing expiration dates, don't replace selfsigs on revoked uids since this would effectively unrevoke them. There is also no point in replacing expired selfsigs. This is bug #181 * g10.c (add_notation_data): Make sure that only ascii is passed to iscntrl. Noted by Christian Biere. * getkey.c (classify_user_id2): Replaced isspace by spacep * keygen.c (ask_user_id): Ditto. (get_parameter_algo): Ditto. * keyedit.c (keyedit_menu): Ditto. * tdbdump.c (import_ownertrust): Ditto. s/isxdigit/hexdigitp/. * revoke.c (ask_revocation_reason): * keyserver.c (keyserver_spawn): Dito. * parse-packet.c (parse): Disallow old style partial length for all key material packets to avoid possible corruption of keyrings. * import.c (import_keys_internal): Invalidate the cache so that the file descriptor gets closed. Fixes bug reported by Juan F. Codagnone. * options.h, g10.c (main), main.h, keylist.c (show_keyserver_url), mainproc.c (check_sig_and_print), parse-packet.c (dump_sig_subpkt, parse_one_sig_subpkt, can_handle_critical): Add read-only support for preferred keyserver subpackets. They're basically policy URLs with a different name. Add a verify-option "show-preferred-keyserver" to turn them on and off (on by default, as per stable branch). * g10.c (main): Add "--set-notation" as alias to "--notation-data" this is to make things consistent with --set-policy-url meaning both sigs and certs. * options.h, g10.c (main), keylist.c (list_keyblock_print): Add "show-validity" and "show-long-keyid" list-options. * gpgv.c (get_validity, trust_value_to_string): Stubs. * g10.c (main): Use SAFE_VERSION instead of VERSION in the version-specific gpg.conf file so it can be overridden on RISCOS. * keyedit.c (show_key_with_all_names): Fix assertion failure when using toggle to see a secret key. Reported by Maxim Britov. 2003-09-22 Timo Schulz * card-util.c (card_status): Free pk in case of an error and return if the card is no OpenPGP card. 2003-09-18 Werner Koch * g10.c: New command --card-edit. * card-util.c (card_status): Use tty_fprintf for all output. (print_sha1_fpr, print_isoname): Ditto. (get_one_name,change_name, change_url, change_login,change_lang) (change_sex): New; taken from keygen.c. * keygen.c (smartcard_get_one_name, smartcard_change_name) (smartcard_change_url, smartcard_change_login_data) (smartcard_change_lang, smartcard_change_sex): Removed. (check_smartcard): Removed most menu items. 2003-09-06 Werner Koch * misc.c (openpgp_pk_algo_usage): Allow AUTH where SIGN is allowed. * keygen.c (ask_passphrase): No need to allocated S2K in secure memory. 2003-09-04 Werner Koch * keygen.c (do_add_key_flags, parse_parameter_usage) (do_generate_keypair): Add support the proposed AUTH key flag. * getkey.c (fixup_uidnode, merge_selfsigs_main) (merge_selfsigs_subkey, premerge_public_with_secret): Ditto. * keylist.c (print_capabilities): Ditto. 2003-08-25 Timo Schulz * pkglue.c (mpi_from_sexp): New. Used to factor out some common code. 2003-08-24 Werner Koch * keygen.c (do_generate_keypair): Print a reminder to use --gen-revoke. 2003-08-18 Timo Schulz * encode.c (encode_sesskey): Checked the code and removed the warning since all compatibility checks with PGP succeeded. * mainproc.c (symkey_decrypt_sesskey): Better check for the algorithm and check the return values of some functions. * mdc.c (use_mdc): Simplified. 2003-08-07 Werner Koch * pkglue.c (pk_sign): Fix last change. (pk_verify): Check for valid DATA array so that we don't segv in Libgcrypt. (pk_verify): Ditto. 2003-08-06 Werner Koch * pkglue.c (pk_sign): Allow signing using RSA. 2003-08-05 Werner Koch * Makefile.am (install-data-local): Dropped check for the ancient gpgm tool. (bin_PROGRAMS): Renamed gpg to gpg2 and gpgv to gpgv2. This is so that it won't conflict with the current stable version of gpg. * pkglue.c (pk_check_secret_key): New. * seckey-cert.c (do_check): Reenable this test here again. * g10.c (main): Add command -K as an alias for --list-secret-keys. Command "-k" is now an alias to --list-keys. Remove special treatment of -kv and -kvv. (set_cmd): Ditto. (main): Strip a "-cvs" suffix when testing for a version specific config file. * status.h, status.c, g10.c [USE_SHM_COPROCESSING]: Removed. This is not any longer available. 2003-07-29 Werner Koch * g10.c (main): Add secmem features and set the random seed file. (g10_exit): Update the random seed file. * parse-packet.c (parse_signature,read_protected_v3_mpi) (parse_key): Fixed use of mpi_set_opaque. * keygen.c (gen_card_key): Ditto. 2003-07-28 Werner Koch * status.c (progress_cb): Adjusted for use with Libcgrypt. (set_status_fd): Register that callback. * keygen.c (smartcard_change_login_data): New. (smartcard_change_lang): New. (smartcard_change_sex): New. (check_smartcard): Add menu entries to edit the above. (gen_elg,gen_dsa,gen_rsa): Reimplemented in terms of Libgcrypt. (genhelp_protect, genhelp_factors, key_from_sexp): New. * comment.c (make_comment_node_from_buffer): New. (make_comment_node): Reimplemented in terms of above. 2003-07-27 Werner Koch Adjusted for gcry_mpi_print and gcry_mpi_scan API change. 2003-07-24 Werner Koch * g10.c: New command --card-status. * card-util.c (card_status): New. * call-agent.c (learn_status_cb): Parse more information. * keylist.c (print_pubkey_info): Add FP arg for optional printing to a stream. Changed all callers. 2003-07-23 Werner Koch * keygen.c (generate_keypair): Create an AUTHKEYTYPE entry for cards. (do_generate_keypair): Abd generate the authkey. (check_smartcard): Changed menu accordingly. 2003-07-22 Werner Koch * g10.c: New command --change-pin. * card-util.c: New. * call-agent.c (agent_scd_change_pin): New. (agent_release_card_info): New. * keygen.c (check_smartcard): Use it here. 2003-07-16 Werner Koch * export.c (parse_export_options): New option sexp-format. (export_seckeys,export_secsubkeys): Check sexp-format option. (do_export): Ignore armor for sexp format. (do_export_stream): Handle sexp-format. (write_sexp_line,write_sexp_keyparm, build_sexp_seckey): New. (build_sexp): New. 2003-07-03 Werner Koch * options.h (DBG_CIPHER): Reintroduced it. * seskey.c (encode_session_key): Debug output of the session key. * pubkey-enc.c (get_it): Handle card case. * call-agent.c (agent_scd_pkdecrypt): New. * pkglue.c (pk_encrypt): Add RSA support. * g10.c (main): Default to --use-agent. * keygen.c (show_smartcard): Print info about the public key. (check_smartcard): Check for existing key here. (gen_card_key): And not anymore here. (fpr_is_zero): New. (generate_keypair): Generate both keys for a card. (smartcard_change_url): Nw. 2003-07-02 Werner Koch * seckey-cert.c (is_secret_key_protected): Let it handle mode 1002. 2003-07-01 Werner Koch * keygen.c (gen_card_key): Obviously we should use the creation date received from SCDAEMON, so that the fingerprints will match. * sign.c (do_sign): Pass the serialno to the sign code. * keyid.c (serialno_and_fpr_from_sk): New. 2003-06-30 Werner Koch * call-agent.h (agent_card_info_s): Add field serialno. * call-agent.c (store_serialno): New. (learn_status_cb): Store the serial number. * keygen.c (gen_card_key): Store the serial number (check_smartcard): New argument to return the serial number. (generate_keypair): Get the serial number from check_smartcard and store it as a parameter. * parse-packet.c (parse_key): Use the protect.iv field to store the serial number. * build-packet.c (do_secret_key): Write the serial number. 2003-06-27 Werner Koch * seckey-cert.c (check_secret_key): Bypass the unprotection for mode 1002. * sign.c (do_sign): Handle card case (i.e. mode 1002). 2003-06-26 Werner Koch * build-packet.c (do_secret_key): Implement special protection mode 1002. * parse-packet.c (parse_key): Likewise. * keygen.c (smartcard_gen_key): New. * call-agent.c (agent_scd_setattr): New. 2003-06-24 Werner Koch * Makefile.am: Removed signal.c * g10.c (emergency_cleanup): New. (main): Use gnupg_init_signals and register malloc for assuan. 2003-06-23 Werner Koch * keyid.c (do_fingerprint_md): Made it work again. 2003-06-19 Werner Koch Fixed all "==" comparisons against error code constants to use gpg_err_code(). * import.c (import_secret_one): (import_revoke_cert): (chk_self_sigs): * misc.c (openpgp_md_map_name): Check also for the Hx format. (openpgp_cipher_map_name): Check also for the Sx format. (pubkey_get_npkey): Adjusted for changed gcrypt API. (pubkey_get_nskey): Ditto. (pubkey_get_nsig): Ditto. (pubkey_get_nenc): Ditto. 2003-06-18 Werner Koch Finished the bulk of changes for gnupg 1.9. This included switching to libgcrypt functions, using shared error codes from libgpg-error, replacing the old functions we used to have in ../util by those in ../jnlib and ../common, renaming the malloc functions and a couple of types. Note, that not all changes are listed below becuause they are too similar and done at far too many places. As of today the code builds using the current libgcrypt from CVS but it is very unlikely that it actually works. * sig-check.c (cmp_help): Removed. Was never used. * pkglue.c: New. Most stuff taken from gnupg 1.1.2. * pkglue.h: New. * misc.c (pull_in_libs): Removed. * keygen.c (count_chr): New. (ask_user_id): Removed faked RNG support. * misc.c (openpgp_md_map_name,openpgp_cipher_map_name) (openpgp_pk_map_name): New. * skclist.c (build_sk_list): Removed faked RNG support. (is_insecure): Removed. * comment.c (make_mpi_comment_node): Use gcry MPI print function. * keyid.c (v3_keyid): New. * misc.c (mpi_write,mpi_write_opaque,mpi_read,mpi_read_opaque) (mpi_print): New. Taken from gnupg 1.1.2. (checksum_mpi): Replaced by implementation from 1.1.2. * g10.c (my_strusage): Renamed from strusage and return NULL instead calling a default function. (add_to_strlist2): New. Taken from ../util/strgutil.c of gnupg 1.2. * plaintext.c (handle_plaintext): New arg CREATE_FILE to cope with the fact that gpg-error does not have this error code anymore. * mainproc.c (symkey_decrypt_sesskey): Ditto. * seskey.c (make_session_key): Adjusted for use with libgcrypt. (encode_session_key): Ditto. (do_encode_md): Ditto. (encode_md_value): Ditto. * keyring.c: Use libgpg-error instead of READ_ERROR etc. * g10.c: Adjusted all algorithm name/id mapping functions. (set_debug): Pass MPI and CRYPTO debug values to libgcrypt. * Makefile.am (INCLUDES): Define LOCALEDIR and the default error source. * g10.c (i18n_init): s/G10_LOCALEDIR/LOCALEDIR/. Renamed m_alloc et al to xmalloc et al. s/g10_errstr/gpg_strerror/ s/MPI/gcry_mpi_t/ Adjusted all md_open calls to the libgcrypt API. * build-packet.c (do_comment): Return error code from iobuf write function. (do_user_id): Ditto. (do_public_key): Ditto. * Makefile.am: Add new files, link gpg with libgpg-error. * g10.c, options.h: New option --agent-program. * call-agent.c: New. * gpg.h, call-agent.h: New. 2003-06-03 David Shaw * options.h, g10.c (main), keylist.c (list_keyblock_print): Add "show-validity" and "show-long-keyid" list-options. * gpgv.c (get_validity, trust_value_to_string): Stubs. * g10.c (main): Use SAFE_VERSION instead of VERSION in the version-specific gpg.conf file so it can be overridden on RISCOS. 2003-06-01 David Shaw * g10.c (main), keylist.c (show_policy_url, show_notation), mainproc.c (check_sig_and_print): Emulate the old policy and notation behavior (display by default). Send to status-fd whether it is displayed on the screen or not. * g10.c (main): Since we now have some options in devel that won't work in a stable branch gpg.conf file, try for a version-specific gpg.conf-VERSION file before falling back to gpg.conf. * main.h, options.h: Move various option flags to options.h. 2003-05-31 David Shaw * mainproc.c (check_sig_and_print), main.h, keylist.c (show_policy, show_notation): Collapse the old print_notation_data into show_policy() and show_notation() so there is only one function to print notations and policy URLs. * options.h, main.h, g10.c (main), keyedit.c (print_and_check_one_sig), keylist.c (list_one, list_keyblock_print), pkclist.c (do_edit_ownertrust), sign.c (mk_notation_and_policy): New "list-options" and "verify-options" commands. These replace the existing --show-photos/--no-show-photos, --show-notation/--no-show-notation, --show-policy-url/--no-show-policy-url, and --show-keyring options. The new method is more flexible since a user can specify (for example) showing photos during sig verification, but not in key listings. The old options are emulated. * main.h, misc.c (parse_options): New general option line parser. Fix the bug in the old version that did not handle report syntax errors after a valid entry. * import.c (parse_import_options), export.c (parse_export_options): Call it here instead of duplicating the code. 2003-05-30 David Shaw * keylist.c (list_one): Don't show the keyring filename when in --with-colons mode. Actually translate "Keyring" string. * mainproc.c (proc_tree): We can't currently handle multiple signatures of different classes or digests (we'd pretty much have to run a different hash context for each), but if they are all the same, make an exception. This is Debian bug #194292. * sig-check.c (check_key_signature2): Make string translatable. * packet.h, getkey.c (fixup_uidnode): Mark real primary uids differently than assumed primaries. * keyedit.c (no_primary_warning): Use the differently marked primaries here in a new function to warn when an --edit-key command might rearrange the self-sig dates enough to change which uid is primary. (menu_expire, menu_set_preferences): Use no_primary_warning() here. * Makefile.am: Use @DLLIBS@ for -ldl. 2003-05-26 David Shaw * getkey.c (premerge_public_with_secret): Made "no secret subkey for" warning a verbose item and translatable. (From wk on stable branch) * sig-check.c (check_key_signature2): Made "no subkey for subkey binding packet" a verbose item instead of a !quiet one. There are too many garbled keys out in the wild. (From wk on stable branch) * filter.h: Remove const from WHAT. (From wk on stable branch) * progress.c (handle_progress): Store a copy of NAME. (progress_filter): Release WHAT, make sure not to print a NULL WHAT. (From wk on stable branch) * openfile.c (open_sigfile): Adjust free for new progress semantics. (From wk on stable branch) * plaintext.c (ask_for_detached_datafile): Don't dealloc pfx->WHAT. (From wk on stable branch) * seckey-cert.c (do_check): Issue the RSA_OR_IDEA status when the cipher algo is IDEA to make it easier to track down the problem. (From twoaday on stable branch) 2003-05-24 David Shaw * armor.c, g10.c, kbnode.c, misc.c, pkclist.c, sign.c, build-packet.c, getkey.c, keydb.c, openfile.c, plaintext.c, status.c, gpgv.c, keygen.c, options.h, sig-check.c, tdbio.h, encode.c, mainproc.c, parse-packet.c, signal.c, textfilter.c: Edit all preprocessor instructions to remove whitespace before the '#'. This is not required by C89, but there are some compilers out there that don't like it. 2003-05-21 David Shaw * trustdb.h, trustdb.c (is_disabled), gpgv.c (is_disabled): Rename is_disabled to cache_disabled_value, which now takes a pk and not just the keyid. This is for speed since there is no need to re-fetch a key when we already have that key handy. Cache the result of the check so we don't need to hit the trustdb more than once. * getkey.c (skip_disabled): New function to get a pk and call is_disabled on it. (key_byname): Use it here. * packet.h, getkey.c (skip_disabled), keylist.c (print_capabilities): New "pk_is_disabled" macro to retrieve the cached disabled value if available, and fill it in via cache_disabled_value if not available. * trustdb.c (get_validity): Cache the disabled value since we have it handy and it might be useful later. * parse-packet.c (parse_key): Clear disabled flag when parsing a new key. Just in case someone forgets to clear the whole key. * getkey.c (merge_selfsigs_main): Add an "if all else fails" path for setting a single user ID primary when there are multiple set primaries all at the same second, or no primaries set and the most recent user IDs are at the same second, or no signed user IDs at all. This is arbitrary, but deterministic. * exec.h, photoid.h: Add copyright message. * keylist.c (list_keyblock_print): Don't dump attribs for revoked/expired/etc uids for non-colon key listings. This is for consistency with --show-photos. * main.h, keylist.c (dump_attribs), mainproc.c (check_sig_and_print): Dump attribs if --attrib-fd is set when verifying signatures. * g10.c (main): New --gnupg option to disable the various --openpgp, --pgpX, etc. options. This is the same as --no-XXXX for those options. * revoke.c (ask_revocation_reason): Clear old reason if user elects to repeat question. This is bug 153. * keyedit.c (sign_uids): Show keyid of the key making the signature. 2003-05-21 Werner Koch * progress.c (handle_progress) * sign.c (write_plaintext_packet) * encode.c (encode_simple,encode_crypt): Make sure that a filename of "-" is considered to be stdin so that iobuf_get_filelength won't get called. This fixes bug 156 reported by Gregery Barton. 2003-05-02 David Shaw * packet.h, build-packet.c (build_sig_subpkt), export.c (do_export_stream), import.c (remove_bad_stuff, import), parse-packet.c (dump_sig_subpkt, parse_one_sig_subpkt): Remove vestigal code for the old sig cache subpacket. This wasn't completely harmless as it caused subpacket 101 to disappear on import and export. * options.h, armor.c, cipher.c, g10.c, keyedit.c, pkclist.c, sign.c, encode.c, getkey.c, revoke.c: The current flags for different levels of PGP-ness are massively complex. This is step one in simplifying them. No functional change yet, just use a macro to check for compliance level. * sign.c (sign_file): Fix bug that causes spurious compression preference warning. * sign.c (clearsign_file): Fix bug that prevents proper warning message from appearing when clearsigning in --pgp2 mode with a non-v3 RSA key. * main.h, misc.c (compliance_option_string, compliance_string, compliance_failure), pkclist.c (build_pk_list), sign.c (sign_file, clearsign_file), encode.c (encode_crypt, write_pubkey_enc_from_list): New functions to put the "this message may not be usable...." warning in one place. * options.h, g10.c (main): Part two of the simplification. Use a single enum to indicate what we are compliant to (1991, 2440, PGPx, etc.) * g10.c (main): Show errors for failure in export, send-keys, recv-keys, and refresh-keys. * options.h, g10.c (main): Give algorithm warnings for algorithms chosen against the --pgpX and --openpgp rules. * keydb.h, pkclist.c (algo_available): Make TIGER192 invalid in --openpgp mode. * sign.c (sign_file), pkclist.c (algo_available): Allow passing a hint of 0. 2003-05-01 David Shaw * tdbio.c (create_version_record): Only create new trustdbs with TM_CLASSIC or TM_PGP. * trustdb.h, trustdb.c (trust_string, get_ownertrust_string, get_validity_string, ask_ownertrust, validate_keys), pkclist.c (do_edit_ownertrust): Rename trust_string to trust_value_to_string for naming consistency. * trustdb.h, trustdb.c (string_to_trust_value): New function to translate a string to a trust value. * g10.c (main): Use string_to_trust_value here for --force-ownertrust. * options.h, g10.c (main), trustdb.c (trust_model_string, init_trustdb, check_trustdb, update_trustdb, get_validity, validate_one_keyblock): An "OpenPGP" trust model is misleading since there is no official OpenPGP trust model. Use "PGP" instead. 2003-04-30 David Shaw * build-packet.c (build_sig_subpkt): Comments. * exec.c (exec_write): Cast NULL to void* to properly terminate varargs list. * keyedit.c (show_key_with_all_names): Just for safety, catch an invalid pk algorithm. * sign.c (make_keysig_packet): Crucial that the call to mksubpkt comes LAST before the calls to finalize the sig as that makes it possible for the mksubpkt function to get a reliable pointer to the subpacket area. * pkclist.c (do_we_trust_pre): If an untrusted key was chosen by a particular user ID, use that ID as the one to ask about when prompting whether to use the key anyway. (build_pk_list): Similar change here when adding keys to the recipient list. * trustdb.c (update_validity): Fix bug that prevented more than one validity record per trust record. (get_validity): When retrieving validity for a (user) supplied user ID, return the validity for that user ID only, and do not fall back to the general key validity. (validate_one_keyblock): Some commentary on whether non-self-signed user IDs belong in the web of trust (arguably, they do). 2003-04-27 David Shaw * g10.c (main): Add --no-textmode. * export.c (do_export_stream), keyedit.c (show_key_with_all_names, menu_addrevoker), mainproc.c (check_sig_and_print), photoid.c (show_photos), sign.c (mk_notation_and_policy), trustdb.c (get_validity, reset_trust_records, validate_keys): Make some strings translatable. * mainproc.c (check_sig_and_print): Show digest algorithm and sig class when verifying a sig with --verbose on, and add version, pk and hash algorithms and sig class to VALIDSIG. * parse-packet.c (enum_sig_subpkt): Make a warning message a --verbose warning message since we don't need to warn every time we see an unknown critical (we only need to invalidate the signature). * trustdb.c (init_trustdb): Check the trustdb options even with TM_AUTO since the auto may become TM_CLASSIC or TM_OPENPGP. 2003-04-26 David Shaw * sign.c (do_sign): Show the hash used when making a signature in verbose mode. * tdbio.h, tdbio.c (tdbio_read_model): New function to return the trust model used in a given trustdb. * options.h, g10.c (main), trustdb.c (init_trustdb, check_trustdb, update_trustdb): Use tdbio_read_model to implement an "auto" trust model which is set via the trustdb. 2003-04-23 David Shaw * import.c (import_revoke_cert): Remove ultimate trust when revoking an ultimately trusted key. * keyedit.c (sign_uids): Allow replacing expired signatures. Allow duplicate signatures with --expert. * pkclist.c (check_signatures_trust): Don't display a null fingerprint when checking a signature with --always-trust enabled. * filter.h (progress_filter_context_t), progress.c (handle_progress), plaintext.c (ask_for_detached_datafile, hash_datafiles): Fix compiler warnings. Make "what" constant. * build-packet.c (do_plaintext): Do not create invalid literal packets with >255-byte names. 2003-04-15 Werner Koch * Makefile.am (AM_CFLAGS): Make use of AM_CFLAGS and AM_LDFLAGS. * g10.c, options.h: New option --enable-progress-filter. * progress.c (handle_progress): Make use of it. 2003-04-15 Marcus Brinkmann * progress.c: New file. * Makefile.am (common_source): Add progress.c. * filter.h (progress_filter_context_t): New type. (progress_filter, handle_progress): New prototypes. * main.h (open_sigfile): New argument for prototype. * openfile.c (open_sigfile): New argument to install progress filter. * encode.c (encode_simple): New variable PFX. Register progress filter. Install text_filter after that. (encode_crypt): Likewise. * sign.c (sign_file): Likewise. (clearsign_file): Likewise. * decrypt.c (decrypt_message): Likewise. (decrypt_messages): Likewise. * verify.c (verify_signatures): Likewise. (verify_one_file): Likewise. * plaintext.c (hash_datafiles): Likewise. (ask_for_detached_datafile): Likewise. 2003-04-10 Werner Koch * passphrase.c (read_passphrase_from_fd): Do a dummy read if the agent is to be used. Noted by Ingo Klöcker. (agent_get_passphrase): Inhibit caching when we have no fingerprint. This is required for key generation as well as for symmetric only encryption. * passphrase .c (agent_get_passphrase): New arg CANCELED. (passphrase_to_dek): Ditto. Passed to above. Changed all callers to pass NULL. * seckey-cert.c (do_check): New arg CANCELED. (check_secret_key): Terminate loop when canceled. * keyedit.c (change_passphrase): Pass ERRTEXT untranslated to passphrase_to_dek and translate where appropriate. * seckey-cert.c (check_secret_key): Ditto. * keygen.c (ask_passphrase): Ditto. * passphrase.c (agent_get_passphrase): Translate the TRYAGAIN_TEXT. Switch the codeset to utf-8. 2003-04-09 Werner Koch * decrypt.c (decrypt_messages): Fixed error handling; the function used to re-loop with same file after an error. Reported by Joseph Walton. 2003-04-08 David Shaw * main.h, g10.c (main), import.c (parse_import_options, fix_pks_corruption): It's really PKS corruption, not HKP corruption. Keep the old repair-hkp-subkey-bug command as an alias. * g10.c (main): Rename --no-version to --no-emit-version for consistency. Keep --no-version as an alias. 2003-04-04 David Shaw * pkclist.c (algo_available): PGP 8 can use the SHA-256 hash. * sign.c (sign_file, clearsign_file, sign_symencrypt_file): Remove unused code. 2003-04-01 Werner Koch * mainproc.c (check_sig_and_print): Add primary key fpr to VALIDSIG status. 2003-03-24 David Shaw * keydb.h: Err on the side of making an unknown signature a SIG rather than a CERT. * import.c (delete_inv_parts): Discard any key signatures that aren't key types (i.e. 0x00, 0x01, etc.) * g10.c (main): Add deprecated option warning for --list-ownertrust. Add --compression-algo alias for --compress-algo. Change --version output strings to match "showpref" strings, and make translatable. * status.c (do_get_from_fd): Accept 'y' as well as 'Y' for --command-fd boolean input. * trustdb.c: Fix typo (DISABLE_REGEXP -> DISABLE_REGEX) * keyedit.c (show_key_with_all_names_colon): Show no-ks-modify flag. 2003-03-11 David Shaw * options.h, g10.c (main), keyserver.c (kopts): Add "try-dns-srv" keyserver option. Defaults to on. * passphrase.c (agent_get_passphrase): Fix memory leak with symmetric messages. Fix segfault with symmetric messages. Fix incorrect prompt with symmetric messages. 2003-03-10 Werner Koch * compress.c (init_uncompress): Use a 15 bit window size so that the output of implementations which don't run for PGP 2 compatibility won't get garbled. 2003-03-04 David Shaw * trustdb.c (validate_keys): Mask the ownertrust when building the list of fully valid keys so that disabled keys are still counted in the web of trust. (get_ownertrust_with_min): Do the same for the minimum ownertrust calculation. * parse-packet.c (dump_sig_subpkt): Show the notation names for not-human-readable notations. Fix cosmetic off-by-one length counter. * options.skel: Add explantion and commented-out "no-mangle-dos-filenames". * mainproc.c (proc_encrypted): Make string translatable. * keyserver.c (keyserver_spawn): Quote ':', '%', and any 8-bit characters in the uid strings sent to the keyserver helper. * keyring.c (keyring_rebuild_cache): Lock the keyring while rebuilding the signature caches to prevent another gpg from tampering with the temporary copy. * keygen.c (keygen_set_std_prefs): Include AES192 and AES256 in default prefs. * keyedit.c (show_prefs): Make strings translatable. * keydb.c: Double the maximum number of keyrings to 40. * gpgv.c (main): Fix bug #113 - gpgv should accept the --ignore-time-conflict option. * g10.c (main): --openpgp disables --pgpX. Double the amount of secure memory to 32k (keys are getting bigger these days). * Makefile.am: Makefile.am: Use @CAPLIBS@ to link in -lcap if we are using capabilities. 2003-02-26 David Shaw * keyserver.c (keyserver_spawn): Include various pieces of information about the key in the data sent to the keyserver helper. This allows the helper to use it in instructing a remote server which may not have any actual OpenPGP smarts in parsing keys. * main.h, export.c (export_pubkeys_stream, do_export_stream): Add ability to return only the first match in an exported keyblock for keyserver usage. This should be replaced at some point with a more flexible solution where each key can be armored seperately. 2003-02-22 David Shaw * sign.c (sign_file): Do not push textmode filter onto an unopened IOBUF (segfault). Noted by Marcus Brinkmann. Push and reinitialize textmode filter for each file in a multiple file list. * packet.h, getkey.c (fixup_uidnode), keyedit.c (show_prefs): Set and show the keyserver no-modify flag. * keygen.c (add_keyserver_modify): New. (keygen_upd_std_prefs): Call it here. (keygen_set_std_prefs): Accept "ks-modify" and "no-ks-modify" as prefs to set and unset keyserver modify flag. * g10.c (main): Accept "s1" in addition to "idea" to match the other ciphers. * main.h, misc.c (idea_cipher_warn): We don't need this if IDEA has been disabled. 2003-02-21 David Shaw * keygen.c (keygen_set_std_prefs): Don't put AES or CAST5 in default prefs if they are disabled. * g10.c (main): Use 3DES instead of CAST5 if we don't have CAST5 support. Use 3DES for the s2k cipher in --openpgp mode. (print_mds): #ifdef all of the optional digest algorithms. 2003-02-12 David Shaw * keydb.h, getkey.c (classify_user_id, classify_user_id2): Make 'exact' a per-desc item. Merge into one function since 'force_exact' is no longer needed. (key_byname): Use new classify_user_id function, and new exact flag in KEYDB_SEARCH_DESC. * keyring.h, keyring.c (keyring_search): Return an optional index to show which KEYDB_SEARCH_DESC was the matching one. * keydb.h, keydb.c (keydb_search): Rename to keydb_search2, and pass the optional index to keyring_search. Add a macro version of keydb_search that calls this new function. * export.c (do_export_stream): If the keyid! syntax is used, export only that specified key. If the key in question is a subkey, export the primary plus that subkey only. 2003-02-11 David Shaw * exec.c (set_exec_path): Add debugging line. * g10.c (print_hex, print_mds): Print long hash strings a lot neater. This assumes at least an 80-character display, as there are a few other similar assumptions here and there. Users who need unformatted hashes can still use with-colons. Check that SHA384 and 512 are available before using them as they are no longer always available. * Makefile.am: Use a local copy of libexecdir along with @PACKAGE@ as GNUPG_LIBEXECDIR so it can be easily overridden at make time. 2003-02-04 David Shaw * armor.c (parse_hash_header, armor_filter): Accept the new SHAs in the armor Hash: header. * g10.c (print_hex): Print long hash strings a little neater. (print_mds): Add the new SHAs to the hash list. 2003-02-02 David Shaw * keyedit.c (menu_revuid): Properly handle a nonselfsigned uid on a v4 key (treat as a v4 revocation). * import.c (print_import_check): Do not re-utf8 convert user IDs. 2003-01-27 David Shaw * mainproc.c (list_node): Show signature expiration date in with-colons sig records. * keylist.c (list_keyblock_colon), mainproc.c (list_node): Show trust sig information in with-colons sig records. 2003-01-16 David Shaw * g10.c (add_group): Trim whitespace after a group name so it does not matter where the user puts the = sign. * options.skel: Comment out the first three lines in case someone manually copies the skel file to their homedir. * sign.c (clearsign_file): Only use pgp2mode with v3 keys and MD5. This matches what we do when decoding such messages and prevents creating a message (v3+RIPEMD/160) that we can't verify. * sig-check.c (signature_check2): Use G10ERR_GENERAL as the error for signature digest conflict. BAD_SIGN implies that a signature was checked and we may try and print out a user ID for a key that doesn't exist. 2003-01-15 David Shaw * trustdb.c (init_trustdb, get_validity): Don't use a changed trust model to indicate a dirty trustdb, and never auto-rebuild a dirty trustdb with the "always" trust model. * g10.c (add_group): Last commit missed the \t ;) 2003-01-14 David Shaw * packet.h, parse-packet.c (setup_user_id), free-packet.c (free_user_id), keydb.h, keyid.c (namehash_from_uid): New function to rmd160-hash the contents of a user ID packet and cache it in the uid object. * keylist.c (list_keyblock_colon): Use namehash in field 8 of uids. Show dates for creation (selfsig date), and expiration in fields 6 and 7. * trustdb.c (get_validity, get_validity_counts, update_validity): Use new namehash function rather than hashing it locally. 2003-01-14 Werner Koch * g10.c (add_group): Fixed group parsing to allow more than one delimiter in a row and also allow tab as delimiter. 2003-01-12 David Shaw * tdbio.c (tdbio_set_dbname): Fix assertion failure with non-fully-qualified trustdb names. 2003-01-11 David Shaw * trustdb.c (get_validity_info, get_ownertrust_info, trust_letter): Simplify by returning a ? for error directly. * keyedit.c (show_key_with_all_names): Use get_validity_string and get_ownertrust_string to show full word versions of trust (i.e. "full" instead of 'f'). * trustdb.h, trustdb.c (get_ownertrust_string, get_validity_string): Same as get_ownertrust_info, and get_validity_info, except returns a full string. * trustdb.c (get_ownertrust_with_min): New. Same as 'get_ownertrust' but takes the min_ownertrust value into account. 2003-01-10 David Shaw * armor.c (armor_filter): Comment about PGP's end of line tab problem. * trustdb.h, trustdb.c (trust_letter): Make static. (get_ownertrust_info, get_validity_info): Don't mask the trust level twice. * trustdb.h, gpgv.c, trustdb.c (get_validity, get_validity_info), keylist.c (list_keyblock_colon), keyedit.c (show_key_with_all_names_colon, menu_revuid): Pass a user ID in rather than a namehash, so we only have to do the hashing in one place. * packet.h, pkclist.c (build_pk_list), free-packet.c (release_public_key_parts): Remove unused namehash element for public keys. 2003-01-07 David Shaw * keygen.c (keygen_set_std_prefs): Warn when setting an IDEA preference when IDEA is not available. 2003-01-06 David Shaw * trustdb.c (get_validity_info): 'd' for disabled is not a validity value any more. * packet.h, tdbio.h, tdbio.c (tdbio_read_record, tdbio_write_record), trustdb.c (update_validity): Store temporary full & marginal counts in the trustdb. (clear_validity, get_validity_counts): Return and clear temp counts. (store_validation_status): Keep track of which keyids have been stored. (validate_one_keyblock, validate_key_list): Use per-uid copies of the full & marginal counts so they can be recalled for multiple levels. (validate_keys): Only use unused keys for each new round. (reset_unconnected_keys): Rename to reset_trust_records, and only skip specifically excluded records. * keylist.c (print_capabilities): Show 'D' for disabled keys in capabilities section. * trustdb.c (is_disabled): Remove incorrect comment. 2003-01-03 David Shaw * import.c (import_one): Only do the work to create the status display for interactive import if status is enabled. * keyring.c (keyring_search): skipfnc didn't work properly with non-keyid searches. Noted by Stefan Bellon. * getkey.c (merge_selfsigs_main): Remove some unused code and make sure that the pk selfsigversion member accounts for 1F direct sigs. 2003-01-02 Werner Koch * keydb.c (keydb_add_resource): Don't assume that try_make_homedir terminates but check again for the existence of the directory and continue then. * openfile.c (copy_options_file): Print a warning if the skeleton file has active options. 2002-12-29 David Shaw * getkey.c (merge_selfsigs_main), main.h, sig-check.c (check_key_signature2): Pass the ultimately trusted pk directly to check_key_signature2 to avoid going through the key selection mechanism. This prevents a deadly embrace when two keys without selfsigs each sign the other. 2002-12-27 David Shaw * keyserver.c (keyserver_refresh): Don't print the "refreshing..." line if there are no keys to refresh or if there is no keyserver set. * getkey.c (merge_selfsigs_main): Any valid user ID should make a key valid, not just the last one. This also fixes Debian bug #174276. 2002-12-27 Stefan Bellon * import.c (print_import_check): Changed int to size_t. 2002-12-27 David Shaw * keyedit.c (keyedit_menu, menu_revuid): Add "revuid" feature to revoke a user ID. This is the same as issuing a revocation for the self-signature, but a much simpler interface to do it. 2002-12-26 David Shaw * keydb.h, getkey.c (key_byname): Flag to enable or disable including disabled keys. Keys specified via keyid (i.e. 0x...) are always included. * getkey.c (get_pubkey_byname, get_seckey_byname2, get_seckey_bynames), keyedit.c (keyedit_menu, menu_addrevoker): Include disabled keys in these functions. * pkclist.c (build_pk_list): Do not include disabled keys for -r or the key prompt. Do include disabled keys for the default key and --encrypt-to. * trustdb.h, trustdb.c (is_disabled): New skipfnc for skipping disabled keys. * gpgv.c (is_disabled): Stub. * keygen.c (keygen_add_key_expire): Properly handle updating a key expiration to a no-expiration value. * keyedit.c (enable_disable_key): Comment. * import.c (import_one): When in interactive mode and --verbose, don't repeat some key information twice. 2002-12-22 Timo Schulz * import.c (print_import_check): New. (import_one): Use it here. Use merge_keys_and_selfsig in the interactive mode to avoid wrong key information. * status.h: Add new status code. * status.c: Ditto. 2002-12-13 David Shaw * pkclist.c (do_we_trust): Tweak language to refer to the "named user" rather than "owner". Noted by Stefan Bellon. * trustdb.h, trustdb.c (trustdb_pending_check): New function to check if the trustdb needs a check. * import.c (import_keys_internal): Used here so we don't rebuild the trustdb if it is still clean. (import_one, chk_self_sigs): Only mark trustdb dirty if the key that is being imported has any sigs other than self-sigs. Suggested by Adrian von Bidder. * options.skel: Include the required '=' sign in the sample 'group' option. Noted by Stefan Bellon. * import.c (chk_self_sigs): Don't try and check a subkey as if it was a signature. 2002-12-11 David Shaw * tdbio.c (tdbio_read_record, tdbio_write_record): Compact the RECTYPE_TRUST records a bit. * g10.c (main): Comment out --list-trust-path until it can be implemented. * import.c (import_one): Warn when importing an Elgamal primary that this may take some time (to verify self-sigs). (chk_self_sigs): Try and cache all self-sigs so the keyblock is written to the keyring with a good rich cache. * keygen.c (ask_algo): Make the Elgamal sign+encrypt warning stronger, and remove the RSA sign+encrypt warning. 2002-12-06 Stefan Bellon * options.h: Fixed typo (mangle_dos_names instead of mangle_dos_filenames). 2002-12-05 Werner Koch * g10.c: New options --[no-]mangle-dos-filenames. * options.h (opt): Added mangle-dos-filenames. * openfile.c (open_outfile) [USE_ONLY_8DOT3]: Truncate the filename only when this option is set; this is the default. 2002-12-04 David Shaw * main.h, keyedit.c, keygen.c: Back out previous (2002-12-01) change. Minimal isn't always best. * sign.c (update_keysig_packet): Use the current time rather then a modification of the original signature time. Make sure that this doesn't cause a time warp. * keygen.c (keygen_add_key_expire): Properly handle a key expiration date in the past (use a duration of 0). * keyedit.c (menu_expire): Use update_keysig_packet so any sig subpackets are maintained during the update. * build-packet.c (build_sig_subpkt): Mark sig expired or unexpired when the sig expiration subpacket is added. (build_sig_subpkt_from_sig): Handle making an expiration subpacket from a sig that has already expired (use a duration of 0). * packet.h, sign.c (update_keysig_packet), keyedit.c (menu_set_primary_uid, menu_set_preferences): Add ability to issue 0x18 subkey binding sigs to update_keysig_packet and change all callers. * trustdb.c (validate_keys): Show trust parameters when building the trustdb, and make sure that the version record update was successful. (init_trustdb): If the current parameters aren't what was used for building the trustdb, the trustdb is invalid. * tbio.c (tdbio_db_matches_options): Update to work with new trustdbs. 2002-12-03 David Shaw * tdbio.h, tdbio.c (tdbio_read_record, tdbio_write_record): Store trust model in the trustdb version record. (tdbio_update_version_record): New function to update version record values during a trustdb check or update. (tdbio_dump_record): Show trust model in dump. * trustdb.c (validate_keys): Call tdbio_update_version_record on success so that the correct options are stored in the trustdb. * options.h: rearrange trust models so that CLASSIC is 0 and OPENPGP is 1. * options.h, g10.c (main), encode.c (write_pubkey_enc_from_list), pkclist.c (algo_available), revoke.c (gen_revoke): Add --pgp8 mode. This is basically identical to --pgp7 in all ways except that signing subkeys, v4 data sigs (including expiration), and SK comments are allowed. * getkey.c (finish_lookup): Comment. * main.h, keylist.c (reorder_keyblock), keyedit.c (keyedit_menu): Reorder user ID display in the --edit-key menu to match that of the --list-keys display. * g10.c (add_notation_data): Fix initialization. 2002-12-01 David Shaw * keyedit.c (menu_expire): Don't lose key flags when changing the expiration date of a subkey. This is not the most optimal solution, but it is minimal change on the stable branch. * main.h, keygen.c (do_copy_key_flags): New function to copy key flags, if any, from one sig to another. (do_add_key_expire): New function to add key expiration to a sig. (keygen_copy_flags_add_expire): New version of keygen_add_key_expire that also copies key flags. (keygen_add_key_flags_and_expire): Use do_add_key_expire. * import.c (fix_hkp_corruption): Comment. 2002-11-25 Stefan Bellon * plaintext.c (handle_plaintext) [__riscos__]: If nooutput is set, no filetype is needed obviously. 2002-11-24 David Shaw * main.h, misc.c (default_cipher_algo, default_compress_algo): New. Return the default algorithm by trying --cipher-algo/--compress-algo, then the first item in the pref list, then s2k-cipher-algo or ZIP. * sign.c (sign_file, sign_symencrypt_file), encode.c (encode_simple, encode_crypt): Call default_cipher_algo and default_compress_algo to get algorithms. * g10.c (main): Allow pref selection for compress algo with --openpgp. * mainproc.c (proc_encrypted): Use --s2k-digest-algo for passphrase mangling rather than --digest-algo. * sign.c (hash_for): If --digest-algo is not set, but --personal-digest-preferences is, then use the first hash algorithm in the personal list. If the signing algorithm is DSA, then use the first 160-bit hash algorithm in the personal list. If --pgp2 is set and it's a v3 RSA key, use MD5. * g10.c (main), keydb.c (keydb_add_resource, keydb_locate_writable): Rename --default-keyring as --primary-keyring. Stefan wins the naming contest. 2002-11-23 David Shaw * g10.c (add_notation_data): Disallow notation names that do not contain a '@', unless --expert is set. This is to help prevent people from polluting the (as yet unused) IETF namespace. * main.h: Comments about default algorithms. * photoid.c (image_type_to_string): Comments about 3-letter file extensions. * encode.c (encode_simple), passphrase.c (passphrase_to_dek), sign.c (sign_symencrypt_file): Use --s2k-digest-algo for passphrase mangling rather than --digest-algo. 2002-11-21 David Shaw * keygen.c (keygen_set_std_prefs): Properly handle an empty preference string. * misc.c (string_to_compress_algo): "none" is a bad choice since it conflicts with the "none" in setpref. 2002-11-14 David Shaw * g10.c (main): Allow compression algorithm names as the argument to --compress-algo. The old algorithm names still work for backwards compatibility. * misc.c (string_to_compress_algo): Allow "none" as an alias for "uncompressed". 2002-11-13 Stefan Bellon * getkey.c (get_pubkey_byfprint_fast): Fixed type incompatibility, was unsigned char instead of byte. 2002-11-13 David Shaw * encode.c (encode_simple): Make sure that files larger than about 4G use partial length encoding. This is required because OpenPGP allows only for 32 bit length fields. From Werner on stable branch. * getkey.c (get_pubkey_direct): Renamed to... (get_pubkey_fast): this and made extern. (get_pubkey_byfprint_fast): New. From Werner on stable branch. * keydb.h, import.c (import_one): Use get_pubkey_fast instead of get_pubkey. We don't need a merged key and actually this might lead to recursions. (revocation_present): Likewise for search by fingerprint. From Werner on stable branch. * g10.c (main): Try to create the trustdb even for non-colon-mode list-key operations. This is required because getkey needs to know whether a a key is ultimately trusted. From Werner on stable branch. * exec.c [__CYGWIN32__]: Keep cygwin separate from Mingw32; we don't need it here as it behaves more like a Posix system. From Werner on stable branch. * passphrase.c (agent_get_passphrase): Ditto. From Werner on stable branch. * tdbio.c (MY_O_BINARY): Need binary mode with Cygwin. From Werner on stable branch. * g10.c, gpgv.c (main) [__CYGWIN32__]: Don't get the homedir from the registry. From Werner on stable branch. * keyedit.c (show_key_with_all_names_colon): Make --with-colons --edit display match the validity and trust of --with-colons --list-keys. * passphrase.c (agent_send_all_options): Fix compile warning. * keylist.c (list_keyblock_colon): Validity for subkeys should match that of the primary key, and not that of the last user ID. * getkey.c (merge_selfsigs): Revoked/expired/invalid primary keys carry these facts onto all their subkeys, but only after the subkey has a chance to be marked valid. This is to fix an incorrect "invalid public key" error verifying a signature made by a revoked signing subkey, with a valid unrevoked primary key. 2002-11-09 Werner Koch * passphrase.c (agent_send_all_options): Use tty_get_ttyname to get the default ttyname. 2002-11-07 David Shaw * keyring.h, keyring.c (keyring_register_filename): Return the pointer if a given keyring is registered twice. * keydb.h, keydb.c (keydb_add_resource): Use flags to indicate a default keyring. (keydb_locate_writable): Prefer the default keyring if possible. * g10.c (main): Add --default-keyring option. 2002-11-06 David Shaw * options.h, g10.c (main), trustdb.c (ask_ownertrust): Add --force-ownertrust option for debugging purposes. This allows setting a whole keyring to a given trust during an --update-trustdb. Not for normal use - it's just easier than hitting "4" all the time to test a large trustdb. * pubkey-enc.c (get_session_key): With hidden recipients or try a given passphrase against all secret keys rather than trying all secret keys in turn. Don't if --try-all-secrets or --status-fd is enabled. * passphrase.c (passphrase_to_dek): Mode 1 means do a regular passphrase query, but don't prompt with the key info. * seckey-cert.c (do_check, check_secret_key): A negative ask count means to enable passphrase mode 1. * keydb.h, getkey.c (enum_secret_keys): Add flag to include secret-parts-missing keys (or not) in the list. 2002-11-05 David Shaw * keyserver.c (keyserver_search_prompt): When --with-colons is enabled, don't try and fit the search output to the screen size - just dump the whole list. 2002-11-04 David Shaw * keyserver.c (keyserver_search_prompt): When --with-colons is enabled, just dump the raw keyserver protocol to stdout and don't print the menu. * keyserver.c (show_prompt): Don't show a prompt when command-fd is being used. * trustdb.c (trust_model_string, check_trustdb, update_trustdb, validate_one_keyblock): It's not clear what a trustdb rebuild or check means with a trust model other than "classic" or "openpgp", so disallow this. 2002-11-03 David Shaw * options.h, g10.c (main): Add --trust-model option. Current models are "openpgp" which is classic+trustsigs, "classic" which is classic only, and "always" which is the same as the current option --always-trust (which still works). Default is "openpgp". * trustdb.c (validate_one_keyblock): Use "openpgp" trust model to enable trust sigs. * gpgv.c (main), mainproc.c (check_sig_and_print), pkclist.c (do_we_trust, do_we_trust_pre, check_signatures_trust): Use new --trust-model option in place of --always-trust. * keyedit.c (sign_mk_attrib, trustsig_prompt, sign_uids, keyedit_menu): Prompt for and create a trust signature with "tsign". This is functional, but needs better UI text. * build-packet.c (build_sig_subpkt): Able to build trust and regexp subpackets. * pkclist.c (do_edit_ownertrust): Comment. 2002-11-02 David Shaw * keygen.c (set_one_pref, keygen_set_std_prefs): Allow using the full algorithm name (CAST5, SHA1) rather than the short form (S3, H2). * main.h, keygen.c (keygen_get_std_prefs), keyedit.c (keyedit_menu): Return and use a fake uid packet rather than a string since we already have a nice parser/printer in keyedit.c:show_prefs. * main.h, misc.c (string_to_compress_algo): New. 2002-11-01 David Shaw * g10.c (main): Add --no-throw-keyid. * keydb.h, encode.c (write_pubkey_enc_from_list), g10.c (main), pkclist.c (build_pk_list): Add --hidden-recipient (-R) and --hidden-encrypt-to, which do a single-user variation on --throw-keyid. The "hide this key" flag is carried in bit 0 of the pk_list flags field. * keyserver.c (parse_keyrec): Fix shadowing warning. 2002-10-31 Stefan Bellon * compress.c (init_compress) [__riscos__]: Use riscos_load_module() to load ZLib module. * g10.c (main) [__riscos__]: Renames due to changes in riscos.c (e.g. prefixes all RISC OS specific functions with riscos_*). * photoid.c (show_photos) [__riscos__]: Likewise. * signal.c (got_fatal_signal) [__riscos__]: Likewise. * trustdb.c (check_regexp) [__riscos__]: Branch to RISC OS RegEx handling. 2002-10-31 David Shaw * build-packet.c (do_plaintext), encode.c (encode_sesskey, encode_simple, encode_crypt), sign.c (write_plaintext_packet): Use wipememory() instead of memset() to wipe sensitive memory as the memset() might be optimized away. 2002-10-30 David Shaw * trustdb.c (check_regexp): Modern regexps require REG_EXTENDED. 2002-10-29 David Shaw * packet.h, trustdb.h, trustdb.c (trust_string): New. Return a string like "fully trusted", "marginally trusted", etc. (get_min_ownertrust): New. Return minimum ownertrust. (update_min_ownertrust): New. Set minimum ownertrust. (check_regexp): New. Check a regular epression against a user ID. (ask_ownertrust): Allow specifying a minimum value. (get_ownertrust_info): Follow the minimum ownertrust when returning a letter. (clear_validity): Remove minimum ownertrust when a key becomes invalid. (release_key_items): Release regexp along with the rest of the info. (validate_one_keyblock, validate_keys): Build a trust sig chain while validating. Call check_regexp for regexps. Use the minimum ownertrust if the user does not specify a genuine ownertrust. * pkclist.c (do_edit_ownertrust): Only allow user to select a trust level greater than the minimum value. * parse-packet.c (can_handle_critical): Can handle critical trust and regexp subpackets. * trustdb.h, trustdb.c (clear_ownertrusts), delkey.c (do_delete_key), import.c (import_one): Rename clear_ownertrust to clear_ownertrusts and have it clear the min_ownertrust value as well. * keylist.c (list_keyblock_print): Indent uid to match pub and sig. * keyedit.c (print_and_check_one_sig, show_key_and_fingerprint, menu_addrevoker), keylist.c (list_keyblock_print, print_fingerprint): Show "T" or the trust depth for trust signatures, and add spaces to some strings to make room for it. * packet.h, parse-packet.c (dump_sig_subpkt, parse_one_sig_subpkt, parse_signature): Parse trust signature values. * tdbio.h, tdbio.c (tdbio_read_record, tdbio_write_record): Reserve a byte for the minimum ownertrust value (for use with trust signatures). 2002-10-29 Stefan Bellon * build-packet.c (calc_plaintext, do_plaintext): Removed RISC OS specific filetype parts (it's now done in make_basename()). * plaintext.c (handle_plaintext): Tidied up RISC OS specific filetype parts. * encode.c (encode_simple, encode_crypt): Added argument to make_basename() call. * sign.c (write_plaintext_packet): Added argument to make_basename() call. 2002-10-28 Stefan Bellon * build-packet.c (calc_plaintext, do_plaintext): Added filetype handling for RISC OS' file types. * plaintext.c (handle_plaintext) [__riscos__]: Added filetype handling for RISC OS' file types. 2002-10-23 David Shaw * main.h, import.c (sec_to_pub_keyblock, import_secret_one, parse_import_options), g10.c (main): New import-option "convert-sk-to-pk" to convert a secret key into a public key during import. It is on by default. 2002-10-23 Werner Koch * pubkey-enc.c (get_it): Fix segv, test for revoked only when PK has been assigned. 2002-10-18 Timo Schulz * keylist.c: (print_pubkey_info): New. (print_seckey_info): New. * main.h: Prototypes for the new functions. * delkey.c (do_delete_key): Use it here. * revoke.c (gen_desig_revoke): Ditto. 2002-10-17 Werner Koch * pkclist.c (do_edit_ownertrust): Show all user IDs. This should be enhanced to also show the current trust level. Suggested by Florian Weimer. 2002-10-17 David Shaw * g10.c (main): Handle --strict and --no-strict from the command line before the options file is loaded. 2002-10-15 David Shaw * g10.c (main): Disable --textmode when encrypting (symmetric or pk) in --pgp2 mode as PGP 2 can't handle the unknown length literal packet. Reported by Michael Richardson. 2002-10-14 David Shaw * keyserver-internal.h, keyserver.c (print_keyrec, parse_keyrec, show_prompt, keyserver_search_prompt, keyserver_spawn): Go to version 1 of the keyserver protocol. This is a better design, similar to --with-colons, that allows for keys with multiple user IDs rather than using multiple keys. It also matches the machine readable pksd format. Also use a prettier --search-keys listing format that can fill different size windows (currently set at 24 lines). 2002-10-12 Werner Koch * keygen.c (print_status_key_created): New. (do_generate_keypair): Use it to print the fingerprint. (generate_subkeypair): Likewise. 2002-10-11 David Shaw * keyedit.c (menu_addrevoker): Properly back out if the signature fails. Also, do not allow appointing the same revoker twice, and report ALREADY_SIGNED if the user tries it. 2002-10-07 David Shaw * import.c (import_keys_internal): Missed one s/inp/inp2/. * keylist.c (print_capabilities): Properly indicate per-key capabilities of sign&encrypt primary keys that have secret-parts-missing (i.e. no capabilities at all) * mainproc.c (symkey_decrypt_sesskey): Fix compiler warning. 2002-10-04 David Shaw * getkey.c (get_pubkey_direct): Don't cache keys retrieved via this function as they may not have all their fields filled in. * sig-check.c (signature_check2): Use new is_primary flag to check rather than comparing main_keyid with keyid as this still works in the case of a not fully filled in pk. 2002-10-04 Werner Koch * import.c (import_keys_internal): s/inp/inp2/ to avoid shadowing warning. * passphrase.c (agent_get_passphrase): Fixed signed/unsigned char problem in %-escaping. Noted by Ingo Klöcker. 2002-10-03 David Shaw * options.h, g10.c (main): Add --strict and --no-strict to switch the log_warning severity level from info to error. * keylist.c (print_capabilities): Secret-parts-missing keys should show that fact in the capabilities, and only primary signing keys can certify other keys. * packet.h, parse_packet.c (parse_key): Add is_primary flag for public keys (it already exists for secret keys). 2002-10-02 David Shaw * import.c (import_secret_one): Check for an illegal (>110) protection cipher when importing a secret key. * keylist.c (list_keyblock_print): Show a '#' for a secret-parts-missing key. * parse_packet.c (parse_key): Some comments. * revoke.c (gen_revoke): Remove some debugging code. * trustdb.c (verify_own_keys): Make trusted-key a non-deprecated option again. * seckey-cert.c (do_check): Don't give the IDEA warning unless the cipher in question is in fact IDEA. 2002-10-01 David Shaw * import.c (import_one): Make sure that a newly imported key starts with a clean ownertrust. 2002-10-01 Werner Koch * getkey.c (get_pubkey_direct): New. (merge_selfsigs_main): Use it here to look for an ultimately trusted key. Using the full get_pubkey might lead to an infinitive recursion. 2002-09-29 David Shaw * keyserver.c (parse_keyserver_uri): Force the keyserver URI scheme to lowercase to be case-insensitive. 2002-09-28 David Shaw * export.c (do_export_stream): Comment. * sig-check.c (check_key_signature2): Properly handle a non-designated revocation import. 2002-09-26 Werner Koch * g10.c (set_homedir): New. Changed all direct assignments to use this. * gpgv.c (set_homedir): Ditto. 2002-09-25 David Shaw * Makefile.am: Link gpg with EGDLIBS (i.e. NETLIBS) as EGD uses sockets. Remove the old NETLIBS variable since the keyserver stuff is no longer internal. 2002-09-24 David Shaw * import.c (import_keys_stream): Fix compiler type warning. * keyring.c (keyring_rebuild_cache), sig-check.c (check_key_signature2), import.c (import, chk_self_sigs): Minor language cleanups. 2002-09-23 Stefan Bellon * main.h: Introduced fast-import as import option. Removed fast as separate option from prototypes. * import.c (parse_import_options): Added fast-import option. (import_*): Removed fast as separate option. * g10.c (main): Added option fast-import, removed old fast as separate argument. * keyserver.c (keyserver_spawn): Removed old fast as separate argument. 2002-09-22 Stefan Bellon * import.c (import_keys, import_keys_stream, import_keys_internal): Added trustdb update/check to key import if not fast-import and interactive set/no-auto-check-trustdb unset. Avoided function clone by introducing import_keys_internal. 2002-09-19 David Shaw * keyserver.c (keyserver_spawn): Properly handle line truncation. Don't leak memory (~10-20 bytes) on searches. (keyserver_search_prompt): Cleanup. * keylist.c (list_keyblock_colon): Show 1F direct key signatures in --with-colons listing. 2002-09-16 David Shaw * keyedit.c (menu_addrevoker): The direct key signature for revocation keys must be at least v4 to carry the revocation key subpacket. Add a PGP 2.x warning for revocation keys. 2002-09-14 David Shaw * g10.c (check_permissions): Rearrange strings to make translating easier (don't incorporate string parts). * keyedit.c (sign_uids): Make strings translatable. * sig-check.c (check_key_signature2): Make string translatable. 2002-09-13 David Shaw * getkey.c (check_revocation_keys): Move.... * main.h, sig-check.c (check_revocation_keys): to here. Also return the signature_check error code rather than 0/1 and cache the sig result. * sig-check.c (check_key_signature2): Divert to check_revocation_keys if a revocation sig is made by someone other than the pk owner. * getkey.c (merge_selfsigs_main): Tidy. 2002-09-13 Werner Koch * g10.c (main) [__MINGW32__]: Activate oLoadExtension. 2002-09-12 David Shaw * Makefile.am, hkp.c, hkp.h, keyserver.c (keyserver_work): Remove internal HKP support. * keyserver.c (keyserver_spawn): Remove whitespace after keyserver commands. 2002-09-10 David Shaw * exec.c (expand_args): Remove loop left over from earlier implementation. (exec_write): Missed one tick. 2002-09-10 Werner Koch * g10.c, options.h: Removed option --emulate-checksum-bug. * misc.c (checksum_u16_nobug): Removed. (checksum_u16): Removed the bug emulation. (checksum_mpi): Ditto. (checksum_mpi_counted_nbits): Removed and replaced all calls with checksum_mpi. * parse-packet.c (read_protected_v3_mpi): New. (parse_key): Use it here to store it as an opaque MPI. * seckey-cert.c (do_check): Changed the v3 unprotection to the new why to store these keys. (protect_secret_key): Likewise. * build-packet.c (do_secret_key): And changed the writing. * tdbio.c (tdbio_set_dbname, open_db): Use new macro MY_O_BINARY to avoid silly ifdefs. (open_db): Fallback to RDONLY so that gpg may be used from a RO-medium. * encode.c (encode_simple): Make sure we don't use an ESK packet when we don't have a salt in the S2K. * misc.c (pct_expando) : Make sure that LEN is initialized. * exec.c (exec_finish): Use ticks to denote filenames in messages. (make_tempdir, exec_write): Changed format of messages. * keyserver.c (print_keyinfo): Release USERID in on error. (keyserver_work) [!DISABLE_KEYSERVER_HELPERS]: Exclude the unused code. 2002-09-09 Werner Koch * parse-packet.c (make_attribute_uidname): Add new ar MAX_NAMELEN for sanity checks. Changed both callers. Limit the size of an %s. * options.skel: Comment lock-once out, so that this file does not change anything when copied to a new home directory. * openfile.c (try_make_homedir): Don't exit after copying the option skeleton. * options.h: Don't use a comma when declaring variables over more than one line. * mainproc.c (symkey_decrypt_sesskey): Check length of the session key. * hkp.c (dehtmlize): Use ascii_tolower to protect against weird locales. Cast the argument for isspace for the sake of broken HP/UXes. (parse_hkp_index): s/ascii_memcasecmp/ascii_strncasecmp/. * g10.c: Removed option --emulate-3des-s2k-bug. * passphrase.c (hash_passphrase): Was used here. * export.c (parse_export_options) * keyserver.c (parse_keyserver_options) * import.c (parse_import_options) * g10.c (check_permissions): s/ascii_memcasecmp/ascii_strncasecmp/. 2002-09-09 David Shaw * g10.c (add_group): Use '=' to separate group name from group members. Use a better error message for when no = is found. * hkp.c (hkp_export): Use CRLF in headers. 2002-09-03 David Shaw * mainproc.c (print_pkenc_list): Don't increment the error counter when printing the list of keys a message was encrypted to. This would make gpg give a non-zero exit code even for completely valid messages if the message was encrypted to more than one key that the user owned. 2002-09-02 Werner Koch * g10.c (main): Try to set a default character set. Print the used one in verbosity level 3. * gpgv.c (main): Try to set a default character set. * status.c, status.h (STATUS_IMPORT_OK): New. * import.c (import_one,import_secret_one): Print new status. 2002-08-30 David Shaw * pkclist.c (build_pk_list): Add new status code to indicate an untrusted user. This (or a disabled key) fail with "unavailable pubkey" (G10ERR_UNU_PUBKEY). * pkclist.c (build_pk_list): Fail if any recipient keys are unusable. * options.skel: The PGP LDAP keyserver is back. Use MIT keyserver as a sample rather than cryptnet as cryptnet does not support searching yet. * keyedit.c (show_key_with_all_names): Fix error message (preferences are userid/selfsig and not key specific). 2002-08-30 Werner Koch * pkclist.c (do_we_trust_pre): Changed the wording of a warning. * encode.c (encode_simple,encode_crypt): Use new style CTB for compressssed packets when using MDC. We need to do this so that concatenated messages are properly decrypted. Old style compression assumes that it is the last packet; given that we can't determine the length in advance, the uncompressor does not know where to start. Actually we should use the new CTB always but this would break PGP 2 compatibility. * parse-packet.c (parse): Special treatment for new style CTB compressed packets. * build-packet.c (do_mdc): Removed. Was not used. (do_encrypted_mdc): Count in the version number and the MDC packet. 2002-08-28 David Shaw * sig-check.c (do_check_messages, do_check): Show keyid in error messages. * keyserver.c (print_keyinfo): More readable key listings for --search-keys responses. 2002-08-26 David Shaw * hkp.c (parse_hkp_index, dehtmlize): Move HTML functionality into new "dehtmlize" function. Remove HTML before trying to parse each line from the keyserver. If the keyserver provides key type information in the listing, use it. 2002-08-23 David Shaw * sig-check.c (do_check, do_check_messages): Emit the usual sig warnings even for cached sigs. This also serves to protect against missing a sig expiring while cached. * getkey.c (merge_selfsigs_main): Don't check UID self-sigs twice. 2002-08-22 David Shaw * import.c (clean_subkeys, chk_self_sigs): Merge clean_subkeys into chk_self_sigs. This improves efficiency as the same signatures are not checked multiple times. Clarify when a subkey is revoked (any revocation signature, even if it is dated before the binding signature). * getkey.c (merge_selfsigs_subkey): Subkey revocation comments. * keylist.c (list_one): Stats are only for public key listings. * g10.c (main), options.skel: Default should be include-revoked for keyserver operations. 2002-08-21 Werner Koch * import.c (import_print_stats): Print new non_imported counter which is currently not used because we terminate on errors. 2002-08-20 David Shaw * options.skel: Document no-include-attributes for keyserver-options. * keylist.c, keyedit.c, keyserver.c, sign.c: Some TODOs and comments. * export.c (do_export_stream): Fix noop bug in exporting sensitive revocation keys. * pkclist.c (do_edit_ownertrust): Comment out the option for showing trust paths until it can be implemented. 2002-08-19 Werner Koch * getkey.c (get_user_id_native): Renamed to .. (get_user_id_printable): this. Filter out all dangerous characters. Checked all usages. (get_user_id_string_native): Renamed to.. (get_user_id_string_printable): this. Filter out all dangerous characters. Checked all usages. * keyedit.c (show_basic_key_info): New. * keylist.c (print_fingerprint): New mode 3. * import.c (import_one): Use new function to display the user ID. 2002-08-16 Timo Schulz * g10.c (main): Enable opt.interactive. * import.c (import_one): Ask the user if the key shall be imported when the interactive mode is used. Useful to extract selected keys from a file. 2002-08-16 Werner Koch * seckey-cert.c: Workaround to allow decryption of v3 keys created with a bug in the mpi_get_secure_buffer. 2002-08-14 David Shaw * hkp.c (parse_hkp_index): Properly handle really large keys (5 digit key length) in HKP searches. 2002-08-13 David Shaw * encode.c (encode_simple): Fix problem with using compression algo 2 and symmetric compressed files. * encode.c (encode_simple, encode_crypt): If we are not using a MDC, compress even if a file is already compressed. This is to help against the chosen ciphertext attack. * pkclist.c (select_algo_from_prefs): Fix requested algorithm bug so the request succeeds even if the requested algorithm is not the first found. * cipher.c (write_header), encode.c (use_mdc, encode_simple, encode_crypt, encrypt_filter), g10.c (main): Be more eager to use a MDC. We use a MDC if the keys directly support it, if the keys list AES (any) or TWOFISH anywhere in the prefs, or if the cipher chosen does not have a 64 bit blocksize. 2002-08-08 David Shaw * options.skel: Some language tweaks, and remove the load-extension section for random gatherers. * keyring.c (create_tmp_file, rename_tmp_file): Create tmp files with user-only permissions, but restore the original permissions if the user has something special set. * openfile.c (copy_options_file): Create new options file (gpg.conf) with user-only permissions. * keydb.c (keydb_add_resource): Create new keyrings with user-only permissions. * tdbio.c (tdbio_set_dbname): Create new trustdbs with user-only permissions. 2002-08-07 David Shaw * sig-check.c (signature_check2): Sanity check that the md has a context for the hash that the sig is expecting. This can happen if a onepass sig header does not match the actual sig, and also if the clearsign "Hash:" header is missing or does not match the actual sig. * keyedit.c (menu_revsig): Properly show a uid is revoked without restarting gpg. This is Debian bug 124219, though their supplied patch will not do the right thing. * main.h, tdbio.c (tdbio_set_dbname), misc.c (removed check_permissions), keydb.c (keydb_add_resource), g10.c (main, check_permissions): Significant reworking of the permission check mechanism. The new behavior is to check everything in the homedir by checking the homedir itself. If the user wants to put (possibly shared) keyrings outside the homedir, they are not checked. The options file and any extension files are checked wherever they are, as well as their enclosing directories. This is Debian bug 147760. 2002-08-06 Stefan Bellon * g10.c (main): Use of EXTSEP_S in new gpg.conf string. * openfile.c (copy_options_file): Ditto. 2002-08-06 David Shaw * options.h, g10.c (main), mainproc.c (proc_encrypted): --ignore-mdc-error option to turn a MDC check error into a warning. * encode.c (encode_crypt), g10.c (main), sign.c (sign_file, clearsign_file): Use the same --pgpX warning string everywhere to ease translations. * encode.c (write_pubkey_enc_from_list): Warn when using --throw-keyid with --pgpX. Noted by Vedaal Nistar. * revoke.c (export_minimal_pk, gen_desig_revoke, gen_revoke): Export a minimal pk along with the revocation cert when in --pgpX mode so that PGP can import it. 2002-08-06 Werner Koch * options.skel: Changed comments. * g10.c (main): Try to use "gpg.conf" as default option file. * openfile.c (copy_options_file): Changed name of created file. 2002-08-02 Werner Koch * Makefile.am (LDFLAGS): Removed DYNLINK_LDFLAGS. 2002-07-30 David Shaw * options.h, g10.c (main), mainproc.c (proc_encrypted): Return a decryption failed error if a MDC does not verify. Warn if a MDC is not present (can disable via --no-mdc-warning). * exec.c (exec_write), g10.c (main), keyserver.c (keyserver_spawn): Use new DISABLE_KEYSERVER_PATH rather than FIXED_EXEC_PATH. 2002-07-28 David Shaw * sig-check.c (do_check): Properly validate v4 sigs with no hashed section at all. 2002-07-25 Werner Koch * delkey.c (do_delete_key): Always allow to delete a key in batch mode when specified by fingerprint. Suggested by Enzo Michelangeli. 2002-07-25 David Shaw * keyedit.c (menu_revsig): Change "revsig" to honor selected uids so the user can revoke sigs from particular uids only. * keylist.c (list_keyblock_print): Don't display expired uids in --list-keys unless -v and not --list-sigs (just like revoked uids). * exec.c, export.c, import.c, keyedit.c, keyserver.c, misc.c: "Warning" -> "WARNING" 2002-07-24 David Shaw * main.h, import.c (parse_import_options, fix_hkp_corruption, import_one, delete_inv_parts), g10.c (main): New import-option "repair-hkp-subkey-bug", which repairs as much as possible the HKP mangling multiple subkeys bug. It is on by default for keyserver receives, and off by default for regular --import. * main.h, import.c (import, import_one, delete_inv_parts), hkp.c (hkp_ask_import), keyserver.c (keyserver_spawn): Use keyserver import options when doing keyserver receives. * options.h, exec.h, exec.c (set_exec_path, exec_write), g10.c (main), keyserver.c (keyserver_spawn): If the user does not use "exec-path", completely replace $PATH with GNUPG_LIBEXECDIR before calling the keyserver helper. If the user does use "exec-path", append GNUPG_LIBEXECDIR after the specified path. 2002-07-23 David Shaw * import.c (parse_import_options), export.c (parse_export_options): Fix offset problem with reversed ("no-") meanings. * import.c (delete_inv_parts): Discard subkey signatures (0x18 and 0x28) if found in the userid section of the key. * sig-check.c (signature_check2): Signatures made by invalid subkeys (bad/missing binding sig) are also invalid. * keylist.c (print_fingerprint): Show the primary as well as the secondary key fingerprint in modes 1 & 2. 2002-07-22 David Shaw * options.h, main.h, g10.c (main), import.c (parse_import_options, delete_inv_parts), keyserver.c (parse_keyserver_options): add new --import-options option. The only current flag is "allow-local-sigs". * g10.c (main): Don't disable MDC in pgp7 mode. * options.h, g10.c (main), keyserver.c (parse_keyserver_options): Remove old keyserver-option include-attributes now that there is an export-option for the same thing. * options.h, main.h, export.c (parse_export_options, do_export_stream), g10.c (main): add new --export-options option. Current flags are "include-non-rfc", "include-local-sigs", "include-attributes", and "include-sensitive-revkeys". * options.h, hkp.c (hkp_export), keyserver.c (parse_keyserver_options, keyserver_spawn): try passing unknown keyserver options to export options, and if successful, use them when doing a keyserver --send-key. * build-packet.c (build_sig_subpkt): We do not generate SIGSUBPKT_PRIV_VERIFY_CACHE anymore. * revoke.c (gen_desig_revoke): Lots more comments about including sensitive revkeys along with the revocation sig itself. * keyserver.c (parse_keyserver_options): Simpler implementation that can skip one pass over the options. 2002-07-18 David Shaw * keyedit.c (keyedit_menu, menu_addrevoker): Allow specifying "sensitive" as an argument to an addrevoker command. This sets the 0x40 sensitive revoker flag. * revoke.c (gen_desig_revoke): When generating a designated revocation, include the direct key sig that contains the designated revoker subpacket. This allows sensitive designated revocation subpackets to be exported. Also indicate which revokers are sensitive in the first place. 2002-07-17 David Shaw * keyedit.c (show_key_with_all_names_colon): The 0x40 class bit in a designated revoker means "sensitive", not "local". It's exportable under the right circumstances. * main.h, options.h, export.c (do_export_stream), g10.c (main), hkp.c (hkp_export), keyserver.c (keyserver_spawn: Add a flag to skip attribute packets and their signatures while exporting. This is to accomodate keyservers (pksd again) that choke on attributes. Use keyserver-option "include-attributes" to control it. This defaults to ON (i.e. don't skip). 2002-07-09 David Shaw * options.h, keyserver.c (parse_keyserver_uri, keyserver_spawn, keyserver_work), hkp.c (hkp_ask_import, hkp_export, hkp_search): Use a much more strict reading of RFC-2396 for the keyserver URIs. Specifically, don't try and be smart about checking the value of ":port" so long as it is all digits, and properly handle opaque data (those scheme specific parts that do not start with "//"). 2002-07-04 David Shaw * photoid.c (get_default_photo_command, show_photos): Honor FIXED_PHOTO_VIEWER and DISABLE_PHOTO_VIEWER. * mainproc.c (check_sig_and_print): Use --show-photos to show photos when verifying a sig made by a key with a photo. * keyserver.c (parse_keyserver_uri): Properly parse a URI with no :port section and an empty file path, but with a terminating '/'. (keyserver_work): Honor DISABLE_KEYSERVER_HELPERS. * hkp.c (hkp_ask_import): Display keyserver URI as a URI, but only if verbose. * exec.c, g10.c: USE_EXEC_PATH -> FIXED_EXEC_PATH 2002-07-03 David Shaw * exec.h, exec.c (set_exec_path, exec_write), g10.c (main): If USE_EXEC_PATH is defined at compile time, use it to lock the exec-path and not allow the user to change it. 2002-07-02 David Shaw * options.h, g10.c (main), keyserver.c (keyserver_refresh): Maintain and use the original keyserver URI for cosmetics rather than trying to recreate it when needed. * mainproc.c (check_sig_and_print): Properly disregard expired uids. Make sure that the first uid listed is a real uid and not an attribute (attributes should only be listed in the "aka" section). When there are no valid textual userids, try for an invalid textual userid before using any attribute uid. 2002-07-01 David Shaw * options.skel: Fix a few typos, clarify "group", and remove sample photo viewers for Win32 since they are the defaults now. * parse-packet.c (make_attribute_uidname), keylist.c (dump_attribs): Fix two typecast warnings. * packet.h, build-packet.c (build_attribute_subpkt), exec.c (expand_args), mkdtemp.c (mkdtemp), photoid.c (parse_image_header): Fix some signedness compiler warnings. 2002-07-01 Werner Koch * photoid.c (get_default_photo_command): Also use __MINGW32__ instead of HAVE_DOSISH_SYSTEM. * encode.c (encode_symmetric): Do not use the new encryption code. 2002-06-30 Werner Koch * photoid.c: Use __MINGW32__ to include windows because HAVE_DOSISH_SYSTEM is also set for OS/2 and plain DOS. Provide constant missing in older mingw installations. 2002-06-21 Stefan Bellon * g10.c [__riscos__]: Moved RISC OS specific stuff to util/riscos.c and include/util.h. * gpgv.c [__riscos__]: Likewise. 2002-06-20 David Shaw * keydb.h, pkclist.c (select_algo_from_prefs): Allow passing a suggested algorithm which will be used if available. * encode.c (encode_crypt, encrypt_filter), sign.c (sign_file): Use new select_algo_from_prefs feature to check if forcing an algorithm would violate the recipient preferences. * photoid.c (get_default_photo_command, show_photos): Use different default viewers on different platforms. Currently we have Win 9x, Win NT (2k, xp), Mac OSX, RISC OS, and "everybody else". These are #ifdefs as much as possible to avoid clutter. * g10.c (strusage, build_list), keyedit.c (show_prefs), main.h, misc.c (compress_algo_to_string, check_compress_algo), pkclist.c (algo_available), keygen.c (keygen_set_std_prefs): New algo_to_string and check functions for compress algorithms. 2002-06-20 Werner Koch * misc.c (setsysinfo): Removed a #warning for Alpha's uniligedn trap disabling - it is quite possible that this is a debug relict. 2002-06-20 Stefan Bellon * g10.c [__riscos__]: Added image file system feature. * gpgv.c [__riscos__]: Added image file system feature. * photoid.c (show_photos) [__riscos__]: Set RISC OS filetype of photo id according to MIME type. 2002-06-19 David Shaw * hkp.c (parse_hkp_index): Don't leak memory when failing out of a bad HKP keyserver. * g10.c (add_notation_data): Relax slightly the rules as to what can go into a notation name - 2440 allows "@", for example. 2002-06-17 David Shaw * import.c (clean_subkeys, import_one): Only allow at most 1 binding sig and at most 1 revocation sig on a subkey, as per 2440:11.1. * hkp.c (parse_hkp_index, hkp_search): Error if the keyserver returns an unparseable HKP response. 2002-06-15 David Shaw * keyedit.c (show_key_with_all_names), keylist.c (list_keyblock_print): Show "[expired]" before expired uids. * keyedit.c (show_key_with_all_names_colon), mainproc.c (list_node), keylist.c (list_keyblock_colon): Show flag 'e' for expired user ids. Use "uat" for user attribute packets instead of "uid". Also use ' ' rather than the fake user id string on attributes. * keygen.c (keygen_add_revkey): Remove unused code. * misc.c (check_permissions): Check directory permissions properly - they are not special files. * pkclist.c (expand_id, expand_group, build_pk_list): When expanding groups before building a pk list, inherit flags from the original pre-expanded string. * pubkey-enc.c (is_algo_in_prefs): Don't use prefs from expired uids. 2002-06-14 David Shaw * free-packet.c (copy_signature): Properly copy a signature that carries a revocation key on it. * pkclist.c (expand_id, expand_group, build_pk_list): Groups now work properly when used in the "Enter the user ID" prompt. 2002-06-14 David Shaw * keyedit.c (show_key_with_all_names): Display warning if a user tries to show prefs on a v3 key with a v3 selfsig. * kbnode.c (dump_kbnode): Show if a uid is expired. * import.c (merge_blocks, import_revoke_cert): Show user ID receiving a revocation certificate. * free-packet.c (cmp_user_ids): Properly compare attribute ids. * pkclist.c (expand_groups): Maintain the strlist flags while expanding. Members of an expansion inherit their flags from the expansion key. * options.h, cipher.c (write_header), g10.c (main), keygen.c (keygen_set_std_prefs): remove the personal_mdc flag. It no longer serves a purpose now that the personal preference lists are split into cipher/digest/zip. 2002-06-14 Timo Schulz * skclist.c (is_insecure): Implemented. 2002-06-12 David Shaw * keyserver.c (keyserver_spawn): Properly handle PROGRAM responses when they have a CRLF ending. Noted by Keith Ray. * keyserver.c (keyserver_spawn): Handle CRLF endings from keyserver helpers. Also don't leak the last line worth of memory from the keyserver response. * main.h, misc.c (deprecated_warning): New function to warn about deprecated options and commands. * g10.c (main), keyserver-internal.h, keyserver.c (parse_keyserver_uri): Use new deprecated function to warn about honor-http-proxy, auto-key-retrieve, and x-broken-hkp. 2002-06-11 David Shaw * Makefile.am: link gpg with NETLIBS for the built-in HKP access. 2002-06-10 David Shaw * options.h, keyserver.c (keyserver_opts), g10.c (main): New keyserver option "include-subkeys". This feature already existed, but now can be turned off. It defaults to on. * options.h, keyserver.c (parse_keyserver_options, keyserver_spawn): There are now enough options to justify making a structure for the keyserver options rather than a page of if-then-else-if-then-etc. * getkey.c (merge_keys_and_selfsig, merge_selfsigs_main): Fix bug in calculating key expiration dates. 2002-06-09 David Shaw * keydb.h, getkey.c (get_user_id_native), import.c (import_one): Display user ID while importing a key. Note this applies to both --import and keyserver --recv-keys. * exec.c (exec_finish): Log unnatural exit (core dump, killed manually, etc) for fork/exec/pipe child processes. 2002-06-08 Timo Schulz * encode.c (encode_symmetric): Disable the compat flag when the expert mode is enabled. 2002-06-07 David Shaw * options.skel, options.h, main.h, keydb.h, pkclist.c (build_pk_list, expand_groups), g10.c (main, add_group): Add new "group" command to allow one name to expand into multiple keys. For simplicity, and to avoid potential loops, we only expand once - you can't make an alias that points to an alias. * main.h, g10.c (main), keygen.c (build_personal_digest_list): Simplify the default digest list - there is really no need for the other hashes since they will never be used after SHA-1 in the list. * options.skel, options.h, g10.c (main), hkp.c (hkp_ask_import, hkp_export, hkp_search), keyserver.c (parse_keyserver_options, parse_keyserver_uri, keyserver_work, keyserver_refresh): Make the "x-broken-hkp" keyserver scheme into keyserver-option "broken-http-proxy". Move honor_http_proxy into keyserver_options. Canonicalize the three variations of "hkp", "x-hkp", and "x-broken-hkp" into "hkp". 2002-06-07 Stefan Bellon * g10.c [__riscos__]: Added --attribute-file to do the same as --attribute-fd, but with a filename not a fd as argument. Added magic symbol for RISC OS to use different memory management. * gpgv.c [__riscos__]: Added magic symbol for RISC OS to use different memory management. 2002-06-06 David Shaw * main.h, g10.c (main), keygen.c (build_personal_digest_list): Put in a default digest preference list consisting of SHA-1, followed by every other installed digest except MD5. Note this is the same as having no digest preference at all except for SHA-1 being favored. * options.h, g10.c (main), keygen.c (keygen_set_std_prefs), pkclist.c (select_algo_from_prefs): Split --personal-preference-list into three: --personal-{cipher|digest|compress}-preferences. This allows a user to set one without affecting another (i.e. setting only a digest pref doesn't imply an empty cipher pref). * exec.c (exec_read): This is a safer way of guessing the return value of system(). Noted by Stefan Bellon. 2002-06-05 David Shaw * hkp.c (parse_hkp_index): Be more robust with keyservers returning very unparseable responses. * exec.c (exec_read): Catch and display an error when the remote process exits unnaturally (i.e. segfault) so the user knows what happened. Also fix exec_write stub which has a different number of arguments now. 2002-06-05 Timo Schulz * encode.c (encode_simple): Ignore the new mode for RFC1991. * mainproc.c (symkey_decrypt_sesskey): Better check for weird keysizes. 2002-06-05 Timo Schulz * encode.c (encode_sesskey): New. (encode_simple): Use it here. But by default we use the compat mode which supress to generate encrypted session keys. 2002-06-05 Timo Schulz * mainproc.c (symkey_decrypt_sesskey): New. (proc_symkey_enc): Support for encrypted session keys. 2002-06-04 David Shaw * sign.c (hash_for, sign_file): When encrypting and signing at the same time, consult the various hash prefs to pick a hash algorithm to use. Pass in a 160-bit hint if any of the signing keys are DSA. * keydb.h, pkclist.c (select_algo_from_prefs, algo_available): Pass a "hints" opaque pointer in to let the caller give hints as to what algorithms would be acceptable. The only current hint is for PREFTYPE_HASH to require a 160-bit hash for DSA. Change all callers in encode.c (encode_crypt, encrypt_filter) and sign.c (sign_file). If we settle on MD5 as the best algorithm based solely on recepient keys and SHA1 is also a possibility, use SHA1 unless the user intentionally chose MD5. This is as per 2440:13. * exec.c (make_tempdir): Fix duplicated filename problem. 2002-06-03 David Shaw * packet.h, parse-packet.c (enum_sig_subpkt): Report back from enum_sig_subpkt when a subpacket is critical and change all callers in keylist.c (show_policy_url, show_notation), mainproc.c (print_notation_data), and pkclist.c (do_show_revocation_reason). * keylist.c (show_policy_url, show_notation): Display if the policy or notation is critical. 2002-06-03 David Shaw * main.h, g10.c (main), keylist.c (dump_attribs, set_attrib_fd, list_keyblock_print, list_keyblock_colon), status.h, status.c (get_status_string): New --attribute-fd feature to dump the contents of attribute subpackets for frontends. If --status-fd is also used, then a new status tag ATTRIBUTE is provided for each subpacket. * packet.h, getkey.c (fixup_uidnode, merge_selfsigs_main, merge_selfsigs_subkey), parse-packet.c (setup_user_id): Keep track of the expiration time of a user ID, and while we're at it, use the expired flag from the selfsig rather than reparsing the SIG_EXPIRE subpacket. * photoid.c (generate_photo_id): When adding a new photo ID, showing the photo for confirmation is not safe when noninteractive since the "user" may not be able to dismiss a viewer window. Noted by Timo Schulz. 2002-06-03 David Shaw * options.skel: Sample photo viewers for Win32. * misc.c (pct_expando): Use the seckey for %k/%K if the pubkey is not available. * photoid.h, photoid.c (show_photos): Include the seckey in case a user tries to view a photo on a secret key, and change all callers in keyedit.c (menu_showphoto), keylist.c (list_keyblock_print), and photoid.c (generate_photo_id). 2002-06-02 David Shaw * photoid.c (show_photos): Work properly when not called with a public key. 2002-05-31 David Shaw * sign.c (mk_notation_and_policy): Free unneeded buffer. * hkp.c (parse_hkp_index): Properly handle the '&' character (i.e. "&") in HKP responses. * getkey.c (merge_selfsigs_main): Fix reversed expiration time check with self-sigs. * keyedit.c (sign_uids): When making a new self-sig on a v3 key, make a v3 self-sig unless it is currently a v3 self-sig being promoted to v4. 2002-05-31 Timo Schulz * pkclist.c (do_show_revocation_reason): Don't use capital letters for non-interactive output. (show_revocation_reason): Now it is global. * pubkey-enc.c (get_it): Show if the key has been revoked. 2002-05-30 David Shaw * sign.c (write_signature_packets, sign_file, clearsign_file, sign_symencrypt_file): Make a v4 signature if a policy URL or notation is set, unless v3 sigs are forced via rfc1991 or force-v3-sigs. Also remove some doubled code and clarify an error message (we don't sign in PGP2 mode - just detach-sign). * parse-packet.c (parse_one_sig_subpkt): Add KS_FLAGS to the "any size" section. 2002-05-29 David Shaw * keygen.c (keygen_set_std_prefs, add_feature_mdc): Use "mdc" and "no-mdc" in the prefs string to allow switching on and off the MDC feature. This is needed to properly export a key from GnuPG for use on PGP which does not support MDC - without this, MDC-capable implementations will still try and generate MDCs which will break PGP. * keygen.c (keygen_get_std_prefs): Show "[mdc]" in prefs string if it is enabled. * options.h, g10.c (main), cipher.c (write_header), keygen.c (keygen_set_std_prefs): For consistency, allow the user to specify mdc/no-mdc in the --personal-preference-list. If disabled, it acts just like --disable-mdc. 2002-05-29 David Shaw * options.h, exec.c: Add some debugging info, using the 1024 debug flag. * exec.c (win_system): New system()-like function for win32 that does not return until the child process terminates. Of course, this doesn't help if the process itself exits before it is finished. 2002-05-29 Werner Koch * encode.c (encode_simple): Intialize PKT when --no-literal is used. * keyedit.c (show_key_with_all_names_colon): Renamed the record for revocation keys to "rvk". 2002-05-27 Werner Koch * keyedit.c (show_key_with_all_names_colon): New. (show_key_with_all_names): Divert to new function when required. Sanitize printing of revoker name. 2002-05-27 David Shaw * build-packet.c (build_sig_subpkt): Handle setting sig flags for certain subpacket types (notation, policy url, exportable, revocable). keyedit.c (sign_mk_attrib): Flags no longer need to be set here. * packet.h, parse-packet.c (parse_one_sig_subpkt), build-packet.c (build_sig_subpkt): Call parse_one_sig_subpkt to sanity check buffer lengths before building a sig subpacket. 2002-05-26 David Shaw * sign.c (mk_notation_and_policy): Include secret key to enable %s expandos, and pass notations through pct_expando as well. * main.h, misc.c (pct_expando): Add %s and %S expandos for signer's keyid. 2002-05-25 David Shaw * g10.c (strusage, build_list): Add compress algorithms to --version list. Show algorithm numbers when --verbose --version is done. 2002-05-22 David Shaw * options.h, main.h, keygen.c (keygen_set_set_prefs, keygen_get_std_prefs, keygen_upd_std_prefs), keyedit.c (keyedit_menu), g10.c (main), pkclist.c (select_algo_from_prefs): Add --personal-preference-list which allows the user to factor in their own preferred algorithms when the preference lists are consulted. Obviously, this does not let the user violate a recepient's preferences (and the RFC) - this only influences the ranking of the agreed-on (and available) algorithms from the recepients. Suggested by David Hollenberg. * options.h, keygen.c (keygen_set_std_prefs), g10.c (main): Rename --preference-list to --default-preference-list (as that is what it really is), and make it a true default in that if the user selects "default" they get this list and not the compiled-in list. 2002-05-22 Werner Koch * g10.c (main): Add missing LF in a info printout and made it translatable. Noted by Michael Tokarev. 2002-05-21 Werner Koch * g10.c (main): Removed the undef of USE_SHM_COPROCESSING which was erroneously introduced on 2002-01-09. * signal.c (got_fatal_signal): Don't write the Nul to stderr. Reported by David Hollenberg. 2002-05-18 David Shaw * main.h, g10.c (main), revoke.c (gen_desig_revoke): Generate a designated revocation via --desig-revoke * keyedit.c (keyedit_menu, menu_addrevoker): New "addrevoker" command to add a designated revoker to a key. 2002-05-17 David Shaw * gpgv.c: Add stub for get_ownertrust(). * g10.c (main): --allow-freeform-uid should be implied by OpenPGP. Add --no-allow-freeform-uid. * keyedit.c (sign_uids): Issue a warning when signing a non-selfsigned uid. * getkey.c (merge_selfsigs_main): If a key has no selfsigs, and allow-non-selfsigned-uid is not set, still try and make the key valid by checking all uids for a signature from an ultimately trusted key. 2002-05-16 David Shaw * main.h, keygen.c (keygen_add_revkey): Add revocation key subpackets to a signature (callable by make_keysig_packet). (write_direct_sig): Write a 1F direct key signature. (parse_revocation_key): Parse a string in algo:fpr:sensitive format into a revocation key. (get_parameter_revkey, do_generate_keypair): Call above functions when prompted from a batch key generation file. * build-packet.c (build_sig_subpkt): Allow multiple revocation key subpackets in a single sig. * keydb.h, getkey.c (get_seckey_byfprint): Same as get_pubkey_byfprint, except for secret keys. We only know the fingerprint of a revocation key, so this is needed to retrieve the secret key needed to issue a revokation. * packet.h, parse-packet.c (parse_signature, parse_revkeys): Split revkey parsing off into a new function that can be used to reparse after manipulating the revkey list. * sign.c (make_keysig_packet): Ability to make 1F direct key signatures. 2002-05-15 David Shaw * options.skel: keyserver.pgp.com is gone, so list pgp.surfnet.nl as a sample LDAP server instead. * getkey.c (merge_selfsigs_main): Properly handle multiple revocation keys in a single packet. Properly handle revocation keys that are in out-of-order packets. Remove duplicates in revocation key list. 2002-05-14 Timo Schulz * exec.c (make_tempdir) [MINGW32]: Added missing '\'. 2002-05-14 Stefan Bellon * exec.c (make_tempdir): Make use of EXTSEP_S instead of hardcoded dot as extension separator. 2002-05-13 David Shaw * photoid.c (show_photos): Use the long keyid as the filename for the photo. Use the short keyid as the filename on 8.3 systems. * exec.h, exec.c (make_tempdir, exec_write, exec_finish): Allow caller to specify filename. This should make things easier on windows and macs where the file extension is required, but a whole filename is even better. * keyedit.c (show_key_with_all_names, show_prefs): Show proper prefs for a v4 key uid with no selfsig at all. * misc.c (check_permissions): Don't check permissions on non-normal files (pipes, character devices, etc.) 2002-05-11 Werner Koch * mainproc.c (proc_symkey_enc): Avoid segv in case the parser encountered an invalid packet. * keyserver.c (keyserver_export): Get confirmation before sending all keys. 2002-05-10 Stefan Bellon * g10.c, hkp.c, keyedit.c, keyserver.c: Replaced all occurrances of strcasecmp with ascii_strcasecmp and all occurrances of strncasecmp with ascii_memcasecmp. 2002-05-10 David Shaw * packet.h, getkey.c (fixup_uidnode), keyedit.c (show_prefs): Show assumed prefs for hash and compression as well as the cipher pref. Show assumed prefs if there are no prefs at all on a v4 self-signed key. * options.h, g10.c (main), sign.c (make_keysig_packet): New --cert-digest-algo function to override the default key signing hash algorithm. 2002-05-09 David Shaw * getkey.c (merge_selfsigs_main): Make sure the revocation key list starts clean as this function may be called more than once (e.g. from functions in --edit). * g10.c, encode.c (encode_crypt), sign.c (sign_file, sign_symencrypt_file): Make --compress-algo work like the documentation says. It should be like --cipher-algo and --digest-algo in that it can override the preferences calculation and impose the setting the user wants. No --compress-algo setting allows the usual preferences calculation to take place. * main.h, compress.c (compress_filter): use new DEFAULT_COMPRESS_ALGO define, and add a sanity check for compress algo value. 2002-05-08 David Shaw * pkclist.c (select_algo_from_prefs): There is an assumed compression preference for uncompressed data. 2002-05-07 David Shaw * options.h, g10.c (main), getkey.c (finish_lookup), pkclist.c (algo_available): --pgp7, identical to --pgp6 except that it permits a few algorithms that PGP 7 added: AES128, AES192, AES256, and TWOFISH. Any more of these --pgpX flags, and it'll be time to start looking at a generic --emulate-pgp X option. * export.c (do_export_stream): Warn the user when exporting a secret key if it or any of its secret subkeys are protected with SHA1 while simple_sk_checksum is set. * parse-packet.c (parse_key): Show when the SHA1 protection is used in --list-packets. * options.h, build-packet.c (do_comment), g10.c (main): Rename --no-comment as --sk-comments/--no-sk-comments (--no-comment still works) and make the default be --no-sk-comments. 2002-05-07 Werner Koch * keygen.c (get_parameter_algo): Never allow generation of the deprecated RSA-E or RSA-S flavors of PGP RSA. (ask_algo): Allow generation of RSA sign and encrypt in expert mode. Don't allow ElGamal S+E unless in expert mode. * helptext.c: Added entry keygen.algo.rsa_se. 2002-05-07 David Shaw * keyedit.c (sign_uids): If --expert is set, allow re-signing a uid to promote a v3 self-sig to a v4 one. This essentially deletes the old v3 self-sig and replaces it with a v4 one. * packet.h, parse-packet.c (parse_key), getkey.c (merge_keys_and_selfsig, merge_selfsigs_main): a v3 key with a v4 self-sig must never let the v4 self-sig express a key expiration time that extends beyond the original v3 expiration time. 2002-05-06 David Shaw * keyedit.c (sign_uids): When making a self-signature via "sign" don't ask about sig level or expiration, and include the usual preferences and such for v4 self-sigs. (menu_set_preferences): Convert uids from UTF8 to native before printing. * keyedit.c (sign_uids): Convert uids from UTF8 to native before printing. (menu_set_primary_uid): Show error if the user tries to make a uid with a v3 self-sig primary. 2002-05-05 David Shaw * import.c (import_one): When merging with a key we already have, don't let a key conflict (same keyid but different key) stop the import: just skip the bad key and continue. * exec.c (make_tempdir): Under Win32, don't try environment variables for temp directories - GetTempDir tries environment variables internally, and it's better not to second-guess it in case MS adds some sort of temp dir handling to Windows at some point. 2002-05-05 Timo Schulz * mainproc.c (proc_symkey_enc): Don't ask for a passphrase in the list only mode. 2002-05-05 David Shaw * keyserver.c (keyserver_refresh): --refresh-keys implies --merge-only so as not to import keys with keyids that match the ones being refreshed. Noted by Florian Weimer. 2002-05-04 Stefan Bellon * free-packet.c (copy_public_key): Don't call m_alloc(0), therefore added consistency check for revkey and numrefkeys. * getkey.c (check_revocation_keys): Added consistency check for revkey and numrefkeys. * keyedit.c (show_key_with_all_names): Likewise. 2002-05-03 David Shaw * photoid.c: Provide default image viewer for Win32. * misc.c (pct_expando): %t means extension, not name ("jpg", not "jpeg"). * keyserver.c (keyserver_spawn), photoid.c (show_photos), exec.h, exec.c: Allow the caller to determine the temp file extension when starting an exec_write and change all callers. * keyedit.c (sign_uids): Nonrevocable key signatures cause an automatic promotion to v4. * exec.c: Provide stubs for exec_ functions when NO_EXEC is defined. 2002-05-02 David Shaw * photoid.h, photoid.c (parse_image_header, image_type_to_string): Useful functions to return data about an image. * packet.h, parse-packet.c (make_attribute_uidname, parse_attribute_subpkts, parse_attribute), photoid.h, photoid.c (show_photos): Handle multiple images in a single attribute packet. * main.h, misc.c (pct_expando), sign.c (mk_notation_and_policy), photoid.c (show_photos): Simpler expando code that does not require using compile-time string sizes. Call image_type_to_string to get image strings (i.e. "jpg", "image/jpeg"). Change all callers. * keyedit.c (menu_showphoto), keylist.c (list_keyblock_print): Allow viewing multiple images within a single attribute packet. * gpgv.c: Various stubs for link happiness. 2002-05-02 David Shaw * build-packet.c (build_sig_subpkt), keyedit.c (sign_uids), options.h, sign.c (mk_notation_and_policy), g10.c (main, add_notation_data, add_policy_url (new), check_policy_url (removed)): Allow multiple policy URLs on a given signature. Split "--notation-data" into "--cert-notation" and "--sig-notation" so the user can set different policies for key and data signing. For backwards compatibility, "--notation-data" sets both, as before. 2002-05-02 Werner Koch * options.skel: Removed the comment on trusted-keys because this option is now deprecated. 2002-05-01 David Shaw * keyedit.c (menu_adduid): 2440bis04 says that multiple attribute packets on a given key are legal. * keyserver.c (keyserver_refresh): the fake v3 keyid hack applies to "mailto" URLs as well since they are also served by pksd. 2002-04-29 Werner Koch Added a copyright year for files changed this year. 2002-04-25 Werner Koch * g10.c, options.h: New options --display, --ttyname, --ttytype, --lc-ctype, --lc-messages to be used with future versions of the gpg-agent. * passphrase.c (agent_send_option,agent_send_all_options): New. (agent_open): Send options to the agent. * trustdb.c (update_ownertrust, clear_ownertrust): Do an explicit do_sync because revalidation_mark does it only if when the timestamp actually changes. 2002-04-23 David Shaw * main.h, keygen.c (do_generate_keypair), keylist.c (print_signature_stats, list_all, list_one, list_keyblock, list_keyblock_print, list_keyblock_colon): After generating a new key, show the key information (name, keyid, fingerprint, etc.) Also do not print uncheckable signatures (missing key..) in --check-sigs. Print statistics (N missing keys, etc.) after --check-sigs. * keyedit.c (sign_uids): When signing a key with an expiration date on it, the "Do you want your signature to expire at the same time?" question should default to YES. 2002-04-22 David Shaw * parse-packet.c (parse_plaintext), packet.h, plaintext.c (handle_plaintext): Fix bug in handling literal packets with zero-length data (no data was being confused with partial body length). * misc.c (pct_expando), options.skel: %t means extension ("jpg"). %T means MIME type ("image/jpeg"). * import.c (import_one): Only trigger trust update if the keyring is actually changed. * export.c (do_export_stream): Missing a m_free. 2002-04-22 Stefan Bellon * keyid.c (expirestr_from_sk, expirestr_from_sig): Added _() to string constant. * exec.c (make_tempdir) [__riscos__]: Better placement of temporary file. 2002-04-20 David Shaw * keygen.c (generate_subkeypair): 2440bis04 adds that creating subkeys on v3 keys is a MUST NOT. * getkey.c (finish_lookup): The --pgp6 "use the primary key" behavior should only apply while data signing and not encryption. Noted by Roger Sondermann. 2002-04-19 Werner Koch * keygen.c (keygen_set_std_prefs): Put back 3DES because the RFC says it is good form to do so. 2002-04-19 David Shaw * keyedit.c (menu_deluid): Only cause a trust update if we delete a non-revoked user id. * hkp.c (hkp_ask_import), keyserver.c (parse_keyserver_options, keyserver_spawn), options.h: Remove fast-import keyserver option (no longer meaningful). * g10.c (main), keyedit.c (sign_uids), options.h: Change --default-check-level to --default-cert-check-level as it makes clear what it operates on. * g10.c (main): --pgp6 also implies --no-ask-sig-expire. * delkey.c (do_delete_key): Comment. * keyedit.c (sign_uids, keyedit_menu, menu_deluid, menu_delsig, menu_expire, menu_revsig, menu_revkey): Only force a trustdb check if we did something that changes it. * g10.c: add "--auto-check-trustdb" to override a "--no-auto-check-trustdb" 2002-04-19 Werner Koch * tdbio.c (tdbio_write_nextcheck): Return a status whether the stamp was actually changed. * trustdb.c (revalidation_mark): Sync the changes. Removed the sync operation done by its callers. (get_validity): Add logic for maintaining a pending_check flag. (clear_ownertrust): New. * keyedit.c (sign_uids): Don't call revalidation_mark depending on primary_pk. (keyedit_menu): Call revalidation_mark after "trust". (show_key_with_all_names): Print a warning on the wrong listed key validity. * delkey.c (do_delete_key): Clear the owenertrust information when deleting a public key. 2002-04-18 Werner Koch * seskey.c (encode_md_value): Print an error message if a wrong digest algorithm is used with DSA. Changed all callers to cope with a NULL return. Problem noted by Imad R. Faiad. 2002-04-18 David Shaw * trustdb.c (mark_usable_uid_certs): Properly handle nonrevocable signatures that can expire. In short, the only thing that can override an unexpired nonrevocable signature is another unexpired nonrevocable signature. * getkey.c (finish_lookup): Always use primary signing key for signatures when --pgp6 is on since pgp6 and 7 do not understand signatures made by signing subkeys. 2002-04-18 Werner Koch * trustdb.c (validate_keys): Never schedule a nextcheck into the past. (validate_key_list): New arg curtime use it to set next_expire. (validate_one_keyblock): Take the current time from the caller. (clear_validity, reset_unconnected_keys): New. (validate_keys): Reset all unconnected keys. * getkey.c (premerge_public_with_secret): Fixed 0x12345678! syntax for use with secret keys. (lookup): Advance the searchmode after a search FIRST. * seckey-cert.c (do_check): Always calculate the old checksum for use after unprotection. * g10.c, options.skel: New option --no-escape-from. Made --escape-from and --force-v3-sigs the default and removed them from the options skeleton. 2002-04-16 Werner Koch * parse-packet.c (parse_key): Support a SHA1 checksum as per draft-rfc2440-bis04. * packet.h (PKT_secret_key): Add field sha1chk. * seckey-cert.c (do_check): Check the SHA1 checksum (protect_secret_key): And create it. * build-packet.c (do_secret_key): Mark it as sha-1 protected. * g10.c, options.h: New option --simple-sk-checksum. 2002-04-13 David Shaw * parse-packet.c (parse_signature): Minor fix - signatures should expire at their expiration time and not one second later. * keygen.c (proc_parameter_file): Allow specifying preferences string (i.e. "s5 s2 z1 z2", etc) in a batchmode key generation file. * keyedit.c (keyedit_menu): Print standard error message when signing a revoked key (no new translation). * getkey.c (merge_selfsigs): Get the default set of key prefs from the real (not attribute) primary uid. 2002-04-12 David Shaw * pkclist.c (build_pk_list): Fix bug that allowed a key to be selected twice in batch mode if one instance was the default recipient and the other was an encrypt-to. Noted by Stefan Bellon. * parse-packet.c (dump_sig_subpkt): Show data in trust and regexp sig subpackets. * keyedit.c (keyedit_menu): Use new function real_uids_left to prevent deleting the last real (i.e. non-attribute) uid. Again, according to the attribute draft. (menu_showphoto): Make another string translatable. 2002-04-11 David Shaw * build-packet.c (build_sig_subpkt): Delete subpackets from both hashed and unhashed area on update. (find_subpkt): No longer needed. * keyedit.c (sign_uids): With --pgp2 on, refuse to sign a v3 key with a v4 signature. As usual, --expert overrides. Try to tweak some strings to a closer match so they can all be translated in one place. Use different helptext keys to allow different help text for different questions. * keygen.c (keygen_upd_std_prefs): Remove preferences from both hashed and unhashed areas if they are not going to be used. 2002-04-10 David Shaw * misc.c (pct_expando), options.skel: Use %t to indicate type of a photo ID (in this version, it's always "jpeg"). Also tweak string expansion loop to minimize reallocs. * mainproc.c (do_check_sig): Variable type fix. * keyedit.c (menu_set_primary_uid): Differentiate between true user IDs and attribute user IDs when making one of them primary. That is, if we are making a user ID primary, we alter user IDs. If we are making an attribute packet primary, we alter attribute packets. This matches the language in the latest attribute packet draft. * keyedit.c (sign_uids): No need for the empty string hack. * getkey.c (fixup_uidnode): Only accept preferences from the hashed segment of the self-sig. 2002-04-10 Werner Koch * tdbio.c (migrate_from_v2): Fixed the offset to read the old ownertrust value and only add entries to the table if we really have a value. 2002-04-08 David Shaw * status.h, status.c (get_status_string): Add KEYEXPIRED, EXPSIG, and EXPKEYSIG. Add "deprecated-use-keyexpired-instead" to SIGEXPIRED. * sig-check.c (do_check): Start transition from SIGEXPIRED to KEYEXPIRED, since the actual event is signature verification by an expired key and not an expired signature. (do_signature_check, packet.h): Rename as signature_check2, make public, and change all callers. * mainproc.c (check_sig_and_print, do_check_sig): Use status EXPSIG for an expired, but good, signature. Add the expiration time (or 0) to the VALIDSIG status line. Use status KEYEXPSIG for a good signature from an expired key. * g10.c (main): remove checks for no arguments now that argparse does it. 2002-04-06 Werner Koch * keyring.c (keyring_get_keyblock): Disable the keylist mode here. * encode.c (encode_simple, encode_crypt): Only test on compressed files if a compress level was not explicity set. * keygen.c (keygen_set_std_prefs): Removed Blowfish and Twofish from the list of default preferences, swapped the preferences of RMD160 and SHA1. Don't include a preference to 3DES unless the IDEA kludge gets used. * free-packet.c (free_packet): call free_encrypted also for PKT_ENCRYPTED_MDC. * compress.c (release_context): New. (handle_compressed): Allocate the context and setup a closure to release the context. This is required because there is no guarantee that the filter gets popped from the chain at the end of the function. Problem noted by Timo and probably also the cause for a couple of other reports. (compress_filter): Use the release function if set. * tdbio.c [__CYGWIN32__]: Don't rename ftruncate. Noted by Disastry. * parse-packet.c (parse_signature): Put parens around a bit test. * exec.c (make_tempdir): Double backslash for TMP directory creation under Windows. Better strlen the DIRSEP_S constants for allocation measurements. * decrypt.c (decrypt_messages): Release the passphrase aquired by get_last_passphrase. 2002-04-02 Werner Koch * Makefile.am (EXTRA_DIST): Removed OPTIONS an pubring.asc - they are no longer of any use. 2002-04-03 David Shaw * keyserver.c (parse_keyserver_options): fix auto-key-retrieve to actually work as a keyserver-option (noted by Roger Sondermann). * keylist.c (reorder_keyblock): do not reorder the primary attribute packet - the first user ID must be a genuine one. 2002-03-31 David Shaw * keylist.c (list_keyblock_colon): Fix ownertrust display with --with-colons. * keygen.c (generate_user_id), photoid.c (generate_photo_id): Properly initialize the user ID refcount. A few more "y/n" -> "y/N" in photoid.c. * keyedit.c (ask_revoke_sig): Warn the user if they are about to revoke an expired sig (not a problem, but they should know). Also tweak a few prompts to change "y/n" to "y/N", which is how most other prompts are written. * keyserver.c (keyserver_search_prompt): Control-d escapes the keyserver search prompt. * pkclist.c (show_revocation_reason & callers): If a subkey is considered revoked solely because the parent key is revoked, print the revocation reason from the parent key. * trustdb.c (get_validity): Allow revocation/expiration to apply to a uid/key with no entry in the trustdb. 2002-03-29 David Shaw * keyserver.c (printunquoted): unquote backslashes from keyserver searches * hkp.c (write_quoted): quote backslashes from keyserver searches 2002-03-26 Werner Koch * keygen.c (ask_keysize): Removed the warning for key sizes > 1536. 2002-03-25 Werner Koch * keyedit.c (sign_uids): Use 2 strings and not a %s so that translations can be done the right way. * helptext.c: Fixed small typo. 2002-03-23 David Shaw * import.c (append_uid, merge_sigs): it is okay to import completely non-signed uids now (with --allow-non-selfsigned-uid). * getkey.c (get_primary_uid, merge_selfsigs_main): do not choose an attribute packet (i.e. photo) as primary uid. This prevents oddities like "Good signature from [image of size 2671]". This is still not perfect (one can still select an attribute packet as primary in --edit), but is closer to the way the draft is going. * g10.c (build_list): algorithms should include 110. * g10.c (main): --pgp2 implies --no-ask-sig-expire and --no-ask-cert-expire as those would cause a v4 sig/cert. * armor.c (is_armor_header): be more lenient in what constitutes a valid armor header (i.e. -----BEGIN blah blah-----) as some Windows programs seem to add spaces at the end. --openpgp makes it strict again. 2002-03-18 David Shaw * keyserver.c (keyserver_search_prompt): Properly handle a "no keys found" case from the internal HKP code (external HKP is ok). Also, make a COUNT -1 (i.e. streamed) keyserver response a little more efficient. * g10.c (main): Add --no-allow-non-selfsigned-uid 2002-03-17 David Shaw * g10.c (main): --openpgp implies --allow-non-selfsigned-uid. * getkey.c (merge_selfsigs_main): If none of the uids are primary (because none are valid) then pick the first to be primary (but still invalid). This is for cosmetics in case some display needs to print a user ID from a non-selfsigned key. Also use --allow-non-selfsigned-uid to make such a key valid and not --always-trust. The key is *not* automatically trusted via --allow-non-selfsigned-uid. * mainproc.c (check_sig_and_print): Make sure non-selfsigned uids print [uncertain] on verification even though one is primary now. * getkey.c (merge_selfsigs): If the main key is not valid, then neither are the subkeys. * import.c (import_one): Allow --allow-non-selfsigned-uid to work on completely unsigned keys. Print the uids in UTF8. Remove mark_non_selfsigned_uids_valid(). * keyedit.c (show_key_with_all_names): Show revocation key as UTF8. * sign.c (clearsign_file): Allow --not-dash-escaped to work with v3 keys. 2002-03-14 Werner Koch * main.h: Changed the default algorithms to CAST5 and SHA1. 2002-03-13 David Shaw * import.c (chk_self_sigs): Show which user ID a bad self-sig (invald sig or unsupported public key algorithm) resides on. * import.c (chk_self_sigs): any valid self-sig should mark a user ID or subkey as valid - otherwise, an attacker could DoS the user by inventing a bogus invalid self-signature. 2002-03-07 David Shaw * g10.c (main): make a few more strings translatable. * options.h, options.skel, g10.c (main), gpgv.c, mainproc.c (check_sig_and_print), keyserver.c (parse_keyserver_options): --auto-key-retrieve should really be a keyserver-option variable. * import.c (revocation_present): new function to print a warning if a key is imported that has been revoked by designated revoker, but the designated revoker is not present to verify the revocation. If keyserver-options auto-key-retrieve is set, try and fetch the designated revoker from the keyserver. * import.c (import_one): call revocation_present after importing a new key. Note that this applies to --import, --recv-keys, and --search-keys. * keyserver-internal.h, keyserver.c (keyserver_import_fprint): import via fingerprint (for revocation keys). * keyserver.c (keyserver_import_keyid): much simpler implementation now that we're using KEYDB_SEARCH_DESC internally. 2002-03-04 David Shaw * revoke.c (gen_revoke): do not prompt for revocation reason for v3 revocations (unless force-v4-certs is on) since they wouldn't be used anyway. * keyedit.c (menu_revsig): show the status of the sigs (exportable? revocable?) to the user before prompting for which sig to revoke. Also, make sure that local signatures get local revocations. * keyedit.c (ask_revoke_sig): remind the user which sigs are local. * g10.c (main): Add "exec-path" variable to override PATH for execing programs. * export.c (do_export_stream): properly check return code from classify_user_id to catch unclassifiable keys. 2002-03-03 David Shaw * parse-packet.c (parse_signature): variable type tweak for RISC OS (from Stefan) 2002-02-28 David Shaw * getkey.c (check_revocation_keys): New function to check a revocation against a list of potential revocation keys. Note the loop-breaking code here. This is to prevent blowing up if A is B's revocation key, while B is also A's. Note also that this is written so that a revoked revoker can still issue revocations: i.e. If A revokes B, but A is revoked, B is still revoked. I'm not completely convinced this is the proper behavior, but it matches how PGP does it. It does at least have the advantage of much simpler code - my first version of this had lots of loop maintaining code so you could chain revokers many levels deep and if D was revoked, C was not, which meant that B was, and so on. It was sort of scary, actually. * getkey.c (merge_selfsigs_main): Add any revocation keys onto the pk. This is particularly interesting since we normally only get data from the most recent 1F signature, but you need multiple 1F sigs to properly handle revocation keys (PGP does it this way, and a revocation key could be marked "sensitive" and hence in a different signature). Also, if a pk has a revocation key set, check for revocation sigs that were not made by us - if made by a valid revocation key, mark the pk revoked. * packet.h, getkey.c (cache_public_key): do not cache key if "dont_cache" is set. This allows the revocation key code to look up a key and return information that may be inaccurate to prevent loops without caching the fake data. * packet.h, sig-check.c (do_signature_check): Record if a signature was made by a revoked pk. * packet.h, parse-packet.c (parse_one_sig_subpkt, can_handle_critical, parse_signature): Get revocation key information out of direct sigs. * keylist.c (list_keyblock_print): don't assume that the presence of a 0x20 signature means the key is revoked. With revocation keys, this may not be true if the revocation key is not around to verify it or if verification failed. Also, 0x1F should get listed as "sig", and not "unexpected signature class". * keyedit.c (show_key_with_all_names): Add a flag for printing revoker information and change all callers. * import.c (merge_blocks): merge in any new direct key (0x1F) sigs. * import.c (import_revoke_cert): don't keep processing after a revocation is rejected. * import.c (delete_inv_parts): Allow importing a revocation signature even if it was not issued by the key. This allows a revocation key to issue it. Of course, the sig still needs to be checked before we trust it. * free-packet.c (copy_public_key): Include a new copy of the revocation keys when duping a pk. * free-packet.c (free_seckey_enc, release_public_key_parts): Free any revocation keys that are attached to a sig or pk. * export.c (do_export_stream): Do not export signatures with "sensitive" revocation keys in them. 2002-02-27 David Shaw * export.c (do_export_stream): Do not include v3 keys in a --export-secret-subkeys export. * getkey.c (merge_selfsigs_main): If a key isn't valid (say, because of no self-signature), allow --always-trust to force it valid so it can be trusted. 2002-02-25 David Shaw * hkp.c (hkp_ask_import), hkp.h, keyserver.c (all): treat key lists internally as fingerprints when possible. All this is via KEYDB_SEARCH_DESC - no point in reinventing the wheel. This allows the helper program to search the keyserver by fingerprint if desired (and the keyserver supports it). Note that automatic fingerprint promotion during refresh only applies to v4 keys as a v4 fingerprint can be easily changed into a long or short key id, and a v3 cannot. * pubkey-enc.c, getkey.c, misc.c, main.h: Take two copies of hextobyte() from pubkey-enc.c and getkey.c and make them into one copy in misc.c. 2002-02-22 David Shaw * keyserver.c (keyserver_search_prompt): Detect a "no keys found" case even if the helper program does not explicitly say how many keys were found. * hkp.c (parse_hkp_index): Bug fix - don't report non-revoked keys as revoked in HKP key searches. 2002-02-19 Werner Koch * parse-packet.c (parse_trust): Made parsing more robust. 2002-02-19 David Shaw * hkp.c (parse_hkp_index): Catch corruption in HKP index lines (can be caused by broken or malicious keyservers). * keyserver.c (keyserver_work): Add KEYSERVER_NOT_SUPPORTED for unsupported actions (say, a keyserver that has no way to search, or a readonly keyserver that has no way to add). Also add a USE_EXTERNAL_HKP define to disable the internal HKP keyserver code. 2002-02-14 Werner Koch * g10.c: New option --no-use-agent. * pkclist.c (check_signatures_trust): Always print the warning for unknown and undefined trust. Removed the did_add cruft. Reported by Janusz A. Urbanowicz. 2002-02-11 David Shaw * hkp.c (parse_hkp_index): Bug fix - properly handle user IDs with colons (":") in them while HKP searching. 2002-02-09 David Shaw * misc.c (pct_expando): More comments. * keydb.h, sign.c (mk_notation_and_policy): Clarify what is a sig and what is a cert. A sig has sigclass 0x00, 0x01, 0x02, or 0x40, and everything else is a cert. * g10.c (main), keyedit.c (keyedit_menu): Add a "nrlsign" for nonrevocable and local key signatures. * g10.c (main): Add a --no-force-mdc to undo --force-mdc. * options.h, g10.c (main), cipher.c (write_header): Add a knob to --disable-mdc/--no-disable-mdc. Off by default, of course, but is used in --pgp2 and --pgp6 modes. * pkclist.c (build_pk_list): Allow specifying multiple users in the "Enter the user ID" loop. Enter a blank line to stop. Show each key+id as it is added. * keylist.c (show_policy_url), mainproc.c (print_notation_data): It is not illegal (though possibly silly) to have multiple policy URLs in a given signature, so print all that are present. * hkp.c (hkp_search): More efficient implementation of URL-ifying code. 2002-02-04 David Shaw * main.h, misc.c (pct_expando): New function to generalize %-expando processing in any arbitrary string. * photoid.c (show_photo): Call the new pct_expando function rather than expand strings internally. * sign.c (mk_notation_and_policy): Show policy URLs and notations when making a signature if show-policy/show-notation is on. %-expand policy URLs during generation. This lets the user have policy URLs of the form "http://notary.jabberwocky.com/keysign/%K" which will generate a per-signature policy URL. * main.h, keylist.c (show_policy_url, show_notation): Add amount to indent so the same function can be used in key listings as well as during sig generation. Change all callers. 2002-02-04 David Shaw * keyserver.c, options.h (parse_keyserver_options, keyidlist): Workaround for the pksd and OKS keyserver bug that calculates v4 RSA keyids as if they were v3. The workaround/hack is to fetch both the v4 (e.g. 99242560) and v3 (e.g. 68FDDBC7) keyids. This only happens for key refresh while using the HKP scheme and the refresh-add-fake-v3-keyids keyserver option must be set. This should stay off by default. 2002-02-03 David Shaw * keyserver.c (keyserver_spawn): Bug fix - do not append keys to each other when --sending more than one. 2002-02-02 David Shaw * options.h, g10.c (main), keyedit.c (sign_uids), sign.c (mk_notation_and_policy): Split "--set-policy-url" into "--cert-policy-url" and "--sig-policy-url" so the user can set different policies for key and data signing. For backwards compatibility, "--set-policy-url" sets both, as before. 2002-01-30 Werner Koch * g10.c (main): --gen-random --armor does now output a base64 encoded string. 2002-01-28 David Shaw * g10.c (main), options.h, pkclist.c (algo_available): --pgp6 flag. This is not nearly as involved as --pgp2. In short, it turns off force_mdc, turns on no_comment, escape_from, and force_v3_sigs, and sets compression to 1. It also restricts the user to IDEA (if present), 3DES, CAST5, MD5, SHA1, and RIPEMD160. See the comments above algo_available() for lots of discussion on why you would want to do this. 2002-01-27 David Shaw * keygen.c (keygen_set_std_prefs): Comment * keyedit.c (sign_uids): Bug fix - when signing with multiple secret keys at the same time, make sure each key gets the sigclass prompt. * exec.c (exec_finish): Close the iobuf and FILE before trying to waitpid, so the remote process will get a SIGPIPE and exit. This is only a factor when using a pipe to communicate. * exec.c (exec_write): Disable cache-on-close of the fd iobuf (is this right? Why is a fd iobuf cached at all?) 2002-01-26 Werner Koch * g10.c, options.h: New option --gpg-agent-info * passphrase.c (agent_open): Let it override the environment info. * seckey-cert.c (check_secret_key): Always try 3 times when the agent is enabled. * options.skel: Describe --use-agent. 2002-01-24 David Shaw * pubkey-enc.c (is_algo_in_prefs, get_it): Only check preferences against keys with v4 self sigs - there is really little point in warning for every single non-IDEA message encrypted to an old key. * pkclist.c (select_algo_from_prefs): Only put in the fake IDEA preference if --pgp2 is on. * mainproc.c (check_sig_and_print): Print "Expired" for expired but good signatures (this still prints "BAD" for expired but bad signatures). 2002-01-23 David Shaw * keygen.c (ask_keysize): Cosmetic: don't present a RSA signing key as a "keypair" which can be 768 bits long (as RSA minimum is 1024). * pubkey-enc.c (is_algo_in_prefs): Allow IDEA as a fake preference for v3 keys with v3 selfsigs. 2002-01-22 David Shaw * packet.h, getkey.c (merge_selfsigs_main), pkclist.c (select_algo_from_prefs): Implement the fake IDEA preference as per RFC2440:12.1. This doesn't mean that IDEA will be used (the plugin may not be present), but it does mean that a v3 key with a v3 selfsig has an implicit IDEA preference instead of 3DES. v3 keys with v4 selfsigs use preferences as normal. * encode.c (encode_crypt): if select_algo_from_prefs fails, this means that we could not find a cipher that both keys like. Since all v4 keys have an implicit 3DES preference, this means there is a v3 key with a v3 selfsig in the list. Use 3DES in this case as it is the safest option (we know the v4 key can handle it, and we'll just hope the v3 key is being used in an implementation that can handle it). If --pgp2 is on, warn the user what we're doing since it'll probably break PGP2 compatibility. * g10.c (main): Do not force using IDEA for encrypted files in --pgp2 mode - let the fake IDEA preference choose this for us for better compatibility when encrypting to multiple keys, only some of which are v3. * keygen.c (keygen_set_std_prefs): Put 3DES on the end of the default cipher pref list (RFC2440: "...it is good form to place it there explicitly."). If the user has the IDEA plugin installed, put a preference for IDEA *after* 3DES to effectively disable its use for everything except encrypting along with v3 keys. * encode.c, g10.c, sign.c: Change the PGP2 warning line from "... will not be usable ..." to "... may not be usable ..." as the user could be using one of the enhanced PGP2 variations. * helptext.c: Revise the sign_uid.class help text as suggested by Stefan. 2002-01-20 Werner Koch * passphrase.c (passphrase_to_dek): Add tryagain_text arg to be used with the agent. Changed all callers. (agent_get_passphrase): Likewise and send it to the agent * seckey-cert.c (do_check): New arg tryagain_text. (check_secret_key): Pass the string to do_check. * keygen.c (ask_passphrase): Set the error text is required. * keyedit.c (change_passphrase): Ditto. * passphrase.c (agent_open): Disable opt.use_agent in case of a problem with the agent. (agent_get_passphrase): Ditto. (passphrase_clear_cache): Ditto. 2002-01-19 Werner Koch * passphrase.c (agent_open): Add support for the new Assuan based gpg-agent. New arg to return the used protocol version. (agent_get_passphrase): Implemented new protocol here. (passphrase_clear_cache): Ditto. (readline): New. 2002-01-15 Timo Schulz * encode.c (encode_crypt_files): Fail if --output is used. * g10.c: New command --decrypt-files. * decrypt.c (decrypt_messages): New. 2002-01-09 David Shaw * g10.c, misc.c, gpgv.c: move idea_cipher_warn to misc.c so gpgv.c doesn't need a stub for it any longer. * g10.c (get_temp_dir), main.h: no longer used (it's in exec.c now) * g10.c (main), delkey.c (delete_keys), main.h : Allow --delete-key (now --delete-keys, though --delete-key still works, of course) to delete multiple keys in one go. This applies to --delete-secret-key(s) and --delete-secret-and-public-key(s) as well. 2002-01-09 Timo Schulz * encode.c (encode_crypt_files): Now it behaves like verify_files. * g10.c (main): We don't need to check argc for encode_crypt_files any longer. 2002-01-09 Timo Schulz * exec.c: Include windows.h for dosish systems. 2002-01-08 Timo Schulz * g10.c (main): New description for --encrypt-files. 2002-01-08 Werner Koch * g10.c (main): Must register the secring for encryption because it is needed to figure out the default recipient. Reported by Roger Sondermann. 2002-01-05 David Shaw * keyedit.c (menu_adduid): Require --expert before adding a photo ID to a v3 key, and before adding a second photo ID to any key. * keyedit.c (keyedit_menu): Don't allow adding photo IDs in rfc1991 or pgp2 mode. * getkey.c (merge_selfsigs_subkey): Permit v3 subkeys. Believe it or not, this is allowed by rfc 2440, and both PGP 6 and PGP 7 work fine with them. * g10.c, options.h, keyedit.c, sign.c: Move the "ask for expiration" switch off of --expert, which was getting quite overloaded, and onto ask-sig-expire and ask-cert-expire. Both default to off. * g10.c (main): Change the default compression algo to 1, to be more OpenPGP compliant (PGP also uses this, so it'll help with interoperability problems as well). * encode.c (encode_crypt): Handle compression algo 2, since the default is now 1. * build-packet.c (build_attribute_subpkt): Fix off-by-one error. 2002-01-05 Werner Koch * g10.c (main): Do not register the secret keyrings for certain commands. * keydb.c (keydb_add_resource): Use access to test for keyring existence. This avoids cached opened files which are bad under RISC OS. 2002-01-04 David Shaw * sign.c (sign_file, sign_symencrypt_file): always use one-pass packets unless rfc1991 is enabled. This allows a signature made with a v3 key to work in PGP 6 and 7. Signatures made with v4 keys are unchanged. * g10.c (main): Disallow non-detached signatures in PGP2 mode. Move the "you must use files and not pipes" PGP2 warning up so all the PGP2 stuff is together. * encode.c (encode_simple): Use the actual filesize instead of partial length packets in the internal literal packet from a symmetric message. This breaks PGP5(?), but fixes PGP2, 6, and 7. It's a decent tradeoff. Note there was only an issue with old-style RFC1991 symmetric messages. 2440-style messages in 6 and 7 work with or without partial length packets. 2002-01-03 David Shaw * g10.c (main): Removed --no-default-check-level option, as it is not consistent with other "default" options. Plus, it is the same as saying --default-check-level 0. * exec.c (exec_read): Disallow caching tempfile from child process, as this keeps the file handle open and can cause unlink problems on some platforms. * keyserver.c (keyserver_search_prompt): Minor tweak - don't bother to transform keyids into textual form if they're just going to be transformed back to numbers. 2002-01-03 Timo Schulz * g10.c: New command --encrypt-files. * verify.c (print_file_status): Removed the static because encode_crypt_files also uses this function. * main.h (print_files_status): New. (encode_crypt_files): New. * encode.c (encode_crypt_files): New. 2002-01-02 Stefan Bellon * keyserver.c: Moved util.h include down in order to avoid redefinition problems on RISC OS. * keyring.c (keyring_lock): Only lock keyrings that are writable. * keyring.c (keyring_update_keyblock): Close unused iobuf. * hkp.c (parse_hkp_index, hkp_search) [__riscos__]: Changed unsigned char* to char* because of compiler issues. * exec.c (exec_finish) [__riscos__]: Invalidate close cache so that file can be unlinked. 2001-12-28 David Shaw * g10.c (main): Use a different strlist to check extensions since they need to be handled seperately now. * misc.c,main.h (check_permissions): Properly handle permission and ownership checks on files in the lib directory (e.g. /usr/local/lib/gnupg), which are owned by root and are world-readable, and change all callers to specify extension or per-user file. * photoid.c (show_photo), keyserver.c (keyserver_spawn): Bug fix - don't call exec_finish if exec_write fails. * keyserver.c (keyserver_spawn): Look for OPTIONS from the keyserver helper - specifically, a "OUTOFBAND" option for the email keyserver. * mainproc.c (list_node), keylist.c (list_keyblock_colon), import.c (delete_inv_parts), export.c (do_export_stream): Use signature flags for exportability check rather than re-parsing the subpacket. * keyid.c, keydb.h (get_lsign_letter): No longer needed. 2001-12-27 David Shaw * exec.c (exec_finish): Show errors when temp files cannot be deleted for whatever reason. * exec.c (exec_read): Don't rely on WEXITSTATUS being present. * exec.c (make_tempdir): Add temp file creator for win32. Don't create an incoming temp file if the exec is write-only. * keyserver.c (keyserver_spawn): Clean up error handling, for when the spawn fails. * photoid.c (show_photo): Clean up error handling. * misc.c (check_permissions): Neaten. 2001-12-25 David Shaw * mkdtemp.c (mkdtemp): Add copyleft info and tweak the 'X' counter to be a bit simpler. * keyserver.c, photoid.c: Remove unused headers left over from when the exec functions lived there. 2001-12-23 Timo Schulz * misc.c (check_permissions): Do not use it for W32 systems. * tdbio.c (migrate_from_v2): Define ftruncate as chsize() for W32. * mkdtemp.c: W32 support. * photoid.c: Ditto. * exec.c: Ditto. 2001-12-22 David Shaw * exec.c (make_tempdir): avoid compiler warning with const * mkdtemp.c (mkdtemp): catch the empty ("") string case in case someone repurposes mkdtemp at some point. * photoid.c (generate_photo_id, show_photo): some type changes from Stefan Bellon. * exec.c (make_tempdir): handle Win32 systems, suggested by Timo Schulz. 2001-12-22 Werner Koch * encode.c (encode_simple, encode_crypt): i18n 2 strings. 2001-12-22 Timo Schulz * encode.c (encode_simple, encode_crypt): Use is_file_compressed to avoid to compress compressed files. 2001-12-22 Werner Koch * keyserver.c (keyserver_spawn): Removed some variables declaration due to shadowing warnings. * build-packet.c (build_attribute_subpkt): s/index/idx/ to avoid compiler warnig due to index(3). * getkey.c (get_ctx_handle): Use KEYDB_HANDLE as return value. * keylist.c (list_one): Made resname const. * keyedit.c (keyedit_menu): Allow "addphoto" only when --openpgp is not used. * options.skel: Changed one example photo viewer to qiv. 2001-12-21 David Shaw * Makefile.am: add exec.c, exec.h, photoid.c, and photoid.h * build-packet.c (build_attribute_subpkt): new function to build the raw attribute subpacket. Note that attribute subpackets have the same format as signature subpackets. * exec.c: new file with generic exec-a-program functionality. Used by both photo IDs and keyserver helpers. This is pretty much the same code that used to be keyserver specific, with some changes to be usable generically. * free-packet.c (free_attributes (new)): function to free an attribute packet. * gpgv.c: added stub show_photo * keyedit.c (keyedit_menu, menu_adduid, menu_showphoto): can add a photo (calls generate_photo_id), or display a photo (calls show_photo) from the --edit menu. New commands are "addphoto", and "delphoto" (same as "deluid"). * keylist.c (list_keyblock_print): show photos during key list if --show-photos enabled. * keyserver.c (keyserver_spawn): use the generic exec_xxx functions to call keyserver helper. * g10.c, options.h: three new options - --{no-}show-photos, and --photo-viewer to give the command line to display a picture. * options.skel: instructions for the photo viewer * parse-packet.c (parse_user_id, setup_user_id (new)): common code for both user IDs and attribute IDs moved to setup_user_id. * parse-packet.c (make_attribute_uidname (new)): constructs a fake "name" for attribute packets (e.g. "[image of size ...]") * parse-packet.c (parse_attribute (replaces parse_photo_id), parse_attribute_subpkts): Builds an array of individual attributes. Currently only handles attribute image / type jpeg subpackets. * sign.c (hash_uid): Fix bug in signing attribute (formerly photo_id) packets. * packet.h, and callers: globally change "photo_id" to "attribute" and add structures for attributes. The packet format is generic attributes, even though the only attribute type thus far defined is jpeg. 2001-12-21 David Shaw * parse-packet.c (can_handle_critical): Can handle critical revocation subpackets now. * trustdb.c (mark_usable_uid_certs): Disregard revocations for nonrevocable sigs. Note that this allows a newer revocable signature to override an older nonrevocable signature. * sign.c (make_keysig_packet): add a duration field and change all callers. This makes make_keysig_packet closer to write_signature_packets and removes some duplicated expiration code. * keyedit.c (keyedit_menu, menu_revsig, sign_uids, sign_mk_attrib): Add nrsign command, don't allow revoking a nonrevocable signature, * g10.c (main): Add --nrsign option to nonrevocably sign a key from the command line. * build-packet.c (build_sig_subpkt_from_sig): Comment to explain the use of CRITICAL. 2001-12-21 Werner Koch * g10.c. options.h : New option --show-keyring * getkey.c (get_ctx_handle): New. * keylist.c (list_one): Implement option here. By David Champion. 2001-12-20 David Shaw * keyserver.c (keyserver_spawn): Use mkdtemp() to make temp directory. * mkdtemp.c: replacement function for those platforms that don't have mkdtemp (make a temp directory securely). 2001-12-19 David Shaw * misc.c (check_permissions): New function to stat() and ensure the permissions of GNUPGHOME and the files have safe permissions. * keydb.c (keydb_add_resource): Check keyring permissions. * tdbio.c (tdbio_set_dbname): Check permissions of trustdb.gpg * keyserver.c (keyserver_spawn): Disable keyserver schemes that involve running external programs if the options file has unsafe permissions or ownership. * g10.c, options.h: New option --no-permission-warning to disable the permission warning message(s). This also permits use of the keyserver if it had been disabled (see above). Also check the permissions/ownership of random_seed. * keyserver.c (keyserver_spawn): The new glibc prints a warning when using mktemp() (the code was already secure, but the warning was bound to cause confusion). Use a different implementation based on get_random_bits() instead. Also try a few times to get the temp dir before giving up. 2001-12-19 Werner Koch * g10.c, passphrase.c [CYGWIN32]: Allow this as an alias for MINGW32. 2001-12-18 David Shaw * g10.c (idea_cipher_warn): Add a flag to show the warning always or once per session and change all callers (show always except for the secret key protection and unknown cipher from an encrypted message errors). Also make the strings translatable. * pubkey-enc.c (get_it): Add the IDEA cipher warning if the user tries to decrypt an IDEA encrypted message without the IDEA plugin. * keyserver.c (parse_keyserver_uri): More strict checking of the keyserver URI. Specifically, fail if the ":port" section is anything except a number between 1 and 65535. 2001-12-17 David Shaw * keyserver.c (print_keyinfo): No need to check for control/illegal characters, as utf8_to_native does this for us. * mainproc.c (proc_encrypted): Use generic IDEA warning. * gpgv.c: add stub for idea_cipher_warn * g10.c, hkp.c, keyserver.c: Fix capitalization and plural issues. * encode.c (encode_crypt), sign.c (sign_file, clearsign_file): disable pgp2 mode after the message is no longer pgp2 compatible. * g10.c (main): Tweak the PGP2.x IDEA warning to use the generic warning, and not merely fail if the IDEA plugin isn't there. * g10.c (main, idea_cipher_warn), keygen.c (set_one_pref), seckey-cert.c (do_check): Add a generic IDEA warning for when the IDEA plugin is not present. This pops up when the user uses "--cipher-algo idea", when setpref is used to set a "S1" preference, and when a secret key protected with IDEA is used. 2001-12-15 Werner Koch * keyserver.c (keyserver_spawn): Assert that we have dropped privs. 2001-12-13 Werner Koch * pubkey-enc.c (get_session_key): Check that the public key algorithm is indeed usable for en/decryption. This avoid a strange error message from pubkey_decrypt if for some reasons a bad algorithm indentifier is passed. 2001-12-12 David Shaw * Fixed some types for portability. Noted by Stefan Bellon. 2001-12-11 Werner Koch * hkp.c (hkp_export): Do not print possible control characters from a keyserver response. (parse_hkp_index): Made uid an unsigned char* because it is passed to isspace(). (hkp_search): Ditto for the char* vars. * g10.c (main): Print the IDEA warning also for -c and -se. * g10.c (get_temp_dir): Assert that we have dropped privs * encode.c (encode_crypt): Include the first key into the --pgp2 check. 2001-12-07 David Shaw * g10.c, options.h: New option --pgp2. This is identical to "--rfc1991 --cipher-algo idea --compress-algo 1 --digest-algo md5 --force_v3_sigs" with the addition of an warning to advise the user not to use a pipe (which would break pgp2 compatibility). * encode.c (encode_crypt): warn if the user tries to encrypt to any key that is not RSA and <= 2048 bits when the --pgp2 option is used. * sign.c (sign_file, clearsign_file): When using --pgp2, make a v3 sig, and warn if the signature is made with a non-v3 key. 2001-12-05 David Shaw * sign.c (sign_file, clearsign_file, sign_symencrypt_file): Prompt for sig expiration if --expert is set and --force-v3-sigs is not set (v3 sigs cannot expire). * mainproc.c (check_sig_and_print): After checking a sig, print expiration status. This causes a error return if the sig is expired. * build-packet.c (build_sig_subpkt_from_sig): Include a critical sig expiration subpacket if the sig is to expire. * keyedit.c (sign_uids): Do not sign an expired key unless --expert is set, in which case prompt. Also, offer to expire a signature when the key the user is signing expires. * keygen.c (ask_expire_interval): Add a value to determine whether to prompt for a key or sig expiration and change all callers. * keyid.c: New functions: expirestr_from_sig and colon_expirestr_from_sig. * keylist.c (list_keyblock_colon): Show sig expiration date in the --with-colons listing. * sign.c (make_keysig_packet, write_signature_packets): Pass in an optional timestamp for the signature packet, and change all callers. * keyedit.c (sign_mk_attrib): Include a critical expiration subpacket in the signature if an expiration date is given. 2001-12-04 David Shaw * keyedit.c (sign_uids): If the user tries to sign a locally-signed key, allow the cert to be promoted to a full exportable signature. This essentially deletes the old non-exportable sig, and replaces it with a new exportable one. 2001-12-04 David Shaw * keyedit.c (keyedit_menu): Do not allow signing a revoked key unless --expert is set, and ask even then. * keyedit.c (sign_uids): Do not allow signing a revoked UID unless --expert is set, and ask even then. * g10.c, options.h : New option --expert 2001-11-16 David Shaw * Allow the user to select no compression via "--compress-algo 0" on the command line. * keyedit.c (show_prefs): Show compression preferences in the long-form "showpref" style. * keygen.c (set_one_pref): Permit setting a no-compression ("Z0") preference. * getkey.c (fixup_uidnode): Fix compression preference corruption bug. 2001-12-02 David Shaw * g10.c: Add advisory --for-your-eyes-only option as per section 5.9 of 2440. 2001-12-05 David Shaw * Force a V4 sig if the user has a notation or policy URL set. 2001-12-04 David Shaw * g10.c: Add options --keyserver-options, --temp-directory, and auto-key-retrieve (the opposite of no-auto-key-retrieve). * hkp.c (hkp_search): New function to handle searching a HKP keyserver for a key * hkp.c (hkp_ask_import, hkp_export): Pretty large changes to make them communicate via the generic functions in keyserver.c * keyserver.c: new file with generic keyserver routines for getting keys from a keyserver, sending keys to a keyserver, and searching for keys on a keyserver. Calls the internal HKP stuff in hkp.c for HKP keyserver functions. Other calls are handled by an external program which is spawned and written to and read from via pipes. Platforms that don't have pipes use temp files. 2001-11-20 David Shaw * options.h, g10.c: New options show-notation, no-show-notation, default-check-level, no-default-check-level, show-policy-url, no-show-policy-url. * packet.h, sign.c (make_keysig_packet), parse-packet.c (parse_signature), free-packet.c (free_seckey_enc): Fill in structures for notation, policy, sig class, exportability, etc. * keyedit.c, keylist.c (print_and_check_one_sig, list_keyblock_print): Show flags in signature display for cert details (class, local, notation, policy, revocable). If selected, show the notation and policy url. * keyedit.c (sign_uids): Prompt for and use different key sig classes. * helptext.c (helptexts): Add help text to explain different key signature classes 2001-11-26 David Shaw * trustdb.c (mark_usable_uid_certs): Fix segfault from bad initialization and fix reversed key signature expiration check. 2001-11-09 Werner Koch * export.c (do_export_stream): Put all given names into a search description and change the loop so that all matching names are returned. 2001-11-08 Werner Koch * pubkey-enc.c (get_it): To reduce the number of questions on the MLs print the the name of cipher algorithm 1 with the error message. * mainproc.c: Changed the way old rfc1991 encryption cipher is selected. Based on a patch by W Lewis. * pkclist.c (do_edit_ownertrust): Allow to skip over keys, the non working "show info" is now assigned to "i" * trustdb.c (ask_ownertrust, validate_keys): Implement a real quit here. Both are by David Shaw. * trustdb.c (validate_keys): Make sure next_exipire is initialized. * sign.c (make_keysig_packet): Use SHA-1 with v4 RSA keys. * g10.c, options.h : New option --[no-]froce-v4-certs. * sign.c (make_keysig_packet): Create v4 sigs on v4 keys even with a v3 key. Use that new option. By David Shaw * revoke.c (ask_revocation_reason): Allow to select "no reason". By David Shaw. * keyid.c (fingerprint_from_sk): Calculation of an v3 fpr was plain wrong - nearly the same code in fingerprint_from_pk is correct. * build-packet.c (do_secret_key): Added a few comments to the code. 2001-11-07 Werner Koch * g10.c (main): Print a warning when -r is used w/o encryption. Suggested by Pascal Scheffers. 2001-10-23 Werner Koch * keyedit.c (keyedit_menu): Changed helptext for showpref command. Suggested by Reinhard Wobst. * keyring.c (keyring_search): When marking the offtbl ready, take into account that we may have more than one keyring. 2001-10-22 Werner Koch * Makefile.am: Do not use OMIT_DEPENDENCIES * build-packet.c (build_sig_subpkt): Default is now to put all types of subpackets into the hashed area and only list those which should go into the unhashed area. 2001-10-18 Werner Koch * keydb.c (keydb_add_resource): Rearranged the way we keep track of the resource. There will now be an entry for each keyring here and not in keyring.c itself. Store a token to allow creation of a keyring handle. Changed all functions to utilize this new design. (keydb_locate_writable): Make a real implementation. * keyring.c (next_kr): Removed and changed all callers to set the resource directly from the one given with the handle. (keyring_is_writable): New. (keyring_rebuild_cache): Add an arg to pass the token from keydb. 2001-10-17 Werner Koch * keyring.c (keyring_search): Enabled word search mode but print a warning that it is buggy. 2001-10-11 Werner Koch * hkp.c (hkp_ask_import): No more need to set the port number for the x-hkp scheme. (hkp_export): Ditto. 2001-10-06 Stefan Bellon * passphrase.c [__riscos__]: Disabled agent specific stuff. * g10.c: New option --no-force-v3-sigs. 2001-10-04 Werner Koch * export.c (do_export_stream): Do not push the compress filter here because the context would run out of scope due to the iobuf_close done by the caller. (do_export): Do it here instead. 2001-09-28 Werner Koch * keyedit.c (sign_uids): Always use the primary key to sign keys. * getkey.c (finish_lookup): Hack to return only the primary key if a certification key has been requested. * trustdb.c (cmp_kid_for_make_key_array): Renamed to (validate_one_keyblock): this and changed arg for direct calling. (make_key_array): Renamed to (validate_one_keyblock): this and changed args for direct calling. (mark_usable_uid_certs, validate_one_keyblock) (validate_key_list): Add next_expire arg to keep track of expiration times. (validate_keys): Ditto for UTKs and write the stamp. * tdbio.c (migrate_from_v2): Check return code of tbdio_sync. * tdbdump.c (import_ownertrust): Do a tdbio_sync(). * keyring.c: Made the offtbl an global object. 2001-09-27 Werner Koch * pkclist.c (do_edit_ownertrust): Allow settin of ultimate trust. * trustdb.c (mark_keyblock_seen): New. (make_key_array): Use it to mark the subkeys too. (validate_keys): Store validity for ultimatly trusted keys. 2001-09-26 Werner Koch * pkclist.c (check_signatures_trust, do_we_trust): Removed the invocation of add_ownertrust. Minor changes to the wording. (add_ownertrust, add_ownertrust_cb): Removed. * trustdb.c (get_validity): Allow to lookup the validity using a subkey. * trustdb.c (new_key_hash_table): Increased the table size to 1024 and changed the masks accordingly. (validate): Changed stats printing. (mark_usable_uid_certs): New. (cmp_kid_for_make_key_array): Does now check the signatures and figures out a usable one. 2001-09-25 Werner Koch * keyring.c (new_offset_item,release_offset_items) (new_offset_hash_table, lookup_offset_hash_table) (update_offset_hash_table, update_offset_hash_table_from_kb): New. (keyring_search): Use a offset table to optimize search for unknown keys. (keyring_update_keyblock, keyring_insert_keyblock): Insert new offsets. * getkey.c (MAX_UNK_CACHE_ENTRIES): Removed the unknown keys caching code. * g10.c, options.h, import.c: Removed the entire allow-secret-key-import stuff because the validity is now controlled by other means. * g10.c: New command --rebuild-keydb-caches. * keydb.c (keydb_rebuild_caches): New. * keyring.c (do_copy): Moved some code to (create_tmp_file, rename_tmp_file, write_keyblock): new functions. (keyring_rebuild_cache): New. * packet.h (PKT_ring_trust): Add sigcache field. * parse-packet.c (parse_trust): Parse sigcache. * keyring.c (do_copy): Always insert a sigcache packet. (keyring_get_keyblock): Copy the sigcache packet to the signature. * sig-check.c (cache_sig_result): Renamed from cache_selfsig_result. Changed implementation to use the flag bits and changed all callers. (mdc_kludge_check): Removed this unused code. (do_check): Do not set the sig flags here. * import.c (read_block): Make sure that ring_trust packets are never imported. * export.c (do_export_stream): and never export them. * trustdb.c (make_key_array): Skip revoked and expired keys. 2001-09-24 Werner Koch * g10.c, options.h: New option --no-auto-check-trustdb. * keygen.c (do_generate_keypair): Set newly created keys to ultimately trusted. * tdbio.h, tdbio.c: Removed all support for records DIR, KEY, UID, PREF, SIG, SDIR and CACH. Changed migration function to work direct on the file. (tdbio_read_nextcheck): New. (tdbio_write_nextcheck): New. 2001-09-21 Werner Koch Revamped the entire key validation system. * trustdb.c: Complete rewrite. No more validation on demand, removed some functions, adjusted to all callers to use the new and much simpler interface. Does not use the LID anymore. * tdbio.c, tdbio.h: Add new record types trust and valid. Wrote a migration function to convert to the new trustdb layout. * getkey.c (classify_user_id2): Do not allow the use of the "#" prefix. * keydb.h: Removed the TDBIDX mode add a skipfnc to the descriptor. * keyring.c (keyring_search): Implemented skipfnc. * passphrase.c (agent_open): Add missing bracket. Include windows.h. 2001-09-19 Werner Koch * keylist.c (print_fingerprint): Renamed from fingerprint, made global available. Added new arg to control the print style. * mainproc.c (print_fingerprint): Removed. * pkclist.c (print_fpr, fpr_info): Removed and changed callers to use print_fingerprint. * keyedit.c (show_fingerprint): Ditto. * passphrase.c (writen, readn) (agent_open, agent_close) (agent_get_passphrase) (passphrase_clear_cache): Support for W32. Contributed by Timo. * import.c (import_one): Release keydb handles at 2 more places. * keyring.c (keyring_release): Close the iobuf. (keyring_get_keyblock): Init ret_kb to NULL and store error contidion. * import.c (import_new_stats_handle): New. (import_release_stats_handle): New. (import_print_stats): Renamed from static fnc print_stats. (import_keys, import_keys_stream): Add an optional status handle arg and changed all callers. * hkp.c (hkp_ask_import): Add an stats_handle arg and changed all callers. * mainproc.c (print_pkenc_list): Use print_utf8_string2(). 2001-09-18 Werner Koch * g10.c: New command --refresh-keys. * hkp.c (hkp_refresh_keys): New. Contributed by Timo Schulz. * parse-packet.c (parse): Stop on impossible packet lengths. 2001-09-17 Werner Koch * mainproc.c (print_notation_data): Wrap notation data status lines after 50 chars. * mainproc.c (proc_pubkey_enc): Make option try-all-secrets work. By disastry@saiknes.lv. 2001-09-14 Werner Koch * parse-packet.c (dump_sig_subpkt): List key server preferences and show the revocable flag correctly. Contributed by David Shaw. 2001-09-09 Werner Koch * keyedit.c (keyedit_menu): No need to define another p. * keylist.c (print_capabilities): s/used/use/ so that it does not shadow a global. * sign.c (sign_file): Renamed arg encrypt to encryptflag * keygen.c: Replaced all "usage" by "use". * misc.c (openpgp_pk_algo_usage): Ditto. * pubkey-enc.c (get_it): Renamed arg k to enc so that the later defined k does not shadow it. * parse-packet.c (parse_gpg_control): No need to define another i. * getkey.c (get_pubkey_byfprint): Must use the enum values and not the fprint_len. * keyring.c (keyring_search): Removed a non-sense break. Both bugs pointed out by Stefan. 2001-09-07 Werner Koch * status.c, status.h: Added NO_RECP and ALREADY_SIGNED. * pkclist.c (build_pk_list): Issue NO_RECP. * keyedit.c (sign_uids): Added experimental ALREADY_SIGNED * hkp.c (hkp_import): Use log_error. Bug reported by Neal H Walfield. * getkey.c (classify_user_id2): Change args to take the desc union direct. It was a stupid idea to pass the individual fields of an union to this function. Changed all callers. (classify_user_id): Ditto and allow to pass NULL as the description. 2001-09-06 Werner Koch * getkey.c (fixup_uidnode): Features flag is now a bit vector. * keygen.c (add_feature_mdc): Ditto. Revamped the entire key I/O code to be prepared for other ways of key storages and to get rid of the existing shit. GDBM support has gone. * keydb.c: New * keyring.c, keyring.h: New. * ringedit.c: Removed. Moved some stuff to keyring.c * getkey.c: Changed everything related to the key retrieving functions which are now using the keydb_ functions. (prepare_search, word_match_chars, word_match) (prepare_word_match, compare_name): Moved to keyring.c (get_pubkey_byname): Removed ctx arg and add ret_kdbhd arg. Changed all callers. (key_byname): Use get_pubkey_end to release the context and take new ret_kbdhd arg. Changed all callers. (classify_user_id2): Fill the 16 byte fingerprint up with 4 null bytes not with zero bytes of value 4, tsss. * import.c (import_one): Updated to use the new keydb interface. (import_secret_one): Ditto. (import_revoke_cert): Ditto. * delkey.c (do_delete_key): Ditto. * keyedit.c (keyedit_menu): Ditto. (get_keyblock_byname): Removed. * revoke.c (gen_revoke): Ditto. * export.c (do_export_stream): Ditto. * trustdb.c (update_trustdb): Ditto. * g10.c, gpgv.c (main): Renamed add_keyblock_resource to keydb_add_resource. * Makefile.am: Added and removed files. * keydb.h: Moved KBNODE typedef and MAX_FINGERPRINT_LEN to * global.h: this new header. 2001-09-03 Werner Koch * passphrase.c (agent_get_passphrase): Changed nread to size_t. (passphrase_clear_cache): Ditto. * keyid.c (mk_datestr): Avoid trigraphs. (fingerprint_from_pk): Cache the keyid in the pk. * options.h: Add opt.with_fingerprint so that we know whether the corresponding options was used. * g10.c (main): Set it here. * pkclist.c (check_signatures_trust): Always print fingerprint when this option is used. Mixed a minor memory leak. * status.c, status.h: New status INV_RECP. * pkclist.c (build_pk_list): Issue this status. 2001-08-31 Werner Koch * parse-packet.c (parse_key,parse_pubkeyenc) (parse_signature): Return error on reading bad MPIs. * mainproc.c (check_sig_and_print): Always print the user ID even if it is not bound by a signature. Use the primary UID in the status messages and encode them in UTF-8 * status.c (write_status_text_and_buffer): New. 2001-08-30 Werner Koch * packet.h (sigsubpkttype_t): Add SIGSUBPKT_FEATURES. (PKT_public_key, PKT_user_id): Add a flag for it. * parse-packet.c, build-packet.c: Add support for them. * getkey.c (fixup_uidnode, merge_selfsigs): Set the MDC flags. * keygen.c (add_feature_mdc): New. (keygen_upd_std_prefs): Always set the MDC feature. * keyedit.c (show_prefs): List the MDC flag * pkclist.c (select_mdc_from_pklist): New. * encode.c (encode_crypt, encrypt_filter): Test whether MDC should be used. * cipher.c (write_header): Set MDC use depending on the above test. Print more status info. * delkey.c (do_delete_key): Kludge to delete a secret key with no public key available. * ringedit.c (find_secret_keyblock_direct): New. * getkey.c (seckey_available): Simplified. * ringedit.c (cmp_seckey): Now compares the secret key against the public key while ignoring all secret parts. (keyring_search): Use a public key packet as arg. Allow to search for subnkeys (search): Likewise. Changed all callers. (find_secret_keyblock_bypk): New. (find_secret_keyblock_byname): First locate the pubkey and then find the correponding secret key. * parse-packet.c (parse): Renamed pkttype arg to onlykeypkts and changed code accordingly. Changed all callers. (search_packet): Removed pkttype arg. * keyedit.c (keyedit_menu): First locate the public key and then try to locate a secret key. * ringedit.c (locate_keyblock_by_fpr): Removed. (locate_keyblock_by_keyid): Removed. (find_keyblock_bysk): Removed. * sig-check.c (check_key_signature2): Print the keyid along with the wrong sig class errors. 2001-08-24 Werner Koch * sign.c (sign_file): Stripped the disabled comment packet code. (sign_file, sign_symencrypt_file): Moved common code to .. (write_onepass_sig_packets): .. this new function. (sign_file, clearsign_file, sign_symencrypt_file): Moved common code to (write_signature_packets): this new function. (write_signature_packets, make_keysig_packet) (update_keysig_packet): Moved common code to (hash_uid, hash_sigclass_to_magic): these new functions (sign_file, sign_symencrypt_file): Moved common code to (write_plaintext_packet): this new function. 2001-08-21 Stefan Bellon * trustdb.c (query_trust_info): Changed trustlevel to signed int. * g10.c [__riscos__]: Fixed handling of --use-agent --lock-multiple. 2001-08-20 Werner Koch * encr-data.c (decrypt_data): Keep track on whether we already printed information about the used algorithm. * mainproc.c (proc_encrypted): Removed the non-working IDEA hack and print a message about the assumed algorithm. * passphrase.c (passphrase_to_dek): Use the same algorithm as above. (proc_symkey_enc): Print the algorithm, so that the user knows it before entering the passphrase. (proc_pubkey_enc, proc_pubkey_enc): Zero the DEK out. * encode.c (encode_crypt, encrypt_filter): Ditto. * g10.c: Allow for --sign --symmetric. * sign.c (sign_and_symencrypt): New. Applied patches from Stefan Bellon to support RISC OS. Nearly all of these patches are identified by the __riscos__ macro. * compress.c: Added a couple of casts. * g10.c [__riscos__]: Some patches and new options foo-file similar to all foo-fd options. * gpgv.c, openfile.c, ringedit.c, tdbio.c: Minor fixes. Mainly replaced hardcoded path separators with EXTSEP_S like macros. * passprase.c [__riscos__]: Disabled agent stuff * trustdb.c (check_trust): Changed r_trustlevel to signed int to avoid mismatch problems in pkclist.c * pkclist.c (add_ownertrust): Ditto. * plaintext.c (handle_plaintext) [__riscos__]: Print a note when file can't be created. * options.h [__riscos__]: Use an extern unless included from the main module. * signal.c (got_fatal_signal) [__riscos__]: Close all files. 2001-08-14 Werner Koch * keygen.c (ask_algo): New arg r_usage. Allow for RSA keys. (gen_rsa): Enabled the code. (do_create): Enabled RSA branch. (parse_parameter_usage): New. (proc_parameter_file): Handle usage parameter. (read_parameter_file): Ditto. (generate_keypair): Ditto. (generate_subkeypair): Ditto. (do_generate_keypair): Ditto. (do_add_key_flags): New. (keygen_add_std_prefs): Use the new function. (keygen_add_key_flags_and_expire): New. (write_selfsig, write_keybinding): Handle new usage arg. * build-packet.c (build_sig_subpkt): Make sure that key flags go into the hashed area. * keygen.c (write_uid): Initialize the reference cunter. * keyedit.c (keyedit_menu): No more need to update the trustdb for preferences. Added calls to merge keblock. * kbnode.c (dump_kbnode): Print some more flags. 2001-08-10 Werner Koch Revamped the preference handling. * packet.h (prefitem_t, preftype_t): New. (PKT_public_key): Added a uid field. (PKT_user_id): Added field to store preferences and a reference counter. * parse-packet.c (parse_user_id,parse_photo_id): Initialize them * free-packet.c (free_user_id): Free them. (copy_user_id): Removed. (scopy_user_id): New. (cmp_user_ids): Optimized for identical pointers. (release_public_key_parts): Release the uid. (copy_public_key_with_new_namehash): Removed. (copy_prefs): New. * keyedit.c (menu_adduid): Use the new shallow copy user id. (show_prefs): Adjusted implementation. (keyedit_menu): No more need to update the trustdb after changing preferences. * getkey.c (fixup_uidnode): Store preferences. (find_by_name): Return a user id packet and remove namehash stuff. (lookup): Removed the unused namehash stuff. (finish_lookup): Added foundu arg. (pk_from_block): Removed the namehash arg and changed all callers. (merge_selfsigs): Copy prefs to all keys. * trustdb.c (get_pref_data): Removed. (is_algo_in_prefs): Removed. (make_pref_record): Deleted and removed all class. * pkclist.c (select_algo_from_prefs): Adjusted for the new preference implementation. * pubkey-enc.c (is_algo_in_prefs): New. (get_it): Use that new function. 2001-08-09 Werner Koch * build-packet.c (build_sig_subpkt): Fixed calculation of newarea->size. * g10.c (main): New option "--preference-list" * keyedit.c (keyedit_menu): New commands "setpref" and "updpref". (menu_set_preferences): New. * keygen.c (keygen_set_std_prefs): New. (set_one_pref): New. (check_zip_algo): New. (keygen_get_std_prefs): New. (keygen_upd_std_prefs): New (keygen_add_std_prefs): Move the pref setting code into the above fnc. * build-packet.c (build_sig_subpkt): Updated the list of allowed to update subpackets. 2001-08-08 Werner Koch * packet.h (subpktarea_t): New. (PKT_signature): Use that type for hashed_data and unhashed_data and removed the _data prefix from those fields. Changed all users. * parse-packet.c (parse_signature): Changed allocation for that. (parse_sig_subpkt): Changed declaration (enum_sig_subpkt): Ditto and changed implementation accordingly. * free-packet.c (cp_subpktarea): Renamed from cp_data_block and adjusted implementation. Changed caller. * sig-check.c (mdc_kludge_check): Adjusted the hashing. (do_check): Ditto. * sign.c (sign_file, clearsign_file, make_keysig_packet, update_keysig_packet): Ditto. * build-packet.c (build_sig_subpkt): Partial rewrite. (find_subpkt): Adjusted and made static. (delete_sig_subpkt): Adjusted. (do_signature): Ditto. * keygen.c (ask_keysize): Do not print the notes about suggested key sizes if just a DSA key is generated. * trustdb.c (add_ultimate_key): s/log_error/log_info/ for duplicated inserted trusted keys. 2001-08-07 Werner Koch * sign.c (sleep): Redefine for W32. * g10.c, options.h: Set new flag opt.no_homedir_creation when --no-options is given. * openfile.c (try_make_homedir): Don't create the homedir in that case. 2001-08-03 Werner Koch * armor.c (armor_filter): Removed the default comment string because it could get us in trouble due to translations using non ascii characters. 2001-08-01 Werner Koch * keylist.c (list_keyblock_print): Do not list revoked UIDs unless in verbose mode and we do no signature listing. * getkey.c (finish_lookup): Skip subkeys which are not yet valid. * g10.c, options.h: New option --ignore-valid-from. * sign.c (make_keysig_packet): Added new sigversion argument to allow the caller to force generation of required signature version. Changed all callers. Suggested by Thomas Roessler. * keyedit.c (sign_uids): Force v4 signature generation for local sigs. Removed the check for local signature and pre-v4 keys. 2001-07-27 Werner Koch * keyedit.c (sign_uids): Check that we are not trying to to a lsign with a pre-v4 key. Bug noticed by Thomas Roessler. 2001-07-26 Werner Koch * parse-packet.c (parse_photo_id): Reset all variables. * getkey.c (merge_selfsigs_main): Removed checks on PHOTO_ID because this is handled identically to a user ID. 2001-07-06 Werner Koch * cipher.c (write_header): Don't use MDC with --rfc1991. Suggested by disastry@saiknes.lv. 2001-07-05 Werner Koch * g10.c, options.h: New option --preserve-permissions. * ringedit.c (add_keyblock_resource): Use it here (keyring_copy): and here. * trustdb.c (verify_own_keys): Be more silent on --quiet. Suggested by Thomas Roessler. * sig-check.c (check_key_signature2): Ditto. * mainproc.c (proc_encrypted, proc_tree): Ditto * getkey.c (lookup): Ditto. 2001-07-04 Werner Koch * ringedit.c (add_keyblock_resource): Restore filename in case of error. 2001-06-25 Werner Koch * kbnode.c (dump_kbnode): Print the signature timestamp. * keyedit.c (keyedit_menu): New menu point "primary". (change_primary_uid_cb): New. (menu_set_primary_uid): New. * sign.c (update_keysig_packet): New. * build-packet.c (build_sig_subpkt): Put the primary UID flag into the hashed area. Allow update of some more packets. 2001-06-15 Werner Koch * getkey.c (merge_selfsigs): Exit gracefully when a secret key is encountered. May happen if a secret key is in public keyring. Reported by Francesco Potorti. 2001-06-12 Werner Koch * getkey.c (compare_name): Use ascii_memistr(), ascii_memcasecmp() * keyedit.c (keyedit_menu): Use ascii_strcasecmp(). * armor.c (radix64_read): Use ascii_toupper(). * ringedit.c (do_bm_search): Ditto. * keygen.c (read_parameter_file): Ditto. * openfile.c (CMP_FILENAME): Ditto. * g10.c (i18n_init): We can now use just LC_ALL. 2001-05-29 Werner Koch * keygen.c (generate_subkeypair): Print a warning if a subkey is created on a v3 key. Suggested by Brian M. Carlson. 2001-05-27 Werner Koch * keyid.c (get_lsign_letter): New. * keylist.c (list_keyblock_colon): Use it here. * mainproc.c (list_node): and here. * getkey.c, packet.h, free-packet.c: Removed that useless key created field; I dunno why I introducded this at all - the creation time is always bound to the key packet and subject to fingerprint calculation etc. * getkey.c (fixup_uidnode): Add keycreated arg and use this instead of the signature timestamp to calculate the help_key_expire. Bug reported by David R. Bergstein. (merge_selfsigs_main): Correct key expiration time calculation. (merge_selfsigs_subkey): Ditto. 2001-05-25 Werner Koch * revoke.c (gen_revoke): Add a cast to a tty_printf arg. * delkey.c (do_delete_key): Ditto. * keyedit.c (print_and_check_one_sig): Ditto. (ask_revoke_sig): Ditto. (menu_revsig): Ditto. (check_all_keysigs): Removed unused arg. 2001-05-23 Werner Koch * g10.c (opts): Typo fix by Robert C. Ames. 2001-05-06 Werner Koch * revoke.c: Small typo fix 2001-05-04 Werner Koch * passphrase.c (passphrase_clear_cache): Shortcut if agent usage is not enabled. 2001-05-01 Werner Koch * passphrase.c (writen): Replaced ssize_t by int. Thanks to to Robert Joop for reporting that SunOS 4.1.4 does not have it. 2001-04-28 Werner Koch * getkey.c (merge_public_with_secret): pkttype was not set to subkey. 2001-04-27 Werner Koch * skclist.c (build_sk_list): Changed one log_debug to log_info. 2001-04-25 Werner Koch * keyedit.c (show_prefs): Add a verbose mode. (show_key_with_all_names): Pass verbose flag for special value of with_pref. (keyedit_menu): New command "showpref" (show_key_with_all_names): Mark revoked uids and the primary key. 2001-04-24 Werner Koch * getkey.c (get_primary_uid): Return a different string in case of error and made it translatable. * build-packet.c (do_secret_key): Ugly, we wrote a zero instead of the computed ndays. Thanks to M Taylor for complaining about a secret key import problem. 2001-04-23 Werner Koch * hkp.c (hkp_ask_import): Allow to specify a port number for the keyserver. Add a kudge to set the no_shutdown flag. (hkp_export): Ditto. * options.skel: Document the changes 2001-04-20 Werner Koch * options.skel: Add some more comments. 2001-04-19 Werner Koch * keyid.c (mk_datestr): New. Handles negative times. We must do this because Windoze segvs on negative times passed to gmtime(). Changed all datestr_from function to use this one. * keyid.c, keyid.h (colon_strtime): New. To implement the fixed-list-mode. (colon_datestr_from_pk): New. (colon_datestr_from_sk): New. (colon_datestr_from_sig): New. * keylist.c (list_keyblock_colon): Use these functions here. * mainproc.c (list_node): Ditto. 2001-04-18 Werner Koch * openfile.c (open_sigfile): Fixed the handling of ".sign". * mainproc.c (proc_tree): Use iobuf_get_real_fname. Both are by Vincent Broman. 2001-04-14 Werner Koch * getkey.c (fixup_uidnode): Removed check for !sig which is pointless here. Thanks to Jan Niehusmann. 2001-04-10 Werner Koch * sig-check.c (check_key_signature2): Use log_info instead of log_error so that messed up keys do not let gpg return an error. Suggested by Christian Kurz. * getkey.c (merge_selfsigs_main): Do a fixup_uidnode only if we have both, uid and sig. Thanks to M Taylor. 2001-04-05 Werner Koch * armor.c (unarmor_pump_new,unarmor_pump_release): New. (unarmor_pump): New. * pipemode.c (pipemode_filter): Use the unarmor_pump to handle armored or non-armored detached signatures. We can't use the regular armor_filter because this does only check for armored signatures the very first time. In pipemode we may have a mix of armored and binary detached signatures. * mainproc.c (proc_tree): Do not print the "old style" notice when this is a pipemode processes detached signature. (proc_plaintext): Special handling of pipemode detached sigs. * packet.h (CTRLPKT_PLAINTEXT_MARK): New. * parse-packet.c (create_gpg_control): New. * kbnode.c (dump_kbnode): Support it here. * mainproc.c (check_sig_and_print): Fixed the check for bad sequences of multiple signatures. (proc_plaintext): Add the marker packet. (proc_tree): We can now check multiple detached signatures. 2001-04-02 Werner Koch The length of encrypted packets for blocksizes != 8 was not correct encoded. I think this is a minor problem, because we usually use partial length packets. Kudos to Kahil D. Jallad for pointing this out. * packet.h: Add extralen to PKT_encrypted. * cipher.c (write_header): Set extralen. * build-packet.c (do_encrypted): Use extralen instead of const 10. (do_encrypted_mdc): Ditto. * parse-packet.c (parse_encrypted): Set extralen to 0 because we don't know it here. 2001-03-30 Werner Koch * getkey.c (premerge_public_with_secret): Changed wording an add the keyID to the info message. 2001-03-29 Werner Koch * getkey.c (premerge_public_with_secret): Use log_info instead of log_error when no secret key was found for a public one. Fix the usage if the secret parts of a key are not available. * openfile.c (ask_outfile_name): Trim spaces. (open_outfile): Allow to enter an alternate filename. Thanks to Stefan Bellon. * plaintext.c (handle_plaintext): Ditto. 2001-03-28 Werner Koch * mainproc.c (do_check_sig): Allow direct key and subkey revocation signature. * sig-check.c (check_key_signature2): Check direct key signatures. Print the signature class along with an error. 2001-03-27 Werner Koch * packet.h: Add a missing typedef to an enum. Thanks to Stefan Bellon. * g10.c: New option --no-sig-create-check. * sign.c (do_sign): Implement it here. * g10.c: New option --no-sig-cache. * sig-check.c (check_key_signature2): Implement it here. (cache_selfsig_result): and here. * keylist.c (list_keyblock): Removed debugging stuff. * getkey.c (cache_public_key): Made global. * keygen.c (write_selfsig, write_keybinding): Cache the new key. * getkey.c (key_byname): Add new arg secmode and changed all callers to request explicitly the mode. Deriving this information from the other supplied parameters does not work if neither pk nor sk are supplied. 2001-03-25 Werner Koch * packet.h (ctrlpkttype_t): New. * mainproc.c (add_gpg_control,proc_plaintext,proc_tree): Use the new enum values. * pipemode.c (make_control): Ditto. * armor.c (armor_filter): Ditto. 2001-03-24 Werner Koch * sign.c (do_sign): Verify the signature right after creation. 2001-03-23 Werner Koch * status.c, status.h (STATUS_UNEXPECTED): New. * mainproc.c (do_proc_packets): And emit it here. 2001-03-21 Werner Koch * status.c: Add sys/types.h so that it runs on Ultrix. Reported by Georg Schwarz.x * build-packet.c (build_sig_subpkt): Fixed generaton of packet length header in case where 2 bytes headers are needed. Thanks to Piotr Krukowiecki. 2001-03-19 Werner Koch * g10.c (main): the default keyring is no always used unless --no-default-keyring is given. * ringedit.c (add_keyblock_resource): invalidate cache after file creation. 2001-03-15 Werner Koch * keygen.c (ask_algo): Changed the warning of the ElGamal S+E Algo. * keylist.c (print_capabilities): New. (list_keyblock_colon): and use it here. 2001-03-13 Werner Koch * main.c, options.h: New option --fixed_list_mode. * keylist.c (list_keyblock_colon): use it here. * getkey.c (merge_keys_and_selfsig): Divert merging of public keys to the function used in key selection.. * keylist.c (is_uid_valid): Removed. (list_keyblock): Splitted into .. (list_keyblock_print, list_keyblock_colon): .. these. functions. Changed them to use the flags set in the key lookup code. (reorder_keyblock): New, so that primary user IDs are listed first. * ringedit.c (keyring_copy): flush the new iobuf chaces before rename or remove operations. This is mainly needed for W32. * hkp.c [HAVE_DOSISH_SYSTEM]: Removed the disabled code because we have now W32 socket support in ../util/http.c * skclist.c (key_present_in_sk_list): New. (is_duplicated_entry): New. (build_sk_list): Check for duplicates and do that before unlocking. 2001-03-12 Werner Koch * armor.c (parse_header_line): Removed double empty line check. (parse_header_line): Replaced trim_trailing_ws with a counting function so that we can adjust for the next read. * options.skel: Fixed 3 typos. By Thomas Klausner. Replaced the keyserver example by a better working server. * parse-packet.c (parse_symkeyenc): Return Invalid_Packet on error. (parse_pubkeyenc): Ditto. (parse_onepass_sig): Ditto. (parse_plaintext): Ditto. (parse_encrypted): Ditto. (parse_signature): Return error at other places too. (parse_key): Ditto. * g10.c (main): Set opt.list_packets to another value when invoked with the --list-packets command. * mainproc.c (do_proc_packets): Don's stop processing when running under --list-packets command. * signal.c (do_sigaction): Removed. (init_one_signal): New to replace the above. Needed to support systems without sigactions. Suggested by Dave Dykstra. (got_fatal_signal,init_signals): Use the above here. (do_block): Use sigset() if sigprocmask() is not available. * armor.c (parse_hash_header): Test on TIGER192, which is the correct value as per rfc2440. By Edwin Woudt. 2001-03-08 Werner Koch * misc.c: Include time.h. By James Troup. * getkey.c: Re-enabled the unknown user Id and PK caches and increased their sizes. * getkey.c (merge_selfsigs_main): Set expire date and continue processing even if we found a revoked key. (merge_selfsigs_subkeys): Ditto. * packet.h: Add an is_revoked flag to the user_id packet. * getkey.c (fixup_uidnode): Set that flag here. (merge_selfsigs_main): Fix so that the latest signature is used to find the self-signature for an UID. * parse-packet.c (parse_user_id): Zero out all fields. * mainproc.c (check_sig_and_print): Print the primary user ID according the the node flag and then all other non-revoked user IDs. (is_uid_revoked): Removed; it is now handled by the key selection code. Changed the year list of all copyright notices. 2001-03-07 Werner Koch * getkey.c (finish_lookup): Print an info message only in verbose mode. 2001-03-05 Werner Koch * packet.h: Replaced sigsubpkt_t value 101 by PRIV_VERIFY_CACHE. We have never used the old value, so we can do this without any harm. * parse-packet.c (dump_sig_subpkt): Ditto. (parse_one_sig_subpkt): Parse that new sub packet. * build-packet.c (build_sig_subpkt): Removed the old one from the hashed area. (delete_sig_subpkt): New. (build_sig_subpkt): Allow an update of that new subpkt. * sig-check.c (check_key_signature2): Add verification caching (cache_selfsig_result): New. * export.c (do_export_stream): Delete that sig subpkt before exporting. * import.c (remove_bad_stuff): New. (import): Apply that function to all imported data 2001-03-03 Werner Koch * getkey.c: Introduced a new lookup context flag "exact" and used it in all place where we once used primary. (classify_user_id2): Replaced the old function and add an extra argument to return whether an exact keyID has been requested. (key_byname): Removed the unused ctx.primary flag (get_seckey_byname2): Ditto. (finish_lookup): Changed debugging output. 2001-03-02 Werner Koch * keylist.c (list_one): Remove the merge key calls. 2001-03-01 Werner Koch * getkey.c (finish_lookup): Don't use it if we no specific usage has been requested. (merge_selfsigs_main): fix UID only if we have an signature. (lookup): Return UNU_PUBKEY etc. instead of NO_PUBKEY if we found a key but the requested usage does not allow this key. * import.c (import_one): Take UNU_PUBKEY into account. * mainproc.c (list_node): Ditto. * keylist.c (list_keyblock): Ditto. * keyedit.c (print_and_check_one_sig): Ditto. 2001-02-09 Werner Koch * delkey.c (delete_key): Removed that silly assert which rendered the whole new stuff meaningless. 2001-02-08 Werner Koch * getkey.c (key_byname): It can happen that we have both, sk and pk NULL, fix for that. * parse-packet.c (parse_one_sig_subpkt): Add support for primary_uid and key_flags. (can_handle_critical): Ditto * parse-packet.c (parse_encrypted): Fixed listing of pktlen for MDC packets. * getkey.c: Backported the version of this file from gpg 1.1. this involved some changes in other files too. * parse-packet.c (parse_key): Clear req_usage. * skclist.c (build_sk_list): Use req_usage to pass the usage information to the lookup function. * pkclist.c (build_pk_list): Ditto. * free-packet.c (copy_public_parts_to_secret_key): New. * keydb.h: Add IS_* macros to check the sig_class. * misc.c (openpgp_cipher_test_algo): New. (openpgp_pk_test_algo): New. (openpgp_pk_algo_usage): New. (openpgp_md_test_algo): New. * packet.h: Add a few fields to PKT_{public,secret}_key and PKT_user_id. * seckey-cert.c (do_check): Use the new main_keyid field. 2001-02-04 Werner Koch * encr-data.c (decrypt_data): Catch error when we had problems to parse the encrypted packet. By Timo. 2001-01-29 Werner Koch * g10.c (main): --batch does now set nogreeting. * delkey.c (do_delete_key): Fixed delete-both functionality. 2001-01-22 Werner Koch * g10.c: New command --delete-secret-and-public-key. * delkey.c (delete_key): Add new arg allow_both. (do_delete_key): Move most stuff from above to this new function. 2001-01-12 Werner Koch * passphrase.c (passphrase_to_dek): Use MD5 when IDEA is installed and we have no S2K. * mainproc.c (proc_encrypted): Likewise 2001-01-11 Werner Koch * sig-check.c (do_check): Print the signature key expire message only in verbose mode and added the keyID. 2001-01-09 Werner Koch * status.c, status.h: New status USERID_HINT. (write_status_text): Replace LF and CR int text by C-escape sequence. * passphrase.c (passphrase_to_dek): Fixed the NEED_PASSPHRASE output. It does now always print 2 keyIDs. Emit the new USERID_HINT. 2001-01-08 Werner Koch * g10.c, options.h: New option --no-expensive-trust-checks. * keylist.c (list_keyblock): Act on this option. 2001-01-04 Werner Koch * g10.c (main): Set homedir only in the pre-parsing phase and replace backslashes in the W32 version. 2001-01-03 Werner Koch * status.c, status.h : New status KEY_CREATED * keygen.c (do_generate_keypair,generate_subkeypair): Emit it. 2000-12-28 Werner Koch * signal.c (got_fatal_signal): Remove lockfiles here because the atexit stuff does not work due to the use of raise. Suggested by Peter Fales. * gpgv.c (remove_lockfiles): New stub. 2000-12-19 Werner Koch * status.c, status.h (cpr_get_no_help): New. * keyedit.c (keyedit_menu): Use it here because we have our own help list here. 2000-12-18 Werner Koch * mainproc.c (print_failed_pkenc): Don't print the sometimes confusing message about unavailabe secret key. Renamed ... (print_pkenc_list): ... to this and introduced failed arg. (proc_encrypted): Print the failed encryption keys and then the one to be used. (proc_pubkey_enc): Store also the key we are going to use. * mainproc.c (check_sig_and_print): Don't list revoked user IDs. (is_uid_revoked): New. 2000-12-08 Werner Koch * pipemode.c: Made the command work. Currently only for non-armored detached signatures. * mainproc.c (release_list): Reset the new pipemode vars. (add_gpg_control): Handle the control packets for pipemode * status.c, status.h: New stati {BEGIN,END}_STREAM. 2000-12-07 Werner Koch * g10.c: New option --allow-secret-key-import. * import.c (import_keys,import_keys_stream): Honor this option. (import): New arg allow_secret and pass that arg down to ... (import_secret_one): to this and print a warning if secret key importing is not allowed. 2000-12-05 Werner Koch * cipher.c (cipher_filter): Moved the end_encryption status ... * encode.c (encode_simple,encode_crypt): to here * sign.c (sign_file): and here. * status.c (mywrite): Removed. (get_status_string): Removed the LFs from the strings. (set_status_fd,is_status_enabed,write_status_text, write_status_buffer): Replaced all mywrite by stdio calls and use fdopen to create a strem. This is needed to make things smoother in the W32 version. 2000-12-04 Werner Koch * import.c (merge_blocks): Increment n_sigs for revocations. 2000-11-30 Werner Koch * g10.c (main): Use iobuf_translate_file_handle for all options with filehandles as arguments. This is function does some magic for the W32 API. * verify.c (verify_signatures): Add a comment rant about the detached signature problem. * mainproc.c (proc_tree): Issue an error if a detached signature is assumed but a standard one was found. * plaintext.c (hash_datafiles): Don't fall back to read signature from stdin. * openfile.c (open_sigfile): Print verbose message only if the file could be accessed. 2000-11-24 Werner Koch * passphrase.c [HAVE_DOSISH_SYSTEM]: Disabled all the agent stuff. 2000-11-16 Werner Koch * g10.c: New option --use-agent * passphrase.c (agent_open,agent_close): New. (agent_get_passphrase,agent_clear_passphrase): New. (passphrase_clear_cache): New. (passphrase_to_dek): Use the agent here. * seckey-cert.c (do_check): Clear cached passphrases. 2000-11-15 Werner Koch * status.c (write_status_text): Moved the big switch to ... (get_status_string): ... new function. (write_status_buffer): New. * status.c (mywrite): New and replaced all write() by this. * status.c, status.h: Add 3 status lcodes for notaions and policy. * mainproc.c (print_notation_data): Do status output of notations. 2000-11-13 Werner Koch * sign.c (clearsign_file): Use LF macro to print linefeed. 2000-11-11 Paul Eggert Clean up the places in the code that incorrectly use "long" or "unsigned long" for file offsets. The correct type to use is "off_t". The difference is important on large-file hosts, where "off_t" is longer than "long". * keydb.h (struct keyblock_pos_struct.offset): Use off_t, not ulong, for file offsets. * packet.h (dbg_search_packet, dbg_copy_some_packets, search_packet, copy_some_packets): Likewise. * parse-packet.c (parse, dbg_search_packet, search_packet, dbg_copy_some_packets, copy_some_packets): Likewise. * ringedit.c (keyring_search): Likewise. * parse-packet.c (parse): Do not use %lu to report file offsets in error diagnostics; it's not portable. * ringedit.c (keyring_search): Likewise. 2000-11-09 Werner Koch * g10.c (main): New option --enable-special-filenames. 2000-11-07 Werner Koch * g10.c (main): New command --pipemode. * pipemode.c: New. 2000-10-23 Werner Koch * armor.c (armor_filter): Changed output of hdrlines, so that a CR is emitted for DOS systems. * keygen.c (read_parameter_file): Add a cast for isspace(). * status.c (myread): Use SIGINT instead of SIGHUP for DOS. 2000-10-19 Werner Koch * g10.c: New option --ignore-crc-error * armor.c (invalid_crc): New. (radix64_read): Act on new option. * openfile.c (try_make_homedir): Klaus Singvogel fixed a stupid error introduced on Sep 6th. 2000-10-18 Werner Koch * misc.c (print_cipher_algo_note): Don't print the note for AES. Changed wording. 2000-10-16 Werner Koch * mainproc.c (do_proc_packets): Hack to fix the problem that signatures are not detected when there is a MDC packet but no compression packet. * g10.c (print_hashline): New. (print_mds): Use above func with --with-colons. * mainproc.c (check_sig_and_print): Detect multiple signatures and don't verify them. 2000-10-14 Werner Koch * mainproc.c (add_onepass_sig): There is an easier solution to the error fixed yesterday; just check that we only have onepass packets. However, the other solution provides an cleaner interface and opens the path to get access to other information from the armore headers. (release_list): Reset some more variables. 2000-10-13 Werner Koch * mainproc.c (add_gpg_control): New. (do_proc_packets): use it. (proc_plaintext): Changed logic to detect clearsigns. (proc_tree): Check the cleartext sig with some new code. * packet.h: New packet PKT_GPG_CONTROL. * parse-packet.c (parse_gpg_control): New. * misc.c (get_session_marker): New. * armor.c (armor_filter): Replaced the faked 1-pass packet by the new control packet. * keyedit.c (keyedit_menu): Allow batchmode with a command_fd. * status.c (my_read): New. (do_get_from_fd): use it. 2000-10-12 Werner Koch * keygen.c (keygen_add_std_prefs): Add Rijndael to the prefs. 2000-10-07 Werner Koch * gpgv.c: Add more stubs for ununsed code to make the binary smaller. Wed Oct 4 15:50:18 CEST 2000 Werner Koch * sign.c (hash_for): New arg to take packet version in account, changed call callers. * gpgv.c: New. * Makefile.am: Rearranged source files so that gpgv can be build with at least files as possible. Mon Sep 18 12:13:52 CEST 2000 Werner Koch * hkp.c (not_implemented): Print a notice for W32 Fri Sep 15 18:40:36 CEST 2000 Werner Koch * keygen.c (keygen_add_std_prefs): Changed order of preferences to twofish, cast5, blowfish. * pkclist.c (algo_available): Removed hack to disable Twofish. Thu Sep 14 17:45:11 CEST 2000 Werner Koch * parse-packet.c (dump_sig_subpkt): Dump key flags. Print special warning in case of faked ARRs. * getkey.c (finsih_lookup): Hack so that for v4 RSA keys the subkey is used for encryption. Thu Sep 14 14:20:38 CEST 2000 Werner Koch * g10.c (main): Default S2K algorithms are now SHA1 and CAST5 - this should solve a lot of compatibility problems with other OpenPGP apps because those algorithms are SHOULD and not optional. The old way to force it was by using the --openpgp option whith the drawback that this would disable a couple of workarounds for PGP. * g10.c (main): Don't set --quite along with --no-tty. By Frank Tobin. * misc.c (disable_core_dump): Don't display a warning here but a return a status value and ... * g10.c (main): ...print warnining here. Suggested by Sam Roberts. Wed Sep 13 18:12:34 CEST 2000 Werner Koch * keyedit.c (keyedit_menu): Allow to use "debug" on the secret key. * ringedit.c (cmp_seckey): Fix for v4 RSA keys. * seckey-cert.c (do_check): Workaround for PGP 7 bug. Wed Sep 6 17:55:47 CEST 2000 Werner Koch * misc.c (print_pubkey_algo_note): Do not print the RSA notice. * sig-check.c (do_signature_check): Do not emit the RSA status message. * pubkey-enc.c (get_session_key): Ditto. * encode.c (encode_simple, encode_crypt): Fix for large files. * sign.c (sign_file): Ditto. Wed Sep 6 14:59:09 CEST 2000 Werner Koch * passphrase.c (hash_passphrase): Removed funny assert. Reported by David Mathog. * openfile.c (try_make_homedir): Changes for non-Posix systems. * g10.c (main): Take the default homedir from macro. * g10.c: The --trusted-key option is back. * trustdb.c (verify_own_key): Handle this option. (add_ultimate_key): Moved stuff from verify_own_key to this new func. (register_trusted_key): New. Fri Aug 25 16:05:38 CEST 2000 Werner Koch * parse-packet.c (dump_sig_subpkt): Print info about the ARR. * openfile.c (overwrite_filep): Always return okay if the file is called /dev/null. (make_outfile_name): Add ".sign" to the list of know extensions. (open_sigfile): Ditto. Wed Aug 23 19:52:51 CEST 2000 Werner Koch * g10.c: New option --allow-freeform-uid. By Jeroen C. van Gelderen. * keygen.c (ask_user_id): Implemented here. Fri Aug 4 14:23:05 CEST 2000 Werner Koch * status.c (do_get_from_fd): Ooops, we used fd instead of opt.command_fd. Thanks to Michael Tokarev. Tue Aug 1 20:06:23 CEST 2000 Werner Koch * g10.c: New opttion --try-all-secrets on suggestion from Matthias Urlichs. * pubkey-enc.c (get_session_key): Quite easy to implement here. Thu Jul 27 17:33:04 CEST 2000 Werner Koch * g10.c: New option --merge-only. Suggested by Brendan O'Dea. * import.c (import_one): Implemented it here (import_secret_one): Ditto. (print_stats): and give some stats. Thu Jul 27 12:01:00 CEST 2000 Werner Koch * g10.c: New options --show-session-key and --override-session-key * pubkey-enc.c (hextobyte): New. (get_override_session_key): New. * mainproc.c (proc_pubkey_enc): Add session-key stuff. * status.h, status.c (STATUS_SESSION_KEY): New. Thu Jul 27 10:02:38 CEST 2000 Werner Koch * g10.c (main): Use setmode(O_BINARY) for MSDOS while generating random bytes (print_mds): Likewise for stdin. * plaintext.c (handle_plaintext): Likewise for stdout. Mon Jul 24 10:30:17 CEST 2000 Werner Koch * keyedit.c (menu_expire): expire date for primary key can be set again. Wed Jul 19 11:26:43 CEST 2000 Werner Koch * keylist.c (is_uid_valid): New. (list_keyblock): Print validity information for all user IDs. Note, this has to be done at other places too; for now we have only minimal support. Wed Jul 12 13:32:06 CEST 2000 Werner Koch * helptext.c, pkclist.c: s/superseeded/superseded/ Mon Jul 10 16:08:57 CEST 2000 Werner Koch * parse-packet.c (enum_sig_subpkt): Fixed testing on crtitical bit in case of a NULL buffer. Reported by Peter Marschall. Wed Jul 5 13:28:45 CEST 2000 Werner Koch * keyedit.c, keyid.c: Add some _() * argparse.c: Changed the flag to suppress --version handling to also suppress --help. Wed Jun 28 11:54:44 CEST 2000 Werner Koch * armor.c (armor_filter): Set sigclass to 0 in case of non-dash-escaped clearsig. This makes this mode work again. * mainproc.c (proc_tree): Fixed handling of one-pass-sig packets in textmode. Disabled the ugly workaround for PGP 5 - let's see whether thi breaks less cases. Found by Ted Cabeen. * options.h (DBG_HASHING): New. All commented md_start_debug are now controlled by this debug option. * sign.c (print_status_sig_created): New and called from 2 places. * keygen.c (gen_rsa): New, but commented. (ask_algo): Commented support for RSA. * seckey-cert.c (protect_secret_key): Started to fix the code for v4 RSA keys - it is not solved yet. However, we have time until, Sep 20th ;) Wed Jun 14 12:27:09 CEST 2000 Werner Koch * status.c (init_shm_coprocessing): Changed the sequence of the get,attach to cope with the changes in newer Linux kernels. This bug has been found by who also proposed this solution. Hopefully this does not break gpg on to many systems. * cipher.c (write_header): Protect the IV with the MDC too. * encr-data.c (decrypt_data): Likewise. Fri Jun 9 10:09:52 CEST 2000 Werner Koch * g10.c: New options --no-auto-key-retrieve * options.h (auto_key_retrieve): New. * mainproc.c (check_sig_and_print): Implemented that. Wed Jun 7 19:19:09 CEST 2000 Werner Koch * sig-check.c (do_check): Use EMULATE_MDENCODE also on v4 packets. Wed Jun 7 17:25:38 CEST 2000 Werner Koch * cipher.c (write_header): Use plain CFB mode for MDC encrypted packets. * encr-data.c (decrypt_data): Ditto. Mon Jun 5 23:41:54 CEST 2000 Werner Koch * seskey.c (do_encode_md, encode_md_value): Add new arg v3compathack to work around a bug in old versions. * sig-check.c (do_check): use the aboved workaround when enabled. * g10.c: New option --emulate-md-decode-bug Mon Jun 5 12:37:43 CEST 2000 Werner Koch * build-packet.c (do_mdc): New. (do_encrypted_mdc): Changed for the new proposal. * parse-packet.c (parse_mdc): New. (parse_encrypted): Fixed for the new proposal. * packet.h (PKT_MDC): New. * cipher.c (cipher_filter): Build the MDC packet here. * g10.c (main): Enable --force-mdc. * encr-data.c (mdc_decode_filter): Fixed for new MDC method * options.h(rfc2440): New. * g10.c (main): Changed the selected values for --openpgp to not include optional algorithms. Thu May 18 11:38:54 CEST 2000 Werner Koch * keyedit.c (keyedit_menu): Add a keyword arg to the prompt. * status.c, status.h: Added 3 new status tokens. * status.c (do_get_from_fd): New. (cpr_enabled,cpr_get,cpr_get_hidden,cpr_kill_prompt, cpr_get_answer_is_yes,cpr_get_answer_yes_no_quit): Modified to work with the new function. * g10.c: Add new option --command-fd. * status.c (progress_cb): New. (set_status_fd): Register progress functions Fri May 12 14:01:20 CEST 2000 Werner Koch * delkey.c (delete_key): Add 2 new status messages * status.c, status.h (STATUS_DELETE_PROBLEM): New. Fixed years of copyright in all source files. Mon May 1 17:08:14 CEST 2000 Werner Koch * trustdb.c (propagate_validity): Fixed the bug that only one uid gets fully trusted even when all are signed by an ultimate key. Mon May 1 15:38:04 CEST 2000 Werner Koch * getkey.c (key_byname): Always returned a defined context. Fixed a segv for invalid user id specifications. Reported by Walter Koch. * getkey.c (get_user_id): I18ned "no user id" string. By Walter. * pkclist.c (do_show_revocation_reason): Typo fixes. * helptext.c: Ditto. * armor.c (armor_filter): Fixed some CRLF issues. By Mike McEwan. Fri Apr 14 19:37:08 CEST 2000 Werner Koch * pkclist.c (do_show_revocation_reason): New. (show_revocation_reason): New and called at various places. * g10.c (main): Fixed small typo. * pkclist.c (do_we_trust): Act on always_trust but not for revoked keys. Suggested by Chip Salzenberg. * g10.c: New option --lock-never. * ringedit.c (get_writable_keyblock_file): New. * keygen.c (do_generate_keypair): Use this instead of the hardwired one. * keygen.c (ask_user_id): Check that the email address is in the correct field. Suggested by Christian Kurz. Mon Apr 10 13:34:19 CEST 2000 Werner Koch * keyedit.c (show_key_with_all_names): s/sbb/ssb/ Tue Mar 28 14:26:58 CEST 2000 Werner Koch * trustdb.c (verify_own_keys): Do not print warning about unprotected key when in quiet mode. Wed Mar 22 13:50:24 CET 2000 Werner Koch * mainproc.c (print_userid): Do UTF8 conversion before printing. * import.c (import_one): Ditto. (import_secret_one): Ditto. (delete_inv_parts): Ditto. Thu Mar 16 16:20:23 CET 2000 Werner Koch * keylist.c (print_key_data): Handle a NULL pk gracefully. * getkey.c (merge_one_pk_and_selfsig): Fixed silly code for getting the primary keys keyID but kept using the one from the subkey. * pubkey-enc.c (get_it): Print a note for expired subkeys. * getkey.c (has_expired): New. (subkeys_expiretime): New. (finish_lookup): Check for expired subkeys needed for encryption. (merge_keys_and_selfsig): Fixed expiration date merging for subkeys. * keylist.c (list_keyblock): Print expiration time for "sub". (list_one): Add missing merging for public keys. * mainproc.c (list_node): Ditto. 2000-03-14 13:49:38 Werner Koch (wk@habibti.openit.de) * keygen.c (keyedit_menu): Do not allow to use certain commands while the secret key is selected. 2000-03-09 12:53:09 Werner Koch (wk@habibti.openit.de) * keygen.c (ask_expire_interval): Movede parsig to ... (parse_expire_string): ... this new function. And some new control commands. (proc_parameter_file): Add expire date parsing. (do_generate_keypair): Allow the use of specified output files. 2000-03-08 10:38:38 Werner Koch (wk@habibti.openit.de) * keygen.c (ask_algo): Removed is_v4 return value and the commented code to create Elg keys in a v3 packet. Removed the rounding of key sizes here. (do_create): Likewise removed arg v4_packet. (gen_elg): Likewise removed arg version. Now rounding keysizes here. (gen_dsa): Rounding keysize now here. (release_parameter_list): New (get_parameter*): New. (proc_parameter_file): New. (read_parameter_file): New. (generate_keypair): Splitted. Now uses read_parameter_file when in batch mode. Additional argument to specify a parameter file. (do_generate_keypair): Main bulk of above fucntion and uses the parameter list. (do_create): Don't print long notice in batch mode. * g10.c (main): Allow batched key generation. Thu Mar 2 15:37:46 CET 2000 Werner Koch * pubkey-enc.c (get_it): Print a note about unknown cipher algos. * g10.c (opts): Add a note to the help listing about the man page and removed some options from the help listing. * keyedit.c (print_and_check_one_sig): Use a new function to truncate the output of the user ID. Suggested by Jan-Benedict Glaw. Wed Feb 23 10:07:57 CET 2000 Werner Koch * helptext.c: typo fix. Thu Feb 17 13:39:32 CET 2000 Werner Koch * revoke.c: Removed a bunch of commented code. * packet.h (SIGSUBPKT_REVOC_REASON): New. * build-packet.c (build_sig_subpkt): Support new sub packet. * parse-packet.c (parse_one_sig_subpkt): Ditto. (dump_sig_subpkt): Ditto. * revoke.c (ask_revocation_reason): New. (release_revocation_reason_info): New. (revocation_reason_build_cb): New. (gen_revoke): Ask for reason. * main.h (struct revocation_reason_info): Add declaration. * keyedit.c (menu_revsig): Add support for revocation reason. (menu_revkey): Ditto. (sign_uid_mk_attrib): Renamed to ... (sign_mk_attrib): ... this, made static and add support for reasons. Tue Feb 15 08:48:13 CET 2000 Werner Koch * build-packet.c (build_packet): Fixed fixing of old comment packets. * import.c (import_keys): Fixed importing from stdin when called with nnames set to zero as it normally happens. Mon Feb 14 14:30:20 CET 2000 Werner Koch * sig-check.c (check_key_signature2): Add new arg r_expired. (do_signature_check): New arg to pass it down to ... (do_check): New arg r-expire which is set when the signature has expired. * trustdb.c (check_sig_record): Set SIGF_EXPIRED flag and set the expiretime to zero so that thi signature will not be checked anymore. Fri Feb 11 17:44:40 CET 2000 Werner Koch * g10.c (g10_exit): Update the random seed_file. (main): Set the random seed file. New option --no-random-seed-file. Thu Feb 10 17:39:44 CET 2000 Werner Koch * keyedit.c (menu_expire): Fixed segv due to unitialized sub_pk. By Rémi. Thu Feb 10 11:39:41 CET 2000 Werner Koch * keylist.c (list_keyblock): Don't print warnings in the middle of regulat output lines. By Rémi. * sig-check.c: Include options.h Wed Feb 9 15:33:44 CET 2000 Werner Koch * gpg.c: New option --ignore-time-conflict * sig-check.c (do_check): Implemented this option. * trustdb.c (check_trust): Ditto. * sign.c (do_sign): Ditto. * keygen.c (generate_subkeypair): Ditto. * encode.c (encode_simple): use iobuf_cancel after open failure. Reported by Huy Le. Fri Jan 14 18:32:01 CET 2000 Werner Koch * packet.h (STRING2KEY): Changed mode from byte to int. * parse-packet.c (parse_key): Add the special GNU protection stuff * build-packet.c (so_secret_key): Ditto. * seckey-cert.c (do_check): Ditto. * keyedit.c (change_passphrase): Ditto. * export.c (export_secsubkeys): New. (do_export_stream): Hack to export the primary key using mode 1001. * g10.c: New command --export-secret-subkeys Thu Jan 13 19:31:58 CET 2000 Werner Koch * armor.c (is_armored): Check for 1-pass-sig packets. Reported by David Hallinan . (armor_filter): Replaced one LF by the LF macro. Reported by Wolfgang Redtenbacher. Wed Jan 5 11:51:17 CET 2000 Werner Koch * g10.c (main): Reset new global flag opt.pgp2_workarounds when --openpgp is used. * mainproc.c (proc_plaintext): Do the PGP2,5 workarounds only when the global flag is set. (proc_tree): Ditto. * textfilter.c (copy_clearsig_text): Ditto. * armor.c (armor_filter): Ditto. * g10.c: New option --list-only * mainproc.c (proc_tree): Don't do it if opt.list_only is active. (proc_pubkey_enc): Implement option. * status.h, status.c ({BEGIN,END}_{EN,DE}CRYPTION): New. * cipher.c (cipher_filter): New status outputs. * mainproc.c (proc_encrypted): New status outputs. Fri Dec 31 14:08:15 CET 1999 Werner Koch * armor.c (armor_filter): Made the "Comment:" header translatable. * hkp.c (hkp_import): Make sure that the program does not return success when there is a connection problem. Reported by Phillip Jones. Sun Dec 19 15:22:26 CET 1999 Werner Koch * armor.c (LF): Use this new macro at all places where a line LF is needed. This way DOSish textfiles should be created when the input data is also in dos mode. * sign.c (LF): Ditto. * textfilter.c (LF): Ditto. (copy_clearsig_text): Disabled the forcing of CR,LF sequences for DOS systems. * plaintext.c (handle_plaintext): Fixes for line endings on DOS. and react on a LF in cleartext. * armor.c (fake_packet): Restore the original line ending after removing trailing spaces. * signal.c (got_fatal_signal): DOS fix. Thu Dec 16 10:07:58 CET 1999 Werner Koch * mainproc.c (print_failed_pkenc): Fix for unknown algorithm. Found by fygrave@epr0.org. Thu Dec 9 10:31:05 CET 1999 Werner Koch * hkp.c: i18n the strings. Sat Dec 4 15:32:20 CET 1999 Werner Koch * trustdb.c (verify_key): Shortcut for ultimately trusted keys. Sat Dec 4 12:30:28 CET 1999 Werner Koch * pkclist.c (build_pk_list): Validate the trust using the namehash if this one has been set by the key lookup. * g10.c: Add --delete-secret-key to the help page. * openfile.c (copy_options_file): Made static. (try_make_homedir): New. * ringedit.c (add_keyblock_resource): Use the try_make_hoemdir logic. * tdbio.c (tdbio_set_dbname): Likewise. * keygen.c (generate_user_id): Use m_alloc_clear() here. We should better use an allocation function specific to the user_id packet. * keygen.c (keygen_add_std_prefs): Changed symmetric preferences to include Blowfish again. This is due to it's better speed compared to CAST5. * g10.c (strusage): Print the home directory. * armor.c (armor_filter): Take action on the cancel control msg. * filter.h (armor_filter_context_t): Add cancel flag. Mon Nov 29 21:52:11 CET 1999 Werner Koch * g10.c: New option --fast-list-mode .. * keylist.c (list_keyblock): .. and implemented. * mainproc.c (list_node): Ditto. * import.c (mark_non_selfsigned_uids_valid): Fixed the case that there is a uid without any packet following. Mon Nov 22 11:14:53 CET 1999 Werner Koch * mainproc.c (proc_plaintext): Never enable the hash processing when skip_verify is active. * armor.c (parse_header_line): Stop parsing on a WS line too. Suggested by Aric Cyr. * tdbdump.c (HEXTOBIN): Changed the name of the argument, so that traditional cpp don't mess up the macros. Suggested by Jos Backus. * mainproc.c (list_node): Print the PK algo in the --with-colon mode. * keylist.c (list_keyblock): Ditto. * signal.c (got_fatal_signal): Found the reason why exit(8) did not work - it is better to set the disposition back to default before raising the signal. Print the notice on stderr always. Fri Nov 12 20:33:19 CET 1999 Werner Koch * g10.c (make_username): Swapped the logic. * keylist.c (public_key_list): Now takes a STRLIST as arg and moved the creation ot this list to the caller, so that he can copy with UTF-conversion of user IDs. Changed all callers. (secret_key_list): Likewise. * getkey.c (get_user_id_string_native): New and ... * encode.c (write_pubkey_enc_from_list): ... use it here. * pubring.asc: Updated. * packet.h (PKT_PHOTO_ID): New. * parse-packet.c (parse_photo_id): New. * build-packet.c (do_user_id: Handle photo IDs. (build_packet): Change CTB for photo IDs * free-packet.c (free_user_id): Release memory used for photo IDs * sig-check.c (hash_uid_node): Handle photo IDs too. * trustdb.c (print_uid_from_keyblock): Hash photo ID. (make_uid_records): Ditto. * getkey.c (find_by_name): Ditto. * keyedit.c (show_prefs): Ditto. * keylist.c (list_keyblock): Ditto. Thu Oct 28 16:08:20 CEST 1999 Werner Koch * keygen.c (ask_expire_interval): Print a warning for systems with a signed 32 time_t if the exiration time is beyoind 2038. Fri Oct 8 20:40:50 CEST 1999 Werner Koch * ringedit.c (enum_keyblocks): The last fix way really stupid; reverted and set rt to Unknown. Fri Oct 8 20:32:01 CEST 1999 Werner Koch * ringedit.c (enum_keyblocks): Zero the entire kbpos out on open. * g10.c (oEntropyDLL): Removed option. (main): Made the warning on development versions more verbose. * g10.c (oHonorHttpProxy): New option. * hkp.c (hkp_ask_import,hkp_export): Implement this option. * options.skel: Enable this option for new installations Mon Oct 4 21:23:04 CEST 1999 Werner Koch * import.c (import_keys): Changed calling interface, adjusted caller. (import): Moved printing of stats out ... (print_stats): New. ... to here. (import_keys_stream): Call stats print here. (import_keys): Print stats as totals for all files. * tdbio.h (DIRF_NEWKEYS): New * tdbio.c (tdbio_dump_record): Print the new flag. * trustdb.c (check_trust_record): New arg sigs_only. Adapted all callers. (do_update_trust_record): Removed recheck arg and add a new sigs_only do we can later improve on the performance. Changed all callers too. (check_trustdb): Evalutate the new flag and add a status output. Do a check when the dir record has not been checked. (build_cert_tree): Evaluate the new flag. (check_trust): Ditto. Do a trust_record check, when the dir record is not marked as checked. (mark_fresh_keys): New. (clear_lid_table): New. (sync_trustdb): New. * import.c (import_keys): Call sync_trustdb() after processing. (import_keys_stream): Ditto. * tdbdump.c (import_ownertrust): Ditto. * import.c (import_revoke_cert): Notify the trust DB. (do_update_trust_record): Use |= to set the REVOKED bit and not &=; shame on me for this bad copy+paste introduced bug. (do_we_trust): Add trustmask to allow revoked key override to work. Chnaged are to allow return of a mofified trustlevel. Adapted the one caller. * g10.c: New options --emulate-3des-s2k-bug * passphrase.c (hash_passphrase): Implemented above. * mainproc.c (proc_tree): Check for standalone signatures. (do_check_sig): Print a notice for a standalone revocation (check_sig_and_print): Do not print an error for unchecked standalone revocations. Tue Sep 28 20:54:37 CEST 1999 Werner Koch * encode.c (encode_simple): Use new CTB when we don't have the length of the file. This is somewhat strange as the comment above indicates that this part is actually fixed for PGP 5 - maybe I simply lost the source line, tsss. * armor.c (armor_filter): Set a flag if no OpenPGP data has been found. * verify.c (verify_signatures): Add an error helptext. Thu Sep 23 19:24:30 CEST 1999 Werner Koch * openfile.c (open_outfile): Fixed the 8dot3 handling. * passphrase.c (passphrase_to_dek): Print uid using utf8 func. * delkey.c (delete_key): Ditto. * pkclist.c (show_paths,do_edit_ownertrust,do_we_trust): Ditto (do_we_trust_pre): Ditto. * trustdb.c (print_user_id,check_uidsigs): Ditto. * revoke.c (gen_revoke,ask_revoke_sig): Ditto. Thu Sep 23 09:52:58 CEST 1999 Werner Koch * verify.c (print_file_status): New. (verify_one_file): Moved status print to th new fnc. Add error status. * status.c, status.h (STATUS_FILE_ERROR): New Wed Sep 22 10:14:17 CEST 1999 Werner Koch * openfile.c (make_outfile_name): Use case-insenstive compare for DOS systems. Add ".pgp" to the list of know extensions. (open_outfile): For DOS systems try to replace the suffiy instead of appending it. * status.c, status.h: Add STATUS_FILE_{START,DONE}. * verify.c (verify_one_file): Emit these new stati. * sign.c (clearsign_file): Avoid duplicated Entries in the "Hash:" line. Those headers are now only _not_ printed when there are only old-style keys _and_ all hashs are MD5. Mon Sep 20 12:24:41 CEST 1999 Werner Koch * verify.c (verify_files, ferify_one_file): New. * g10.c: New command --verify-files Fri Sep 17 12:56:42 CEST 1999 Werner Koch * g10.c: Add UK spelling as alias for armor options ;-) * import.c (append_uid): Fixed a SEGV when there is no selfsig and no subkey. (merge_sigs): Ditto. Removed the assertion. Wed Sep 15 16:22:17 CEST 1999 Werner Koch * g10.c: New option --entropy-dll-name Mon Sep 13 10:51:29 CEST 1999 Werner Koch * signal.c (got_fatal_signal): Print message using write(2) and only for development versions. Mon Sep 6 19:59:08 CEST 1999 Werner Koch * tdbio.c (tdbio_set_dbname): Use mkdir macro * ringedit.c (add_keyblock_resource): Ditto. Fri Sep 3 10:04:45 CEST 1999 Werner Koch * pkclist.c (build_pk_list): Skip keys set with --encrypt-to also when asking for a key. * plaintext.c (handle_plaintext): Make sure that we don't read a second EOF in the read loop for partial length packets. * mainproc.c (check_sig_and_print): print user ID as utf-8. Thu Sep 2 16:40:55 CEST 1999 Werner Koch * import.c (merge_blocks): First add new subkeys, then merge subkey certificates. (merge_sigs): Don't merge subkey signatures here. Wed Sep 1 15:30:44 CEST 1999 Werner Koch * keygen.c (ask_expire_interval): Fixed bug related to cpr_xx (tnx Francis J. Lacoste). Tue Aug 31 17:20:44 CEST 1999 Werner Koch * plaintext.c (do_hash): Hash CR,LF for a single CR. (ask_for_detached_datafile): Changed arguments to be closer to those of hash_datafiles and cleanup the code a bit. * mainproc.c (proc_tree): Workaround for pgp5 textmode detached signatures. Changed behavior of asking for data file to be the same as with provided data files. * keylist.c (list_keyblock): Use UTF8 print functions. Mon Aug 30 20:38:33 CEST 1999 Werner Koch * import.c (chk_self_sigs): some s/log_error/log_info/ so that gpg does not return an error if a key has some invalid packets. * helptext.c: Fixed some typos and changed the way the translation works. The english text is now the keyword for gettext and not anymore the keyword supplied to the function. Done after some discussion with Walter who thinks this is much easier for the translators. * misc.c (disable_core_dumps): Don't do it for DOSish systems. * signal.c (signal_name): Bounds check on signum. Wed Aug 4 10:34:18 CEST 1999 Werner Koch * pubring.asc: Updated. * pkclist.c (do_we_trust_pre,check_signatures_trust): Do not print the warning about --always_trust when --quiet is used. * pkclist.c (fpr_info): New and called at several places. * parse-packet.c (dump_sig_subpkt): List revocation key contents. Mon Jul 26 09:34:46 CEST 1999 Werner Koch * pkclist.c (build_pk_list): Fixed typo in format string. * trustdb.c (create_shadow_dir): Don't translate the error string. * g10.c (main): Fixed spelling of user-id. * getkey.c (find_by_name_pk,find_by_name_sk, find_by_keyid,find_by_keyid_sk): Ditto and translate it. * import.c (mark_non_selfsigned_uids_valid,delete_inv_parts): Ditto. Mon Jul 26 01:01:39 CEST 1999 Michael Roth * g10.c, options.h: New options --no-literal and --set-filesize * encode.c (encode_simple, encode_crypt): Support for the options --no-literal and --set-filesize. * sign.c (sign_file): ditto. Fri Jul 23 13:53:03 CEST 1999 Werner Koch * ringedit.c (enum_keyblocks): Removed annoying error message in cases when we have no keyring at all to enum. * getkey.c (classify_user_id): Rewrote to relax the recognition of keyIDs and fingerprints (Michael). * mainproc.c (check_sig_and_print): Print status NO_PUBKEY. (print_failed_pkenc): Print status NO_SECKEY. * import.c (mark_non_selfsigned_uids_valid): New. * g10.c: New option --allow-non-selfsigned-uid. * pkclist.c (print_fpr): New. (do_we_trust_pre): Print the fpr before asking whether to use the key anyway. (do_edit_ownertrust): Likewise. Thu Jul 22 20:03:03 CEST 1999 Werner Koch * ringedit.c (enum_keyblocks): Removed annoying error message in cases when we have no keyring at all to enum. * getkey.c (classify_user_id): Rewrote to relax the recognition of keyIDs and fingerprints (Michael). * mainproc.c (check_sig_and_print): Print status NO_PUBKEY. (print_failed_pkenc): Print status NO_SECKEY. * import.c (mark_non_selfsigned_uids_valid): New. * g10.c: New option --allow-non-selfsigned-uid. Thu Jul 15 10:15:35 CEST 1999 Werner Koch * g10.c: New options --disable-{cipher,pubkey}-algo. Wed Jul 14 19:42:08 CEST 1999 Werner Koch * status.h (STATUS_IMPORTED): New. * import.c (import): Print some status information (Holger Schurig). * g10.c (main): Make --no-greeting work again. Add a warning when --force-mds is used. Tue Jul 13 17:39:25 CEST 1999 Werner Koch * pkclist.c (do_edit_ownertrust): Changed the way help works. (build_pk_list): Implemented default recipient stuff. * g10.c: New options --default-recipient[-self] (main): Suppress greeting in most cases, entering a passphrase or a missing value is not considered to be interactive use. Merged --print-md and --print-mds; the latter is now obsolete. Changed the way --gen-random works and documented it. Changed the way --gen-prime works and add a man entry. * g10.c (MAINTAINER_OPTIONS): Removed. Mon Jul 12 18:45:57 CEST 1999 Werner Koch * keyedit.c (keyedit_menu): Add arg sign_mode and changed callers * g10.c (main): New command --lsign-key. Mon Jul 12 14:55:34 CEST 1999 Werner Koch * mainproc.c (kidlist_item): New. (release_list): Release failed pk-enc-list. (print_failed_pkenc): New (proc_encrypted): Print info about failed PK enc. * openfile.c (make_outfile_name): s/error/info/ * passphrase.c (passphrase_to_dek): Return an empty passphrase when in batch mode and don't make the warning message fatal * seckey-cert.c (check_secret_key): Try only once when in batch mode. * g10.c (make_username): New. Thu Jul 8 16:21:27 CEST 1999 Werner Koch * packet.h (PKT_ring_trust): New * parse-packet.c (parse_trust): Store trust value * build-packet (build_packet): Ignore ring trust packets. * mainproc.c (add_ring_trust): New. (list_node): Print "rtv" records. * g10.c: New option --with-fingerprint. * trustdb.c (verify_own_keys): Don't insert if we are dry running (check_trust): Ditto. Wed Jul 7 13:08:40 CEST 1999 Werner Koch * Makefile.am: Support for libtool. * keygen.c (ask_expire_interval): Hack to allow for an expire date. * trustdb.c (do_update_trust_record,update_trust_record): Splitted. (check_trust_record): New. (check_trust,build_cert_tree): Check the dir record as needed. (upd_pref_record): Removed. (make_pref_record): New. (propagate_validity): Stop as soon as we have enough validity. * tbdio.c (MAX_CACHE_ENTRIES_HARD): Increased the limit. Fri Jul 2 11:45:54 CEST 1999 Werner Koch * g10.c (g10_exit): Dump random stats. * sig-check.c (check_key_signature,check_key_signature2): Enhanced version and wrapper for old function. (do_signature_check,signature_check): Ditto. Thu Jul 1 12:47:31 CEST 1999 Werner Koch * keyedit.c (show_key_with_all_names): Print a notice for disabled keys. (enable_disable_keys): Add functionality * pkclist.c (edit_ownertrust): preserve disabled state. (build_pk_list): Skip disabled keys. * trustdb.c (upd_one_ownertrust): Ditto. (build_cert_tree): Mask the ownertrust. (trust_letter): Mask the value. (do_check): Take disabled flag into account. * passphrase.c (passphrase_to_dek): Add a pubkey_algo arg and changed all callers. * g10.c (utf8_strings): 2 new options. * trustdb.c (insert_trust_record_by_pk): New, replaces the next one. (insert_trust_record): Now takes a keyblock as arg. Changed all callers to use the appropritae function. * openfile.c (ask_outfile_name): New. * plaintext.c (handle_plaintext): Ask for filename if there is no valid syntax. Don't use fname varbatim but filter it. Tue Jun 29 21:44:25 CEST 1999 Werner Koch * trustdb.h (TRUST_FLAG_DISABLED): New. * status.c (USE_CAPABILITIES): Capabilities support (Remi). * tdbio.c : Added new fields to the DIR record. (tdbio_write_record): Fixed the update of the hash tables. (tdbio_delete_record): Drop the record from the hash tables. (drop_from_hashtbl): New. * status.c (cpr_get): Special online help mode. * helptext.c ("keyedit.cmd"): Removed. * keyedit.c (keyedit_menu): Use only help system. (enable_disable_key): New bit doies not yet work. Sat Jun 26 12:15:59 CEST 1999 Werner Koch * dearmor.c (enarmor_file): Fixed comment string. * tdbdump.c (export_ownertrust): Text fix. * tbio.c (tdbio_invalid): Ditto. * parse-packet.c (parse_key): Made temp buffer larger. * Makefile.am (install-data-local): Add missing backslashes Tue Jun 15 12:21:08 CEST 1999 Werner Koch * g10.c (main): Made iterated+salted the default S2K method. * Makefile.am (install-data-local): Use DESTDIR. * passphrase.c (passphrase_to_dek): Emit missing-passphrase while in batchmode. * parse-packet.c (parse_pubkeyenc): Fixed a SEGV. Mon Jun 14 21:18:54 CEST 1999 Michael Roth * g10.c: New options --openpgp, --no-tty, --emit-version, --default-comment and --lock-multiple Thu Jun 10 14:18:23 CEST 1999 Werner Koch * free-packet.c (free_encrypted): Fixed EOF case (Remi). (free_plaintext): Ditto. * helptext.c (keyedit.delsig.unknown): New (Remi). * keyedit.c (print_and_check_one_sig): Add arg print_without_key and changed all callers to make use of it (Remi): Tue Jun 8 13:36:25 CEST 1999 Werner Koch * keylist.c (print_key_data): New and called elsewhere. * g10.c: New option --with-key-data Wed Jun 2 14:17:19 CEST 1999 Werner Koch * mainproc.c (proc_tree): Yet another bad hack to cope with broken pgp2 created detached messages in textmode. Tue Jun 1 16:01:46 CEST 1999 Werner Koch * openfile.c (make_outfile_name): New. * plaintext.c (handle_plaintext): Outputfile is now the inputfile without the suffix. * g10.c: New option --use-embedded-filename Mon May 31 19:41:10 CEST 1999 Werner Koch * g10.c (main): Fix for SHM init (Michael). * compress.c, encr-data.c, mdfilter.c, plaintext.c, free-packet.c: Speed patches (Rémi). Thu May 27 09:40:55 CEST 1999 Werner Koch * status.c (cpr_get_answer_yes_no_quit): New. * keyedit.c (menu_delsig): New. (check_all_keysigs): Splitted. (print_and_check_one_sig): New. Wed May 26 14:36:29 CEST 1999 Werner Koch * build-packet.c (build_sig_subpkt): Support large packets. * parse-packet.c (enum_sig_subpkt): Replaces parse_sig_subpkt. * mainproc.c (print_notation_data): Print all notation packets. * g10.c (add_notation_data): Add a way to specify the critical flag. (main): Add option --set-policy-url. (check_policy_url): Basic checks. * sign.c (mk_notation_and_policy): Replaces mk_notation. * parse-packet.c (can_handle_critical): Moved decision whether we can handle critical subpacket to an extra function. Tue May 25 19:50:32 CEST 1999 Werner Koch * sign.c (sign_file): Always use compression algo 1 for signed onyl file becuase we can´ be sure the the verifier supports other algorithms. * build-packet.c (build_sig_subpkt): Support for notation data. * sign.c (sign_file,clearsign_file,make_keysig_packet): Ditto. (mk_notation): New. * g10.c (add_notation_data): New and add option -N * mainproc.c (print_notation_data): New. (check_sig_and_print): Print any notation data of the signed text. Sun May 23 14:20:22 CEST 1999 Werner Koch * pkclist.c (check_signatures_trust): Print a warning and return immediateley if opt.always_trust is true. * g10.c (main): Corrected handling of no-default-keyring * pkclist.c (algo_available): Disable Twofish until we have settled how to do the MDC. * hkp.c: Disable everything for mingw32 Sat May 22 22:47:26 CEST 1999 Werner Koch * mainproc.c (check_sig_and_print): Add sig creation time to the VALIDSIG status output. Add more info to the ERRSIG output. * sig-check.c (signature_check): Add sig time after epoch to SIG_ID. * import.c (import_one): Merge duplicate user IDs. (collapse_uids): New. * kbnode.c (move_kbnode): New. (remove_kbnode): New. * keyedit.c (keyedit_menu): Call collapse_uids. * g10.c: new option --logger-fd. * import.c: s/log_*_f/log_*/ Thu May 20 14:04:08 CEST 1999 Werner Koch * misc.c (pull_in_libs): do the volatile only for gcc * sig-check (signature_check): Emit SIG_iD only for classes 0 and 1. * armor.c (armor_filter): Add detection of PGP2 created clearsigs. (fake_packet): A tab is not a WS for pgp2 - handle this. * textfilter.c (len_without_trailing_chars): New. (copy_clearsig_text): Add pgp2mode arg. * sign.c (clearsign_file): pass old_style to the above fnc. Wed May 19 16:04:30 CEST 1999 Werner Koch * g10.c: New option --interactive. * mainproc.c (proc_plaintext): Add workaround for pgp2 bug (do_check_sig): Ditto. (proc_tree): Ditto. * plaintext.c (do_hash): Ditto. (hash_datafiles): Ditto, add an arg, changed all callers. * mdfilter.c (md_filter): Add support for the alternate hash context. Mon May 17 21:54:43 CEST 1999 Werner Koch * parse-packet.c (parse_encrypted): Support for PKT_ENCRYPTED_MDC. * build-packet.c (do_encrypted_mdc): Ditto. * cipher.c (write_header): Add mdc hashing. (cipher_filter): write out the hash. * mainproc.c (do_proc_packets): Add PKT_ENCRYPTED_MDC. * encr-data.c (decrypt_data): Add mdc hashing. (mdc_decode_filter): New. * parse-packet.c (parse_sig_subpkt): Fixed stupid bug for subpkt length calculation (parse_signature): Fixed even more stupid bug. Sat May 8 19:28:08 CEST 1999 Werner Koch * build-packet.c (do_signature): Removed MDC hack. * encode.c (encode_crypt_mdc): Removed. * mainproc.c (do_check_sig): Removed MDC hack. (check_sig_and_print): Ditto. * parse-packet.c (parse_signature): Ditto. * sig-check.c (mdc_kludge_check): Ditto. * free-packte.c (copy_signature, free_seckey_enc): Ditto. * parse-packet.c (parse_signature,parse_key): Store data of unknown algorithms with mpi_set_opaque inseatd of the old faked data stuff. (read_rest): Removed. (read_rest2): Renamed to read_rest * build-packet.c (write_fake_data): Use mpi_get_opaque. * free-packet.c (cp_fake_data): Removed and cahnged all callers to use mpi_copy. (free_pubkey_enc,free_seckey_enc,release_public_key_parts, release_secret_key_parts): Use mpi_free for opaque data. Thu May 6 14:18:17 CEST 1999 Werner Koch * trustdb.c (check_trust): Check for revoked subkeys. * pkclist.c (do_we_trust): Handled revoked subkeys. (do_we_trust_pre): Ditto. (check_signatures_trust): Ditto. * build-packet.c (hash_public_key): Fix for ancient g10 keys. * mainproc.c (do_proc_packets): Return EOF if no data has been read. * g10.c (main): Catch errors for default operation. Thu Apr 29 12:29:22 CEST 1999 Werner Koch * sign.c (sign_file): Fixed hashing in case of no subpackets. (clearsign_file): Ditto. (make_keysig_packet): Ditto. Wed Apr 28 13:03:03 CEST 1999 Werner Koch * keyedit.c (keyedit_menu): Add new command revkey. * (menu_revkey): New. Mon Apr 26 17:48:15 CEST 1999 Werner Koch * parse-packet.c (parse_signature): Add the MDC hack. * build-packet.c (do_signature): Ditto. * free-packet.c (free_seckey_enc,copy_signature,cmp_signatures): Ditto. * mainproc.c (do_check_sig): Ditto. * sig-check.c (mdc_kludge_check): New. * encode.c (encrypt_mdc_file): New. * keyedit.c (check_all_keysigs): List revocations. * (menu_revsig): New. * sign (make_keysig_packet): Support for class 0x30. Sun Apr 18 20:48:15 CEST 1999 Werner Koch * pkclist.c (select_algo_from_prefs): Fixed the case that one key has no preferences (Remi Guyomarch). keylist.c (list_keyblock): ulti_hack to propagate trust to all uids. Sun Apr 18 10:11:28 CEST 1999 Werner Koch * seckey-cert.c (do_check): Use real IV instead of a 0 one, so that it works even if the length of the IV doesn't match the blocksize. Removed the save_iv stuff. (protect_secret_key): Likewise. Create the IV here. * packet.h (PKT_secret_key): Increased size of IV field and add a ivlen field. * parse-packet.c (parse_key): Use the len protect.ivlen. * build-packet.c (do_secret_key). Ditto. * getkey.c (key_byname): Close keyblocks. * Makefile.am (gpgm): Removed this * g10.c: Merged gpg and gpgm * import.c (import): Utilize option quiet. * tdbio.c (tdbio_set_dbname): Ditto. * ringedit.c (add_keyblock_resource,keyring_copy): Ditto. * keyedit.c (sign_uids): Add some batch support. * g10.c (main): add call to tty_batchmode. Fri Apr 9 12:26:25 CEST 1999 Werner Koch * status.c (write_status_text): Some more status codes. * passphrase_to_dek (passphrase_to_dek): add a status code. * seckey_cert.c (check_secret_key): Likewise. * encr-data.c (decrypt_data): Reverse the last changes * cipher.c (write_header): Ditto. * parse-packet.c (parse_key): Dropped kludge for ancient blowfish mode. Thu Apr 8 09:35:53 CEST 1999 Werner Koch * mainproc.c (proc_encrypted): Add a new status output * passphrase.c (passphrase_to_dek): Ditto. * status.h status.c: Add new status tokens. Wed Apr 7 20:51:39 CEST 1999 Werner Koch * encr-data.c (decrypt_data): Fixes for 128 bit blocksize * cipher.c (write_header): Ditto. * seckey-cert.c (do_check): Ditto. (protect_secret_key). Ditto. * misc.c (print_cipher_algo_note): Twofish is now a standard algo. * keygen.c (do_create): Fixed spelling (Gaël Quéri) (ask_keysize): Only allow keysizes up to 4096 * ringedit.c (add_keyblock_resource): chmod newly created secrings. * import.c (delete_inv_parts): Fixed accidently deleted subkeys. Tue Apr 6 19:58:12 CEST 1999 Werner Koch * armor.c: Removed duped include (John Bley) * mainproc.c: Ditto. * build-packet.c (hash_public_key): Fixed hashing of the header. * import.c (delete_inv_parts): Allow import of own non-exportable sigs. Sat Mar 20 13:59:47 CET 1999 Werner Koch * armor.c (fake_packet): Fix for not not-dash-escaped Sat Mar 20 11:44:21 CET 1999 Werner Koch * g10.c (main): Added command --recv-keys * hkp.c (hkp_import): New. Wed Mar 17 13:09:03 CET 1999 Werner Koch * trustdb.c (check_trust): add new arg add_fnc and changed all callers. (do_check): Ditto. (verify_key): Ditto. (propagate_validity): Use the new add_fnc arg. (print_user_id): Add the FILE arg. (propagate_ownertrust): New. * pkclist.c (add_ownertrust_cb): New and changed the add_ownertrust logic. * getkey.c (get_keyblock_bylid): New. * trustdb.c (print_uid_from_keyblock): New. (dump_tn_tree_with_colons): New. (list_trust_path): Add colon print mode. * trustdb.c (insert_trust_record): Always use the primary key. * encode.c (encode_simple): Added text_mode filter (Rémi Guyomarch) (encode_crypt): Ditto. * mainproc.c (proc_pubkey_enc): Added status ENC_TO. * armor.c (armor_filter): Added status NODATA. * passphrase.c (passphrase_to_dek): Always print NEED_PASSPHRASE * seckey_cert.c (check_secret_key): Added BAD_PASS status. * g10.c (main): Set g10_opt_homedir. Sun Mar 14 19:34:36 CET 1999 Werner Koch * keygen.c (do_create): Changed wording of the note (Hugh Daniel) Thu Mar 11 16:39:46 CET 1999 Werner Koch * tdbdump.c: New * trustdb.c (walk_sigrecs,do_list_sigs,list_sigs, list_records,list_trustdb,export_ownertrust,import_ownertrust): Moved to tdbdump.c (init_trustdb): renamed to setup_trustdb. Changed all callers. (do_init_trustdb): renamed to init_trustdb(). * trustdb.c (die_invalid_db): replaced by tdbio_invalid. * tdbio.c (tdbio_invalid): New. * import.c (delete_inv_parts): Skip non exportable signatures. * keyedit.c (sign_uid_mk_attrib): New. (sign_uids): Add the local argument. (keyedit_menu): New "lsign" command. * trustdb.c (register_trusted_key): Removed this and all related stuff. * g10.c (oTrustedKey): Removed option. * tdbio.h (dir.valcheck): New trustdb field. * tdbio.c: Add support for this field (tdbio_read_modify_stamp): New. (tdbio_write_modify_stamp): New. * trustdb.c (do_check): Check against this field. Removed cache update. (verify_key): Add cache update. (upd_uid_record): Some functional changes. (upd_cert_record): Ditto Wed Mar 10 11:26:18 CET 1999 Werner Koch * keylist.c (list_keyblock): Fixed segv in uid. Print 'u' as validity of sks. Mon Mar 8 20:47:17 CET 1999 Werner Koch * getkey.c (classify_user_id): Add new mode 12 (#). * seckey-cert.c (check_secret_key): replaced error by info. * trustdb.c (query_trust_info): Add another arg, changed all callers. (check_trust): Ditto. (do_check): Ditto. (verify_key): Handle namehash. * keylist.c (list_keyblock): print trust info for user ids. * sig-check.c (signature_check): Add sig-created to status output. Tue Mar 2 16:44:57 CET 1999 Werner Koch * textfilter.c (copy_clearsig_text): New. (clearsign): Removed. * sign.c (clearsign_file): does not use textfiler anymore. * keygen.c (ask_user_id): print a note about the used charset. Tue Mar 2 10:38:42 CET 1999 Werner Koch * sig-check.c (signature_check): sig-id now works for all algos. * armor.c (armor_filter): Fixed armor bypassing. Sun Feb 28 19:11:00 CET 1999 Werner Koch * keygen.c (ask_user_id): Don't change the case of email addresses. (has_invalid_email_chars): Adjusted. * keylist.c (list_one): Really list serect keys (Remi Guyomarch) * keyedit.c (menu_select_uid): Add some braces to make egcs happy. (menu_select_key): Ditto. * mainproc.c (do_proc_packets): List sym-enc packets (Remi Guyomarch) Fri Feb 26 17:55:41 CET 1999 Werner Koch * pkclist.c (build_pk_list): Return error if there are no recipients. * sig-check.c (signature_check): New signature id feature. * armor.c (make_radic64_string): New. * mainproc.c (proc_pubkey_enc): early check for seckey availability. * pkclist.c (do_we_trust_pre): print user id before asking. * ringedit.c (add_keyblock_resource,get_keyblock_handle): Cleaner handling of default resource. Thu Feb 25 18:47:39 CET 1999 Werner Koch * pkclist.c (algo_available): New. (select_algo_from_prefs): Check whether algo is available. * ringedit.c (keyring_copy): Take care of opt.dry_run. (do_gdbm_store): Ditto. * openfile.c (open_outfile). Ditto. (copy_options_file): Ditto. * trustdb.c (update_trustdb): Ditto. (clear_trust_checked_flag): Ditto. (update_trust_record): Ditto. (insert_trust_record): Ditto. Wed Feb 24 11:07:27 CET 1999 Werner Koch * keylist.c (secret_key_list): Now really list the secret key. * trustdb.c (do_init_trustdb): New. Init is now deferred. Mon Feb 22 20:04:00 CET 1999 Werner Koch * getkey.c (lookup_sk): Return G10ERR_NO_SECKEY and not x_PUBKEY. Fri Feb 19 15:49:15 CET 1999 Werner Koch * pkclist.c (select_algo_from_prefs): retrieve LID if not there. * armor.c (fake_packet): Replaced ugly lineending handling. * g10.c (oNoEncryptTo): New. * pkclist.c (build_pk_list): Implemented this option. * g10.c (main): Greeting is now printed to stderr and not to tty. Use add_to_strlist() instead of direct coding. * import.c (import): Use iobuf_push_filter2. * mainproc.c (check_sig_and_print): Print all user ids for good signatures. * getkey.c (get_pubkeyblock): New. * import.c (chk_self_sigs): Fixed SEGV for unbounded class 0x18 keys. (delete_inv_parts): Delete special marked packets. Tue Feb 16 14:10:02 CET 1999 Werner Koch * g10.c (main): New option --encrypt-to * pkclist.c (build_pk_list): Implemented encrypt-to. * parse-packet.c (parse_user_id): Removed the hack to work with utf-8 strings. * g10.c (main): Install lockfile cleanup handler. * tdbio.c (cleanup): Removed: this is now handled by dotlock. Sat Feb 13 14:13:04 CET 1999 Werner Koch * tdbio.c (tdbio_set_dbname): Init lockhandle for a new trustdb Wed Feb 10 17:15:39 CET 1999 Werner Koch * g10.c (main): check for development version now in configure * tdbio.c (tdbio_write_record): Add uid.validity (tdbio_read_record) : Ditto. (tdbio_dump_record) : Ditto. * keygen.c (keygen_add_std_prefs): Replaced Blowfish by Twofish, removed MD5 and Tiger. * pubkey-enc.c (get_it): Suppress warning about missing Blowfish in preferences in certain cases. * ringedit.c (lock_rentry,unlock_rentry): New. * getkey.c (key_byname): Pass ret_kb down to lookup_xx. * armor.c (armor_filter): No output of of empty comment lines. Add option --no-version to suppress the output of the version string. * getkey.c: Release the getkey context for auto context variables. Sun Jan 24 18:16:26 CET 1999 Werner Koch * getkey.c: Changed the internal design to allow simultaneous lookup of multible user ids (get_pubkey_bynames): New. (get_seckey_bynames): New. (get_seckey_next): New. (get_seckey_end): New. * keylist.c (list_one): Use the new functions. * keylist.c (list_keyblock): add a newline for normal listings. * g10.c (--recipient): New option name to replace --remote-user Wed Jan 20 18:59:49 CET 1999 Werner Koch * textfilter.c: Mostly rewritten * plaintext.c (handle_plaintext): Use now text_filter semantics. Tue Jan 19 19:34:58 CET 1999 Werner Koch * export.c (export_pubkeys_stream): New. (do_export_stream): New. * g10.c (aSendKeys): New command. * hkp.c (hkp_export): New. * compress.c (do_uncompress): Hack for algo 1 and 1.1.3 Sun Jan 17 11:04:33 CET 1999 Werner Koch * textfilter.c (text_filter): Now uses iobuf_read_line(). (read_line): Removed. * armor.c (trim_trailing_spaces): Removed and replaced by trim_trailing_ws from libutil Sat Jan 16 12:03:27 CET 1999 Werner Koch * hkp.c (hkp_ask_import): Use only the short keyid Sat Jan 16 09:27:30 CET 1999 Werner Koch * import.c (import_key_stream): New (import): New, moved most of import_keys here. * g10.c: New option --keyserver * mainproc.c (check_sig_and_print): Hook to import a pubkey. * pref.c pref.h : Removed * hkp.c hkp.h: New Wed Jan 13 14:10:15 CET 1999 Werner Koch * armor.c (radix64_read): Print an error if a bad armor was detected. Wed Jan 13 12:49:36 CET 1999 Werner Koch * armor.c (radix64_read): Now handles malformed armors produced by some buggy MUAs. Tue Jan 12 11:17:18 CET 1999 Werner Koch * ringedit.c (find_keyblock_bysk): New. * skc_list.c (is_insecure): New. (build_sk_list): usage check for insecure keys. * import.c (chk_self_sigs): Add handling for subkeys. (delete_inv_parts): Skip unsigned subkeys * sig-check.c (do_check): Print info if the signature is older than the key. * keygen.c (generate_subkeypair): Fail on time warp. * sign.c (do_sign): Ditto. Sun Jan 10 15:10:02 CET 1999 Werner Koch * armor.c (fake_packet): Fixed not-dash-escaped bug. Sat Jan 9 16:02:23 CET 1999 Werner Koch * sig-check.c (do_check): Output time diff on error * status.c (STATUS_VALIDSIG): New. (is_status_enabled): New. * mainproc.c (check_sig_and_print): Issue that status message. * plaintext.c (special_md_putc): Removed * armor.c (armor_filter): print error for truncated lines. * free-packet.c (free_encrypted): Revomed call to set_block_mode. (free_plaintext): Ditto. Thu Jan 7 18:00:58 CET 1999 Werner Koch * pkclist.c (add_ownertrust): Fixed return value. * encr-data.c (decrypt_data): Disabled iobuf_set_limit and iobuf_pop_filter stuff. * compress.c (handle_compressed): Disabled iobuf_pop_filter. * packet.h (PKT_secret_key): Add is_primary flag. * parse-packet.c (parse_key): Set this flag. * passphrase.c (passphrase_to_dek): Kludge to print the primary keyid - changed the API: keyid must now hold 2 keyids. * getkey.c (get_primary_seckey): New. * seckey-cert.c (do_check): pass primary keyid to passphrase query * tbdio.c (open_db): removed the atexit (tdbio_set_dbname): and moved it to here. * armor.c: Rewrote large parts. Tue Dec 29 19:55:38 CET 1998 Werner Koch * revoke.c (gen_revoke): Removed compression. * pkclist.c (do_we_trust_pre): special check for revoked keys * trustdb.c (update_trust_record): Fixed revoke flag. Tue Dec 29 14:41:47 CET 1998 Werner Koch * misc.c (disable_core_dumps): Check for EINVAL (Atari) * getkey (merge_one_pk_and_selfsig): Fixed search of expiredate. (merge_keys_and_selfsig): Ditto. * free-packet.c (cmp_public_keys): cmp expire only for v3 packets (cmp_secret_keys): Ditto. (cmp_public_secret_key): Ditto. Wed Dec 23 17:12:24 CET 1998 Werner Koch * armor.c (find_header): Reset not_dashed at every header Wed Dec 23 13:18:14 CET 1998 Werner Koch * pkclist.c (add_ownertrust): Refresh validity values. * trustdb.c (enum_cert_paths_print): New arg refresh. * ringedit.c: Fixed problems fix keyrings * parse-packet.c (dbg_parse_packet): New debug functions. * getkey.c (getkey_disable_caches): New. * import.c (import_keys): Disable caches. Thu Dec 17 18:31:15 CET 1998 Werner Koch * misc.c (trap_unaligned): Only for glibc 1 * sign.c (write_dash_escaped): Now escapes "From " lines * g10.c: New option --escape-from-lines * trustdb.c (sort_tsl_list): New (list_trust_path): Now prints sorted list. (enum_cert_paths): Likewise. (enum_cert_paths_print): New. (print_paths): New printing format. * pkclist.c (add_ownertrust): New arg quit. (edit_ownertrust): New quit selection and does not query the recipients ownertrust anymore. (add_ownertrust): Print the ceritficate path. Mon Dec 14 21:18:49 CET 1998 Werner Koch * parse-packet.c (parse_signature): Now checks for critical bit (parse_sig_subpkt): Splitted. (parse_one_sig_subpkt): New. * sig-check.c (do_check): handle critical bit. Sun Dec 13 14:10:56 CET 1998 Werner Koch * pcklist.c (select_algo_from_prefs): Preferences should now work (lost the != ? ) Thu Dec 10 20:15:36 CET 1998 Werner Koch * ringedit.c (gdbm_store): Fix for inserts * g10.c (main): New option --export-all * export.c (export_pubkeys): New arg. (do_export): Now may skip old keys. * status.c: Minor patches for Sun's cc * keygen.c (ask_algo): Disabled v3 ElGamal choice, rearranged the numbers. Add a warning question when a sign+encrypt key is selected. * g10.c (do_not_use_RSA): Removed. * misc.c (print_pubkey_algo_note): New as replacement for the do_not_use_RSA() and chnaged all callers. (print_cipher_algo_note): New. (print_hash_algo_note): New. * cipher.c (write_header): Add a call to print_cipher_algo_note. * seckey-cert.c (protect_secret_key): Ditto * sign.c (do_sign): Add a call to print_digest_algo_note. * getkey.c (get_long_user_id_string): New. * mainproc.c (check_sig_and_print): Changed the format of the status output. * encrypt.c (write_pubkey_enc_from_list): print used symmetric cipher. * pkclist.c (do_we_trust): Changed a message. Wed Dec 9 13:41:06 CET 1998 Werner Koch * misc.c (trap_unaligned) [ALPHA]: Only if UAC_SIGBUS is defined. * sign.c (write_dash_escaped): Add the forgotten patch by Brian Moore. * compress.c (do_uncompress): Fixed the inflating bug. Tue Dec 8 13:15:16 CET 1998 Werner Koch * trustdb.c (upd_uid_record): Now uses the newest self-signature (insert_trust_record): Now calls update with recheck set to true. (register_trusted_key): New. (verify_own_keys): Enhanced by list of trusted keys. * g10.c (main): Print a warning when a devel version is used. (main): New option --trusted-key * import.c (merge_blocks): Fixed merging of new user ids and added merging of subkeys. (append_uid): Ditto. (merge_keysig): New. (append_key): New. * getkey.c (merge_one_pk_and_selfsig): Get the expiration time from the newest self-signature. (merge_keys_and_selfsig): Ditto. * free-packet.c (cmp_secret_key): New. Fri Nov 27 21:37:41 CET 1998 Werner Koch * g10.c: New option --lock-once * tdbio.c (open_db): Add an atexit (cleanup): New. (tdbio_sync): Add locking. (tdbio_end_transaction): Ditto. (put_record_into_cache): Ditto. * ringedit.c (keyring_copy): Ditto. (cleanup): New. (add_keyblock_resource): Add an atexit. Fri Nov 27 15:30:24 CET 1998 Werner Koch * armor.c (find_header): Another fix for clearsigs. Fri Nov 27 12:39:29 CET 1998 Werner Koch * status.c (display_help): Removed. * helptext.c: New and removed the N_() from all cpr_gets. Fri Nov 20 16:54:52 1998 Werner Koch (wk@isil.d.shuttle.de) * g10.c (main): New option --not-dash-escaped * sign.c (write_dashed_escaped): Ditto. * armor.c (find_header): Support for NotDashEscaped header. * getkey.c: print "disabled cache.." only if verbose is used. Thu Nov 19 07:17:31 1998 Werner Koch * parse-packet.c (dump_sig_subpkt): Fixed expire listing * getkey.c (merge_keys_and_selfsig): Fixed expire calculation. (merge_one_pk_and_selfsig): Ditto. * keyedit.c (menu_expire). Ditto. * keygen.c (keygen_add_key_expire): Ditto. (ask_expire_interval): New and changed all local function to use this instead. (keygen_add_key_expire): Opaque should now be a public key; changed all callers. * parse.packet.c (parse): use skip_rest to skip packets. * keyedit.c (keyedit_menu): New arg for cmdline cmds. Wed Nov 18 20:33:50 1998 Werner Koch (wk@isil.d.shuttle.de) * trustdb.c (check_trustdb): Now rechecks all gived userids. (collect_paths): Some fixes. (upd_pref_records): Skips empty items, evaluate all items. * parse-packet.c (dump_sig_subpkt): Better listing of prefs. (skip_packet): Now knows about marker packet * g10.c: removed cmd "--edit-sig". * pubring.asc: Updated. Sat Nov 14 14:01:29 1998 Werner Koch (wk@isil.d.shuttle.de) * g10.c (main): Changed syntax of --list-trust-path * trustdb.c (list_trust_path): Replaced max_depth by opt.max_cert_depth Fri Nov 13 07:39:58 1998 Werner Koch * trustdb.c (collect_paths): Removed a warning message. (enum_trust_web): Removed. (enum_cert_paths): New. * pkclist.c (add_ownertrust): Changed to use enum_cert_paths. (edit_ownertrust): Now list ceritficates on request. (show_paths): New. Wed Nov 11 18:05:44 1998 Werner Koch * g10.c (main): New option --max-cert-depth * tdbio.h: add new fields to ver and dir record. * tdbio.c: read/write/dump of these fields. (tdbio_db_matches_options): New. * trustdb.c: replaced MAC_CERT_DEPTH by opt.max_cert_depth. (do_check): cache validity and changed other functions to reset the cached value. * keylist.c (list_one): Now lists the ownertrust. * mainproc.c (list_node): Ditto. Tue Nov 10 10:08:59 1998 Werner Koch (wk@isil.d.shuttle.de) * g10.c (g10_exit): Now looks at the new g10_errors_seen. * mainproc.c (check_sig_and_print): Sets g10_errors_seen. * *.c : i18n many more strings. * ringedit.c (locate_keyblock_by_keyid): Add HAVE_LIBGDBM (locate_keyblock_by_fpr): Ditto. * g10.c (main): removed unsused "int errors". (main): Add new option --charset. * g10.c (main): special message for the unix newbie. Mon Nov 9 07:17:42 1998 Werner Koch * getkey.c (finish_lookup): Kludge to prefere algo 16. * trustdb.c (new_lid_table): Clear cached item. * status.c (cpr_get_utf8): New. * pkclist.c (build_pk_list): Uses this. Sun Nov 8 17:20:39 1998 Werner Koch (wk@isil.d.shuttle.de) * mainproc.c (check_sig_and_print): Why did I use strlen()-1 in the printf? - This truncated the TZ. Sat Nov 7 15:57:28 1998 me,,, (wk@tobold) * getkey.c (lookup): Changes to support a read_next. (get_pubkey): Fixed a memory leak. * keylist.c (list_one): Now lists all matching user IDs. Tue Nov 3 16:19:21 1998 Werner Koch (wk@isil.d.shuttle.de) * keygen.c (ask_user_id): Now converted to UTF-8 * g10.c (main): Kludge for pgp clearsigs and textmode. Fri Oct 30 16:40:39 1998 me,,, (wk@tobold) * signal.c (block_all_signals): New. (unblock_all_signals): New * tdbio.c (tdbio_end_transaction): Now blocks all signals. * trustdb.c (new_lid_table): Changed the representation of the former local_lid_info stuff. * trustdb.c (update_trust_record): Reorganized the whole thing. * sig-check.c (check_key_signature): Now handles class 0x28 Wed Oct 28 18:56:33 1998 me,,, (wk@tobold) * export.c (do_export): Takes care of the exportable sig flag. Tue Oct 27 14:53:04 1998 Werner Koch (wk@isil.d.shuttle.de) * trustdb.c (update_trust_record): New "fast" parameter. Sun Oct 25 19:32:05 1998 Werner Koch (wk@isil.d.shuttle.de) * openfile.c (copy_options_File): New. * ringedit.c (add_keyblock_resource): Creates options file * tdbio.c (tdbio_set_dbname): Ditto. Sat Oct 24 14:10:53 1998 brian moore * mainproc.c (proc_pubkey_enc): Don't release the DEK (do_proc_packets): Ditto. Fri Oct 23 06:49:38 1998 me,,, (wk@tobold) * keyedit.c (keyedit_menu): Comments are now allowed * trustdb.c: Rewrote large parts. Thu Oct 22 15:56:45 1998 Michael Roth (mroth@nessie.de) * encode.c: (encode_simple): Only the plain filename without a given directory is stored in generated packets. (encode_crypt): Ditto. * sign.c: (sign_file) Ditto. Thu Oct 22 10:53:41 1998 Werner Koch (wk@isil.d.shuttle.de) * trustdb.c (update_trust_record): Add new optional arg. * import.c (import_keys): Add statistics output * trustdb.c (update_trustdb): Ditto. (insert_trustdb): Ditto. * tdbio.c (tdbio_begin_transaction): New. (tdbio_end_transaction): New. (tdbio_cancel_transaction): New. * g10.c (main): New option --quit. * trustdb.c (check_hint_sig): No tests for user-id w/o sig. This caused an assert while checking the sigs. * trustdb.c (upd_sig_record): Splitted into several functions. * import.c (import_keys): New arg "fast". * g10.c (main): New command --fast-import. Wed Oct 21 18:19:36 1998 Michael Roth * ringedit.c (add_keyblock_resource): Directory is now created. * tdbio.c (tdbio_set_dbname): New info message. Wed Oct 21 11:52:04 1998 Werner Koch (wk@isil.d.shuttle.de) * trustdb.c (update_trustdb): released keyblock in loop. * keylist.c (list_block): New. (list_all): Changed to use list_block. * trustdb.c: Completed support for GDBM * sign.c (only_old_style): Changed the way force_v3 is handled (sign_file): Ditto. (clearsign_file): Ditto. * keygen.c (has_invalid_email_chars): Splitted into mailbox and host part. * keylist.c (list_one): Add a merge_keys_and_selfsig. * mainproc.c (proc_tree): Ditto. Sun Oct 18 11:49:03 1998 Werner Koch (wk@isil.d.shuttle.de) * sign.c (only_old_style): Add option force_v3_sigs (sign_file): Fixed a bug in sig->version (clearsign_file): Ditto. * parse-packet.c (dump_sig_subpkt): New * keyedit.c (menu_expire): New. * free-packet.c (cmp_signatures): New Sat Oct 17 10:22:39 1998 Werner Koch (wk@isil.d.shuttle.de) * armor.c: changed output line length from 72 to 64. * keyedit.c (fix_keyblock): New. Fri Oct 16 10:24:47 1998 Werner Koch (wk@isil.d.shuttle.de) * trustdb.c: Rewrote most. * tdbio.c: Add cache and generalized hash tables. * options.h (ENABLE_COMMENT_PACKETS): New but undef'ed. * encode.c, sign.c, keygen.c: Disabled comment packets. * export.c (do_export): Comment packets are never exported, except for those in the secret keyring. * g10.c (main): Removed option do-no-export-rsa; should be be replaced by a secpial tool. * export.c (do_export): Removed the code for the above option. * armor.c (find_header): Support for new only_keyblocks. * import.c (import_keys): Only looks for keyblock armors. * packet.h: replaced valid_days by expiredate and changed all users. * build-packet.c (do_public_key): calculates valid-days (do_secret_key): Ditto. * parse-packet.c (parse_key): expiredate is calucated from the valid_period in v3 packets. * keyid.c (do_fingerprint_md): calculates valid_dates. * keygen.c (add_key_expire): fixed key expiration time for v4 packets. * armor.c (find_header): A LF in the first 28 bytes was skipped for non-armored data. Thu Oct 8 11:35:51 1998 Werner Koch (wk@isil.d.shuttle.de) * armor.c (is_armored): Add test on old comment packets. * tdbio.c (tdbio_search_dir_bypk): fixed memory leak. * getkey.c: Changed the caching algorithms. Wed Oct 7 19:33:28 1998 Werner Koch (wk@isil.d.shuttle.de) * kbnodes.c (unused_nodes): New. Wed Oct 7 11:15:36 1998 Werner Koch (wk@isil.d.shuttle.de) * keyedit.c (sign_uids): Fixed a problem with SK which could caused a save of an unprotected key. (menu_adduid): Ditto. * keyedit.c (keyedit_menu): Prefs are now correctly listed for new user ids. * trustdb.c (update_trust_record): New. (insert_trust_record): Now makes use of update_trust_record. Tue Oct 6 16:18:03 1998 Werner Koch (wk@isil.d.shuttle.de) * trustdb.c (read_record): replaces most of the tdbio_read_records. (write_record): Ditto. Sat Oct 3 11:01:21 1998 Werner Koch (wk@isil.d.shuttle.de) * keygen.c (ask_alogo): enable ElGamal enc-only only for addmode. Wed Sep 30 10:15:33 1998 Werner Koch (wk@isil.d.shuttle.de) * import.c (import_one): Fixed update of wrong keyblock. Tue Sep 29 08:32:08 1998 me,,, (wk@tobold) * mainproc.c (proc_plaintext): Display note for special filename. * plaintext.c (handle_plaintext): Suppress output of special file. Mon Sep 28 12:57:12 1998 Werner Koch (wk@isil.d.shuttle.de) * g10.c (verify_own_keys): Add warning if a key is not protected. * passphrase (hash_passphrase): Fixed iterated+salted mode and setup for keysizes > hashsize. * g10.c (main): New options: --s2k-{cipher,digest,mode}. Fri Sep 25 09:34:23 1998 Werner Koch (wk@isil.d.shuttle.de) * g10.c: Chnaged some help texts. Tue Sep 22 19:34:39 1998 Werner Koch (wk@isil.d.shuttle.de) * passphrase.c (read_passphrase_from_fd): fixed bug for long passphrases. Mon Sep 21 11:28:05 1998 Werner Koch (wk@(none)) * getkey.c (lookup): Add code to use the sub key if the primary one does not match the usage. * armor.c (armor_filter): New error message: no valid data found. (radix64_read): Changes to support multiple messages. (i18n.h): New. * mainproc.c (add_onepass_sig): bug fix. Mon Sep 21 08:03:16 1998 Werner Koch (wk@isil.d.shuttle.de) * pkclist.c (do_we_trust): Add keyid to most messages. * passphrase.c (read_passphrase_from_fd): New. (have_static_passphrase): New (get_passphrase_fd): Removed. (set_passphrase_fd): Removed. * g10.c (main): passphrase is now read here. * keyedit.c (keyedit_menu): "help" texts should now translate fine. Mon Sep 21 06:40:02 1998 Werner Koch (wk@isil.d.shuttle.de) * encode.c (encode_simple): Now disables compression when --rfc1991 is used. (encode_crypt): Ditto. Fri Sep 18 16:50:32 1998 Werner Koch (wk@isil.d.shuttle.de) * getkey.c (merge_key_and_selfsig): New. Fri Sep 18 10:20:11 1998 Werner Koch (wk@isil.d.shuttle.de) * pkclist.c (select_algo_from_prefs): Removed 3DES kludge. * seskey.c (make_session_key): Fixed SERIOUS bug introduced by adding the weak key detection code. * sign.c (sign_file): Changed aremor header in certain cases. Tue Sep 15 17:52:55 1998 Werner Koch (wk@isil.d.shuttle.de) * mainproc.c (check_sig_and_print): Replaced ascime by asctimestamp. Mon Sep 14 11:40:52 1998 Werner Koch (wk@isil.d.shuttle.de) * seskey.c (make_session_key): Now detects weak keys. * trustdb (clear_trust_checked_flag): New. * plaintext.c (handle_plaintext): Does no anymore suppress CR from cleartext signed messages. Sun Sep 13 12:54:29 1998 Werner Koch (wk@isil.d.shuttle.de) * trustdb.c (insert_trust_record): Fixed a stupid bug in the free liunked list loops. Sat Sep 12 15:49:16 1998 Werner Koch (wk@isil.d.shuttle.de) * status.c (remove_shmid): New. (init_shm_comprocess): Now sets permission to the real uid. Wed Sep 9 11:15:03 1998 Werner Koch (wk@isil.d.shuttle.de) * packet.h (PKT_pubkey_enc): New flah throw_keyid, and add logic to implement it. * g10.c (main): New Option --throw-keyid * getkey.c (enum_secret_keys): Add new ar and changed all callers. Tue Sep 8 20:04:09 1998 Werner Koch (wk@isil.d.shuttle.de) * delkey.c (delete_key): Moved from keyedit.c. Mon Sep 7 16:37:52 1998 Werner Koch (wk@isil.d.shuttle.de) * build-packet.c (calc_length_header): New arg new_ctb to correctly calculate the length of new style packets. * armor.c (is_armored): Checks for symkey_enc packets. * pkclist.c (select_algo_from_prefs): 3DEs substitute is now CAST5. Tue Aug 11 17:54:50 1998 Werner Koch (wk@isil.d.shuttle.de) * build-packet.c (do_secret_key): Fixed handling of old keys. * getkey.c (compare_name): Fixed exact and email matching * openfile.c (open_outfile): Changed arguments and all callers. Tue Aug 11 09:14:35 1998 Werner Koch (wk@isil.d.shuttle.de) * encode.c (encode_simple): Applied option set-filename and comment. (encode_crypt): Ditto. * sign.c (sign_file): Ditto. * armor.c (armor_filter): Applied option comment. * encode.c (encode_crypt): Moved init_packet to the begin. (encode_simple): add an init_packet(). * comment (write_comment): Now enforces a hash sign as the 1st byte. * import.c (import_one): Add explanation for "no user ids". * compress.c (do_uncompress): Applied Brian Warner's patch to support zlib 1.1.3 etc. * trustdb.c (check_trust): Fixed a problem after inserting new keys. * getkey (lookup): do not return the primary key if usage is given (lookup_sk): Ditto and take usage into account. * status.c (cpr_get_answer_is_yes): add display_help. Mon Aug 10 10:11:28 1998 Werner Koch (wk@isil.d.shuttle.de) * getkey.c (lookup_sk): Now always returns the primary if arg primary is true. (lookup): Likewise. (get_pubkey_byname): Now returns the primary key (get_seckey_byname): Ditto. Mon Aug 10 08:34:03 1998 Werner Koch (wk@isil.d.shuttle.de) * keyid.c (pubkey_letter): ELG_E is now a small g. Sat Aug 8 17:26:12 1998 Werner Koch (wk@isil.d.shuttle.de) * openfile (overwrite_filep): Changed semantics and all callers. Sat Aug 8 12:17:07 1998 Werner Koch (wk@isil.d.shuttle.de) * status.c (display_help): New. Thu Aug 6 16:30:41 1998 Werner Koch,mobil,,, (wk@tobold) * seskey.c (encode_session_key): Now uses get_random_bits(). Thu Aug 6 07:34:56 1998 Werner Koch,mobil,,, (wk@tobold) * ringedit.c (keyring_copy): No more backupfiles for secret keyrings and add additional warning in case of a failed secret keyring operation. Wed Aug 5 11:54:37 1998 Werner Koch (wk@isil.d.shuttle.de) * g10.c (check_opts): Moved to main. Changed def_cipher_algo semantics and chnaged all users. * pubkey-enc.c (get_sssion_key): New informational output about preferences. * parse-packet.c (parse_symkeyenc): Fixed salted+iterated S2K (parse_key): Ditto. * build-packet.c (do_secret_key): Ditto. (do_symkey_enc): Ditto. Tue Aug 4 08:59:10 1998 Werner Koch (wk@isil.d.shuttle.de) * getkey.c (enum_secret_keys): Now returns only primary keys. * getkey (lookup): Now sets the new namehash field. * parse-packet.c (parse_sig_subpkt2): New. * sign.c (sign_file): one-pass sigs are now emiited reverse. Preference data is considered when selecting the compress algo. Wed Jul 29 12:53:03 1998 Werner Koch (wk@isil.d.shuttle.de) * free-packet.c (copy_signature): New. * keygen.c (generate_subkeypair): rewritten * g10.c (aKeyadd): Removed option --add-key Mon Jul 27 10:37:28 1998 Werner Koch (wk@isil.d.shuttle.de) * seckey-cert.c (do_check): Additional check on cipher blocksize. (protect_secret_key): Ditto. * encr-data.c: Support for other blocksizes. * cipher.c (write_header): Ditto. Fri Jul 24 16:47:59 1998 Werner Koch (wk@isil.d.shuttle.de) * kbnode.c (insert_kbnode): Changed semantics and all callers. * keyedit.c : More or less a complete rewrite Wed Jul 22 17:10:04 1998 Werner Koch (wk@isil.d.shuttle.de) * build-packet.c (write_sign_packet_header): New. Tue Jul 21 14:37:09 1998 Werner Koch (wk@isil.d.shuttle.de) * import.c (import_one): Now creates a trustdb record. * g10.c (main): New command --check-trustdb Mon Jul 20 11:15:07 1998 Werner Koch (wk@isil.d.shuttle.de) * genkey.c (generate_keypair): Default key is now DSA with encryption only ElGamal subkey. Thu Jul 16 10:58:33 1998 Werner Koch (wk@isil.d.shuttle.de) * keyid.c (keyid_from_fingerprint): New. * getkey.c (get_pubkey_byfprint): New. Tue Jul 14 18:09:51 1998 Werner Koch (wk@isil.d.shuttle.de) * keyid.c (fingerprint_from_pk): Add argument and changed all callers. (fingerprint_from_sk): Ditto. Tue Jul 14 10:10:03 1998 Werner Koch (wk@isil.d.shuttle.de) * plaintext.c (handle_plaintext): Now returns create error if the file could not be created or the user responded not to overwrite the file. * mainproc.c (proc_plaintext): Tries again if the file could not be created to check the signature without output. * misc.c (disable_core_dumps): New. * g10.c (main): disable coredumps for gpg * g10.c (MAINTAINER_OPTIONS): New to disable some options Mon Jul 13 16:47:54 1998 Werner Koch (wk@isil.d.shuttle.de) * plaintext.c (hash_datafiles): New arg for better support of detached sigs. Changed all callers. * mainproc.c (proc_signature_packets): Ditto. * g10.c (main): New option "compress-sigs" * sig.c (sign_file): detached signatures are not anymore compressed unless the option --compress-sigs is used. Thu Jul 9 19:54:54 1998 Werner Koch (wk@isil.d.shuttle.de) * armor.c: Fixes to allow zero length cleartext signatures Thu Jul 9 14:52:47 1998 Werner Koch (wk@isil.d.shuttle.de) * g10.c (build_list): Now drops setuid. (main): Changed the way keyrings and algorithms are registered . Wed Jul 8 14:17:30 1998 Werner Koch (wk@isil.d.shuttle.de) * packet.h (PKT_public_key): Add field keyid. * parse-packet.c (parse_key): Reset the above field. * keyid.c (keyid_from_pk): Use above field as cache. * tdbio.c, tdbio.h: New * trustdb.c: Moved some functions to tdbio.c. (print_keyid): New. * pkclist.c (check_signatures_trust): New. Wed Jul 8 10:45:28 1998 Werner Koch (wk@isil.d.shuttle.de) * plaintext.c (special_md_putc): New. (handle_plaintext): add clearsig argument * mainproc.c (proc_plaintext): detection of clearsig * sign.c (write_dased_escaped): Changed clearsig format Tue Jul 7 18:56:19 1998 Werner Koch (wk@isil.d.shuttle.de) * armor.c (find_header): Now makes sure that there is only one empty line for clearsigs, as this is what OP now says. Mon Jul 6 13:09:07 1998 Werner Koch (wk@isil.d.shuttle.de) * g10.c (main): New option default-secret-key * getkey.c (get_seckey_byname): support for this option. Mon Jul 6 09:03:49 1998 Werner Koch (wk@isil.d.shuttle.de) * getkey.c (add_keyring): Keyrings are now added to end of the list of keyrings. The first added keyringwill be created. (add_secret_keyring): Likewise. * ringedit.c (add_keyblock_resource): Files are created here. * g10.c (aNOP): Removed * getkey.c (lookup): Add checking of usage for name lookups * packet.h (pubkey_usage): Add a field which may be used to store usage capabilities. * pkclist.c (build_pk_list): getkey now called with usage arg. * skclist.c (build_sk_list): Ditto. * sign.c (clearsign_file): Fixed "Hash:" headers Sat Jul 4 13:33:31 1998 Werner Koch (wk@isil.d.shuttle.de) * trustdb.c (list_ownertrust): New. * g10.c (aListOwnerTrust): New. * g10.c (def_pubkey_algo): Removed. * trustdb.c (verify_private_data): Removed and also the call to it. (sign_private_data): Removed. Fri Jul 3 13:26:10 1998 Werner Koch (wk@isil.d.shuttle.de) * g10.c (aEditKey): was aEditSig. Changed usage msg. * keyedit.c: Done some i18n stuff. * g10.c (do_not_use_RSA): New. * sign.c (do_sign): Add call to above function. * encode.c (write_pubkey_enc_from_list): Ditto. Thu Jul 2 21:01:25 1998 Werner Koch (wk@isil.d.shuttle.de) * parse-packet.c: Now is able sto store data of unknown algorithms. * free-packet.c: Support for this. * build-packet.c: Can write data of packet with unknown algos. Thu Jul 2 11:46:36 1998 Werner Koch (wk@isil.d.shuttle.de) * parse-packet.c (parse): fixed 4 byte length header Wed Jul 1 12:36:55 1998 Werner Koch (wk@isil.d.shuttle.de) * packet.h (new_ctb): New field for some packets * build-packet.c (build_packet): Support for new_ctb * parse-packet.c (parse): Ditto. Mon Jun 29 12:54:45 1998 Werner Koch (wk@isil.d.shuttle.de) * packet.h: changed all "_cert" to "_key", "subcert" to "subkey". * free-packet.c (free_packet): Removed memory leak for subkeys. Sun Jun 28 18:32:27 1998 Werner Koch (wk@isil.d.shuttle.de) * import.c (import_keys): Renamed from import_pubkeys. (import_secret_one): New. * g10.c (aExportSecret): New. * export.c (export_seckeys): New. * parse-packet.c (parse_certificate): Cleaned up. (parse_packet): Trust packets are now considered as unknown. (parse_pubkey_warning): New. Fri Jun 26 10:37:35 1998 Werner Koch (wk@isil.d.shuttle.de) * keygen.c (has_invalid_email_chars): New. Wed Jun 24 16:40:22 1998 Werner Koch (wk@isil.d.shuttle.de) * armor.c (armor_filter): Now creates valid onepass_sig packets with all detected hash algorithms. * mainproc.c (proc_plaintext): Now uses the hash algos as specified in the onepass_sig packets (if there are any) Mon Jun 22 11:54:08 1998 Werner Koch (wk@isil.d.shuttle.de) * plaintext.c (handle_plaintext): add arg to disable outout * mainproc.c (proc_plaintext): disable output when in sigs_only mode. Thu Jun 18 13:17:27 1998 Werner Koch (wk@isil.d.shuttle.de) * keygen.c: Removed all rsa packet stuff, chnaged defaults for key generation. Sun Jun 14 21:28:31 1998 Werner Koch (wk@isil.d.shuttle.de) * misc.c (checksum_u16): Fixed a stupid bug which caused a wrong checksum calculation for the secret key protection and add a backward compatibility option. * g10.c (main): Add option --emulate-checksum-bug. Thu Jun 11 13:26:44 1998 Werner Koch (wk@isil.d.shuttle.de) * packet.h: Major changes to the structure of public key material which is now stored in an array and not anaymore in a union of algorithm specific structures. These is needed to make the system more extendable and makes a lot of stuff much simpler. Changed all over the system. * dsa.c, rsa.c, elg.c: Removed. Wed Jun 10 07:22:02 1998 Werner Koch,mobil,,, (wk@tobold) * g10.c ("load-extension"): New option. Mon Jun 8 22:23:37 1998 Werner Koch (wk@isil.d.shuttle.de) * seckey-cert.c (do_check): Removed cipher constants (protect_secret_key): Ditto. Fri May 29 10:00:28 1998 Werner Koch (wk@isil.d.shuttle.de) * trustdb.c (query_trust_info): New. * keylist.c (list_one): Add output of trust info * mainproc (list_node): ditto. * g10.c (main): full trustdb init if -with-colons and any of the key list modes. Thu May 28 10:34:42 1998 Werner Koch (wk@isil.d.shuttle.de) * status.c (STATUS_RSA_OR_IDEA): New. * sig-check.c (check_signature): Output special status message. * pubkey-enc.c (get_session_key): Ditto. * mainproc.c (check_sig_and_print): Changed format of output. * passpharse.c (passphrase_to_dek): Likewise. Wed May 27 13:46:48 1998 Werner Koch (wk@isil.d.shuttle.de) * g10.c (aListSecretKeys): New option --list-secret-keys * keylist.c (std_key_list): Renamed to public_key_list. (secret_key_list): New (list_one, list_all): Add support for secret keys. * getkey.c (get_secret_keyring): New. * mainproc.c (list_node): Add option --with-colons for secret keys * sig-check.c (check_key_signature): detection of selfsigs * mainproc.c (list_node): fixed listing. * g10.c (aListSecretKeys): New option --always-trust * pkclist.c (do_we_trust): Override per option added * status.c (write_status_text): Add a prefix to every output line. Wed May 27 07:49:21 1998 Werner Koch (wk@isil.d.shuttle.de) * g10 (--compress-keys): New. * options.h (compress_keys): New. * export.c (export_pubkeys): Only compresses with the new option. Tue May 26 11:24:33 1998 Werner Koch (wk@isil.d.shuttle.de) * passphrase.c (get_last_passphrase): New (set_next_passphrase): New. (passphrase_to_dek): add support for the above functions. * keyedit.c (make_keysig_packet): Add sigclass 0x18, changed all callers due to a new argument. * keygen.c (write_keybinding): New (generate_subkeypair): Add functionality (ask_algo, ask_keysize, ask_valid_days): Broke out of generate_keypair (ask_user_id, ask_passphrase): Ditto. Thu May 21 11:26:13 1998 Werner Koch (wk@isil.d.shuttle.de) * g10.c,gpgd.c (main): Does now return an int, so that egcs does not complain. * armor.c (fake_packet): Removed erro message and add a noticed that this part should be fixed. * sign.c (sign_file): Compression now comes in front of encryption. * encode.c (encode_simple): Ditto. (encode_crypt): Ditto. Tue May 19 16:18:19 1998 Werner Koch (wk@isil.d.shuttle.de) * armor.c (fake_packet): Changed assertion to log_error Sat May 16 16:02:06 1998 Werner Koch (wk@isil.d.shuttle.de) * build-packet.c (build_packet): Add SUBKEY packets. Fri May 15 17:57:23 1998 Werner Koch (wk@isil.d.shuttle.de) * sign.c (hash_for): New and used in all places here. * main.h (DEFAULT_): new macros. * g10.c (opt.def_digest_algo): Now set to 0 * compress.c (init_compress): Add support for algo 1 * options.h (def_compress_algo): New * g10.c (main): New option --compress-algo Fri May 15 13:23:59 1998 Werner Koch (wk@isil.d.shuttle.de) * g10.c (print_mds): New feature to print only one hash, chnaged formatting. Thu May 14 15:36:24 1998 Werner Koch (wk@isil.d.shuttle.de) * misc.c (trap_unaligned) [__alpha__]: New * g10.c (trap_unaligned): Add call to this to track down SIGBUS on Alphas (to avoid the slow emulation code). Wed May 13 11:48:27 1998 Werner Koch (wk@isil.d.shuttle.de) * build-packet.c (do_signature): Support for v4 pakets. * keyedit.c (make_keysig_packet): Ditto. * build-packet.c (build_sig_subpkt_from_sig): New. (build_sig_subpkt): New. * elg.c (g10_elg_sign): removed keyid_from_skc. * dsa.c (g10_dsa_sign): Ditto. * rsa.c (g10_rsa_sign): Ditto. * keyedit.c (make_keysig_packet): Add call to keyid_from_skc * sign.c (clearsign_file): Support for v4 signatures. (sign_file): Ditto. Wed May 6 09:31:24 1998 Werner Koch (wk@isil.d.shuttle.de) * parse-packet.c (do_parse): add support for 5 byte length leader. (parse_subpkt): Ditto. * build-packet.c (write_new_header): Ditto. * packet.h (SIGSUBPKT_): New constants. * parse-packet.c (parse_sig_subpkt): Changed name, made global, and arg to return packet length, chnaged all callers Tue May 5 22:11:59 1998 Werner Koch (wk@isil.d.shuttle.de) * keygen.c (gen_dsa): New. * build_packet.c (do_secret_cert): Support for DSA Mon May 4 19:01:25 1998 Werner Koch (wk@isil.d.shuttle.de) * compress.c: doubled buffer sizes * parse-packet.c (do_plaintext): now uses iobuf_read/write. Mon May 4 09:35:53 1998 Werner Koch (wk@isil.d.shuttle.de) * seskey.c (encode_md_value): Add optional argument hash_algo, changed all callers. * passphrase.c (make_dek_from_passphrase): Removed * (get_passhrase_hash): Changed name to passphrase_to_dek, add arg, changed all callers. * all: Introduced the new ELG identifier and added support for the encryption only one (which is okay to use by GNUPG for signatures). Sun May 3 17:50:26 1998 Werner Koch (wk@isil.d.shuttle.de) * packet.h (PKT_OLD_COMMENT): New name for type 16. * parse-packet.c (parse_comment): Now uses type 61 Fri May 1 12:44:39 1998 Werner Koch,mobil,,, (wk@tobold) * packet.h (count): Chnaged s2k count from byte to u32. * seckey-cert.c (do_check): Changed s2k algo 3 to 4, changed reading of count. * build-packet.c (do_secret_cert): ditto. * parse-packet.c (parse_certificate): ditto. * parse-packet.c (parse_symkeyenc): New. * build-packet.c (do_symkey_enc): New. Thu Apr 30 16:33:34 1998 Werner Koch (wk@isil.d.shuttle.de) * sign.c (clearsign_file): Fixed "Hash: " armor line. Tue Apr 28 14:27:42 1998 Werner Koch (wk@isil.d.shuttle.de) * parse-packet.c (parse_subpkt): Some new types. Mon Apr 27 12:53:59 1998 Werner Koch (wk@isil.d.shuttle.de) * g10.c (main): Add option --skip-verify. * mainproc.c (check_sig_and_print): Ditto. * g10.c (print_mds): Add output for Tiger. * sign.c (sign_file): Now uses partial length headers if used in canonical textmode (kludge to fix a bug). * parse-packet.c (parse_certificate): Changed BLOWFISH id. * pubkey-enc.c (get_session_key): Ditto. * seskey.c (make_session_key): Ditto. * seckey-cert.c (protect_secret_key,do_check): Add BLOWFISH160. Fri Apr 24 17:38:48 1998 Werner Koch,mobil,,, (wk@tobold) * sig-check.c (check_key_signature): Add sig-class 0x14..0x17 * keyedit.c (sign-key): Some changes to start with support of the above new sig-classes. Wed Apr 22 09:01:57 1998 Werner Koch,mobil,,, (wk@tobold) * getkey.c (compare_name): add email matching Tue Apr 21 16:17:12 1998 Werner Koch,mobil,,, (wk@tobold) * armor.c (armor_filter): fixed missing last LF before CSUM. Thu Apr 9 11:35:22 1998 Werner Koch (wk@isil.d.shuttle.de) * seckey-cert.c (do_check): New; combines all the check functions into one. * sign.c: removed all key management functions * keyedit.c: New. Thu Apr 9 09:49:36 1998 Werner Koch (wk@isil.d.shuttle.de) * import.c (chk_self_sigs): Changed an error message. Wed Apr 8 16:19:39 1998 Werner Koch (wk@isil.d.shuttle.de) * packet.h: packet structs now uses structs from the pubkey, removed all copy operations from packet to pubkey structs. Wed Apr 8 13:40:33 1998 Werner Koch (wk@isil.d.shuttle.de) * trustdb.c (verify_own_certs): Fixed "public key not found". * getkey.c (key_byname): New, combines public and secret key search. * pkclist.c (build_pkc_list): Add new arg usage, changed all callers. * skclist.c (build_skc_list): Likewise. * ringedit.c (find_keyblock, keyring_search2): Removed. Wed Apr 8 09:47:21 1998 Werner Koch (wk@isil.d.shuttle.de) * sig-check.c (do_check): Applied small fix from Ulf Möller. Tue Apr 7 19:28:07 1998 Werner Koch (wk@isil.d.shuttle.de) * cipher.c, encr-data.c, seckey-cert.c: Now uses cipher_xxxx functions instead of blowfish_xxx or cast_xxx Tue Apr 7 11:04:02 1998 Werner Koch (wk@isil.d.shuttle.de) * Makefile.am (g10maint.o): Changed the way it is created. Mon Apr 6 11:17:08 1998 Werner Koch (wk@isil.d.shuttle.de) * misc.c: New. * keygen.c (checksum,checksum_u16,checksum_mpi): Moved to misc.c * seckey-cert.c: Kludge for wrong ELG checksum implementation. Sat Apr 4 20:07:01 1998 Werner Koch (wk@isil.d.shuttle.de) * cipher.c (cipher_filter): Support for CAST5 * encr-data.c (decode_filter): Ditto. (decrypt_data): Ditto. * seskey.c (make_session_key): Ditto. * seckey-cert.c (check_elg, check_dsa): Ditto, (protect_secret_key): Ditto. * pubkey-enc.c (get_session_key): Ditto. * passphrase.c (hash_passphrase): Ditto. Thu Apr 2 20:22:35 1998 Werner Koch (wk@isil.d.shuttle.de) * gpgd.c: New Thu Apr 2 10:38:16 1998 Werner Koch (wk@isil.d.shuttle.de) * keygen.c (generate_keypair): Add valid_days stuff. * trustdb.c (check_trust): Add check for valid_days. Wed Apr 1 16:15:58 1998 Werner Koch (wk@isil.d.shuttle.de) * keygen.c (generate_keypair): Addional question whether the selected large keysize is really needed. Wed Apr 1 15:56:33 1998 Werner Koch (wk@isil.d.shuttle.de) * seckey-cert.c (protect_secret_key): merged protect_xxx to here. Wed Apr 1 10:34:46 1998 Werner Koch (wk@isil.d.shuttle.de) * Makefile.am (g10maint.c): Changed creation rule, so that it works on FreeBSD (missing CFLAGS). * parse-packet.c (parse_subkey): Removed. Thu Mar 19 15:22:36 1998 Werner Koch (wk@isil.d.shuttle.de) * ringedit.c (keyring_enum): Fixed problem with reading too many packets. Add support to read secret keyrings. * getkey.c (scan_keyring): Removed (lookup): New to replace scan_keyring. (scan_secret_keyring): Removed. (lookup_skc): New. Wed Mar 18 11:47:34 1998 Werner Koch (wk@isil.d.shuttle.de) * ringedit.c (enum_keyblocks): New read mode 11. * keyid.c (elg_fingerprint_md): New and changed all other functions to call this if the packet version is 4 or above. Tue Mar 17 20:46:16 1998 Werner Koch (wk@isil.d.shuttle.de) * parse-packet.c (parse_certificate): Add listing support for subkeys. Tue Mar 17 20:32:22 1998 Werner Koch (wk@isil.d.shuttle.de) * armor.c (is_armored): Allow marker packet. Thu Mar 12 13:36:49 1998 Werner Koch (wk@isil.d.shuttle.de) * trustdb.c (check_trust): Checks timestamp of pubkey. * sig-check. (do_check): Compares timestamps. Tue Mar 10 17:01:56 1998 Werner Koch (wk@isil.d.shuttle.de) * g10.c (main): Add call to init_signals. * signal.c: New. Mon Mar 9 12:43:42 1998 Werner Koch (wk@isil.d.shuttle.de) * dsa.c: New * packet.h, free-packet.c, parse-packet.c : Add support for DSA * sig-check.c, getkey.c, keyid.c, ringedit.c: Ditto. * seckey-cert.c: Ditto. * packet.h : Moved .digest_algo of signature packets to outer structure. Changed all references Sun Mar 8 13:06:42 1998 Werner Koch (wk@isil.d.shuttle.de) * openfile.c : Support for stdout filename "-". * mainproc.c (check_sig_and_print): Enhanced status output: * status.c (write_status_text): New. Fri Mar 6 16:10:54 1998 Werner Koch (wk@isil.d.shuttle.de) * kbnode.c (clone_kbnode): Fixed private_flag. * mainproc.c (list_node): Output of string "Revoked" as user-id. Fri Mar 6 14:26:39 1998 Werner Koch (wk@isil.d.shuttle.de) * g10.c (main): Add userids to "-kv" and cleaned up this stuff. Fri Mar 6 12:45:58 1998 Werner Koch (wk@isil.d.shuttle.de) * g10.c (main): Changed semantics of the list-... commands and added a new one. Removed option "-d" * decrypt.c: New. * trustdb.c (init_trustdb): Autocreate directory only if it ends in "/.gnupg". Thu Mar 5 12:12:11 1998 Werner Koch (wk@isil.d.shuttle.de) * mainproc.c (do_proc_packets): New. Common part of proc_packet. (proc_signature_packets): special version to handle signature data. * verify.c: New. * g10.c (aVerify): New. * plaintext.c (hash_datafiles): New. * compress.c (handle_compressed): Add callback arg, changed caller. Thu Mar 5 10:20:06 1998 Werner Koch (wk@isil.d.shuttle.de) * g10.c: Is nom the common source for gpg and gpgm * g10maint.c: Removed * Makefile.am: Add rule to build g10maint.c Thu Mar 5 08:43:59 1998 Werner Koch (wk@isil.d.shuttle.de) * g10.c (main): Changed the way clear text sigs are faked. Wed Mar 4 19:47:37 1998 Werner Koch (wk@isil.d.shuttle.de) * g10maint.c (aMuttKeyList): New * keylist.c: New. Wed Mar 4 17:20:33 1998 Werner Koch (wk@isil.d.shuttle.de) * getkey.c (get_pubkey_byname): Kludge to allow 0x prefix. Tue Mar 3 13:46:55 1998 Werner Koch (wk@isil.d.shuttle.de) * g10maint.c (main): New option --gen-random. Tue Mar 3 09:50:08 1998 Werner Koch (wk@isil.d.shuttle.de) * g10.c (aDeleteSecretKey): New. (aEditSig): Add option "--edit-key" as synonym for "--edit-sig". (aDeleteSecretKey): New. * getkey.c (seckey_available): New. * sign.c (delete_key): Enhanced to delete secret keys, changed all callers. Mon Mar 2 21:23:48 1998 Werner Koch (wk@isil.d.shuttle.de) * pkc_list.c (build_pkc_list): Add interactive input of user ID. Mon Mar 2 20:54:05 1998 Werner Koch (wk@isil.d.shuttle.de) * pkclist.c (do_we_trust_pre): New. (add_ownertrust): Add message. * trustdb.c (enum_trust_web): Quick fix. Mon Mar 2 13:50:53 1998 Werner Koch (wk@isil.d.shuttle.de) * g10.c (main): New action aDeleteKey * sign.c (delete_key): New. Sun Mar 1 16:38:58 1998 Werner Koch (wk@isil.d.shuttle.de) * trustdb.c (do_check): No returns TRUST_UNDEFINED instead of eof error. Fri Feb 27 18:14:03 1998 Werner Koch (wk@isil.d.shuttle.de) * armor.c (find_header): Removed trailing CR on headers. Fri Feb 27 18:02:48 1998 Werner Koch (wk@isil.d.shuttle.de) * ringedit.c (keyring_search) [MINGW32]: Open and close file here because rename does not work on open files. Chnaged callers. Fri Feb 27 16:43:11 1998 Werner Koch (wk@isil.d.shuttle.de) * sig-check.c (do_check): Add an md_enable. * mainproc.c (do_check_sig): Use md_open in case of detached sig (proc_tree): Take detached sigs into account. Fri Feb 27 15:22:46 1998 Werner Koch (wk@isil.d.shuttle.de) * g10.c (main): Make use of GNUPGHOME envvar. * g10main.c (main): Ditto. Wed Feb 25 11:40:04 1998 Werner Koch (wk@isil.d.shuttle.de) * plaintext.c (ask_for_detached_datafile): add opt.verbose to info output. * openfile.c (open_sigfile): Try also name ending in ".asc" Wed Feb 25 08:41:00 1998 Werner Koch (wk@isil.d.shuttle.de) * keygen.c (generate_keypair): Fixed memory overflow. Tue Feb 24 15:51:55 1998 Werner Koch (wk@isil.d.shuttle.de) * parse-packet.c (parse_certificate): Support for S2K. * build-packet.c (do_secret_cert): Ditto. * keygen.c (gen_elg): Ditto. * seckey-cert.c (check_elg): Ditto (protect_elg): Ditto. * sign.c (chnage_passphrase): Ditto. * passphrase.c (get_passphrase_hash): Support for a salt and changed all callers. (make_dek_from_passphrase): Ditto. Tue Feb 24 12:30:56 1998 Werner Koch (wk@isil.d.shuttle.de) * build-packet.c (hash_public_cert): Disabled debug output. Fri Feb 20 17:22:28 1998 Werner Koch (wk@isil.d.shuttle.de) * trustdb.c (init_trustdb) [MINGW32]: Removed 2nd mkdir arg. (keyring_copy) [MINGW32]: Add a remove prior to the renames. Wed Feb 18 18:39:02 1998 Werner Koch (wk@isil.d.shuttle.de) * Makefile.am (OMIT_DEPENDENCIES): New. * rsa.c: Replaced log_bug by BUG. Wed Feb 18 13:35:58 1998 Werner Koch (wk@isil.d.shuttle.de) * mainproc.c (do_check_sig): Now uses hash_public_cert. * parse-packet.c (parse_certificate): Removed hashing. * packet.h (public_cert): Removed hash variable. * free-packet.c (copy_public_cert, free_public_cert): Likewise. * sig-check.c (check_key_signatures): Changed semantics. Wed Feb 18 12:11:28 1998 Werner Koch (wk@isil.d.shuttle.de) * trustdb.c (do_check): Add handling for revocation certificates. (build_sigrecs): Ditto. (check_sigs): Ditto. Wed Feb 18 09:31:04 1998 Werner Koch (wk@isil.d.shuttle.de) * armor.c (armor_filter): Add afx->hdrlines. * revoke.c (gen_revoke): Add comment line. * dearmor.c (enarmor_file): Ditto. * sig-check.c (check_key_signature): Add handling for class 0x20. * mainproc.c : Ditto. Tue Feb 17 21:24:17 1998 Werner Koch (wk@isil.d.shuttle.de) * armor.c : Add header lines "...ARMORED FILE .." * dearmor.c (enarmor_file): New. * g10maint.c (main): New option "--enarmor" Tue Feb 17 19:03:33 1998 Werner Koch (wk@isil.d.shuttle.de) * mainproc.c : Changed a lot, because the packets are now stored a simple linlked list and not anymore in a complicatd tree structure. Tue Feb 17 10:14:48 1998 Werner Koch (wk@isil.d.shuttle.de) * free_packet.c (cmp_public_certs): New. (cmp_user_ids): New. * kbnode.c (clone_kbnode): New. (release_kbnode): Add clone support. * ringedit.c (find_keyblock_bypkc): New. * sign.c (remove_keysigs): Self signatures are now skipped, changed arguments and all callers. * import.c : Add functionality. Tue Feb 17 09:31:40 1998 Werner Koch (wk@isil.d.shuttle.de) * options.h (homedir): New option. * g10.c, g10maint.c, getkey.c, keygen.c, trustdb.c (opt.homedir): New. * trustdb.c (init_trustdb): mkdir for hoem directory (sign_private_data): Renamed "sig" to "g10.sig" Mon Feb 16 20:02:03 1998 Werner Koch (wk@isil.d.shuttle.de) * kbnode.c (commit_kbnode): New. (delete_kbnode): removed unused first arg. Changed all Callers. * ringedit.c (keyblock_resource_name): New. (get_keyblock_handle): NULL for filename returns default resource. Mon Feb 16 19:38:48 1998 Werner Koch (wk@isil.d.shuttle.de) * sig-check.s (check_key_signature): Now uses the supplied public key to check the signature and not any more the one from the getkey.c (do_check): New. (check_signature): Most work moved to do_check. Mon Feb 16 14:48:57 1998 Werner Koch (wk@isil.d.shuttle.de) * armor.c (find_header): Fixed another bug. Mon Feb 16 12:18:34 1998 Werner Koch (wk@isil.d.shuttle.de) * getkey.c (scan_keyring): Add handling of compressed keyrings. Mon Feb 16 10:44:51 1998 Werner Koch (wk@isil.d.shuttle.de) * g10.c, g10maint.c (strusage): Rewrote. (build_list): New Mon Feb 16 08:58:41 1998 Werner Koch (wk@isil.d.shuttle.de) * armor.c (use_armor): New. Sat Feb 14 14:30:57 1998 Werner Koch (wk@isil.d.shuttle.de) * mainproc.c (proc_tree): Sigclass fix. Sat Feb 14 14:16:33 1998 Werner Koch (wk@isil.d.shuttle.de) * armor.c (armor_filter): Changed version and comment string. * encode.c, sign.c, keygen.c: Changed all comment packet strings. Sat Feb 14 12:39:24 1998 Werner Koch (wk@isil.d.shuttle.de) * g10.c (aGenRevoke): New command. * revoke.c: New. * sign.c (make_keysig_packet): Add support for sigclass 0x20. Fri Feb 13 20:18:14 1998 Werner Koch (wk@isil.d.shuttle.de) * ringedit.c (enum_keyblocks, keyring_enum): New. Fri Feb 13 19:33:40 1998 Werner Koch (wk@isil.d.shuttle.de) * export.c: Add functionality. * keygen.c (generate_keypair): Moved the leading comment behind the key packet. * kbnode.c (walk_kbnode): Fixed. * g10.c (main): listing armored keys now work. Fri Feb 13 16:17:43 1998 Werner Koch (wk@isil.d.shuttle.de) * parse-packet.c (parse_publickey, parse_signature): Fixed calls to mpi_read used for ELG b. Fri Feb 13 15:13:23 1998 Werner Koch (wk@isil.d.shuttle.de) * g10.c (main): changed formatting of help output. Thu Feb 12 22:24:42 1998 Werner Koch (wk@frodo) * pubkey-enc.c (get_session_key): rewritten Copyright 1998,1999,2000,2001,2002,2003,2004,2005, 2006,2007,2008,2009,2010 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/g10/Makefile.am b/g10/Makefile.am index 3a0529293..b89ff8ee6 100644 --- a/g10/Makefile.am +++ b/g10/Makefile.am @@ -1,141 +1,141 @@ # Copyright (C) 1998, 1999, 2000, 2001, 2002, # 2003, 2006 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 3 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, see . ## Process this file with automake to produce Makefile.in EXTRA_DIST = options.skel AM_CPPFLAGS = -I$(top_srcdir)/gl -I$(top_srcdir)/common \ -I$(top_srcdir)/include -I$(top_srcdir)/intl include $(top_srcdir)/am/cmacros.am AM_CFLAGS = $(LIBGCRYPT_CFLAGS) $(LIBASSUAN_CFLAGS) $(GPG_ERROR_CFLAGS) -needed_libs = $(libcommon) ../jnlib/libjnlib.a ../gl/libgnu.a +needed_libs = $(libcommon) ../gl/libgnu.a bin_PROGRAMS = gpg2 gpgv2 noinst_PROGRAMS = $(module_tests) TESTS = $(module_tests) if ENABLE_BZIP2_SUPPORT bzip2_source = compress-bz2.c else bzip2_source = endif common_source = \ gpg.h \ build-packet.c \ compress.c \ $(bzip2_source) \ filter.h \ free-packet.c \ getkey.c \ keydb.c keydb.h \ keyring.c keyring.h \ seskey.c \ kbnode.c \ main.h \ mainproc.c \ armor.c \ mdfilter.c \ textfilter.c \ progress.c \ misc.c \ rmd160.c rmd160.h \ options.h \ openfile.c \ keyid.c \ packet.h \ parse-packet.c \ cpr.c \ plaintext.c \ sig-check.c \ keylist.c \ pkglue.c pkglue.h gpg2_SOURCES = gpg.c \ server.c \ $(common_source) \ pkclist.c \ skclist.c \ pubkey-enc.c \ passphrase.c \ seckey-cert.c \ decrypt.c \ decrypt-data.c \ cipher.c \ encrypt.c \ sign.c \ verify.c \ revoke.c \ keyedit.c \ dearmor.c \ import.c \ export.c \ trustdb.c \ trustdb.h \ tdbdump.c \ tdbio.c \ tdbio.h \ delkey.c \ keygen.c \ helptext.c \ keyserver.c \ keyserver-internal.h \ photoid.c photoid.h \ call-agent.c call-agent.h \ card-util.c \ exec.c exec.h gpgv2_SOURCES = gpgv.c \ $(common_source) \ verify.c #gpgd_SOURCES = gpgd.c \ # ks-proto.h \ # ks-proto.c \ # ks-db.c \ # ks-db.h \ # $(common_source) LDADD = $(needed_libs) ../common/libgpgrl.a \ $(ZLIBS) $(DNSLIBS) $(LIBREADLINE) \ $(LIBINTL) $(CAPLIBS) $(NETLIBS) gpg2_LDADD = $(LDADD) $(LIBGCRYPT_LIBS) $(LIBASSUAN_LIBS) $(GPG_ERROR_LIBS) \ $(LIBICONV) gpgv2_LDADD = $(LDADD) $(LIBGCRYPT_LIBS) $(LIBASSUAN_LIBS) $(GPG_ERROR_LIBS) \ $(LIBICONV) t_common_ldadd = module_tests = t-rmd160 t_rmd160_SOURCES = t-rmd160.c rmd160.c t_rmd160_LDADD = $(t_common_ldadd) $(PROGRAMS): $(needed_libs) ../common/libgpgrl.a install-data-local: $(mkinstalldirs) $(DESTDIR)$(pkgdatadir) $(INSTALL_DATA) $(srcdir)/options.skel \ $(DESTDIR)$(pkgdatadir)/gpg-conf.skel uninstall-local: -@rm $(DESTDIR)$(pkgdatadir)/gpg-conf.skel diff --git a/g10/main.h b/g10/main.h index f0f1edc7c..ec09124bd 100644 --- a/g10/main.h +++ b/g10/main.h @@ -1,353 +1,352 @@ /* main.h * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, * 2008, 2009, 2010 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 3 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, see . */ #ifndef G10_MAIN_H #define G10_MAIN_H #include "types.h" #include "iobuf.h" #include "cipher.h" #include "keydb.h" #include "util.h" -#include "../common/estream.h" /* It could be argued that the default cipher should be 3DES rather than CAST5, and the default compression should be 0 (i.e. uncompressed) rather than 1 (zip). However, the real world issues of speed and size come into play here. */ #define DEFAULT_CIPHER_ALGO CIPHER_ALGO_CAST5 #define DEFAULT_DIGEST_ALGO DIGEST_ALGO_SHA1 #define DEFAULT_COMPRESS_ALGO COMPRESS_ALGO_ZIP #define DEFAULT_S2K_DIGEST_ALGO DIGEST_ALGO_SHA1 #define S2K_DIGEST_ALGO (opt.s2k_digest_algo?opt.s2k_digest_algo:DEFAULT_S2K_DIGEST_ALGO) typedef struct { int header_okay; PK_LIST pk_list; DEK *symkey_dek; STRING2KEY *symkey_s2k; cipher_filter_context_t cfx; } encrypt_filter_context_t; struct groupitem { char *name; strlist_t values; struct groupitem *next; }; /*-- gpg.c --*/ extern int g10_errors_seen; #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 5 ) void g10_exit(int rc) __attribute__ ((noreturn)); #else void g10_exit(int rc); #endif void print_pubkey_algo_note( int algo ); void print_cipher_algo_note( int algo ); void print_digest_algo_note( int algo ); /*-- armor.c --*/ char *make_radix64_string( const byte *data, size_t len ); /*-- misc.c --*/ void trap_unaligned(void); int disable_core_dumps(void); void register_secured_file (const char *fname); void unregister_secured_file (const char *fname); int is_secured_file (int fd); int is_secured_filename (const char *fname); u16 checksum_u16( unsigned n ); u16 checksum( byte *p, unsigned n ); u16 checksum_mpi( gcry_mpi_t a ); u32 buffer_to_u32( const byte *buffer ); const byte *get_session_marker( size_t *rlen ); int map_cipher_openpgp_to_gcry (int algo); #define openpgp_cipher_open(_a,_b,_c,_d) gcry_cipher_open((_a),map_cipher_openpgp_to_gcry((_b)),(_c),(_d)) #define openpgp_cipher_get_algo_keylen(_a) gcry_cipher_get_algo_keylen(map_cipher_openpgp_to_gcry((_a))) #define openpgp_cipher_get_algo_blklen(_a) gcry_cipher_get_algo_blklen(map_cipher_openpgp_to_gcry((_a))) int openpgp_cipher_blocklen (int algo); int openpgp_cipher_test_algo( int algo ); const char *openpgp_cipher_algo_name (int algo); int openpgp_pk_test_algo( int algo ); int openpgp_pk_test_algo2 ( int algo, unsigned int use ); int openpgp_pk_algo_usage ( int algo ); int openpgp_md_test_algo( int algo ); #ifdef USE_IDEA void idea_cipher_warn( int show ); #else #define idea_cipher_warn(a) do { } while (0) #endif struct expando_args { PKT_public_key *pk; PKT_public_key *pksk; byte imagetype; int validity_info; const char *validity_string; }; char *pct_expando(const char *string,struct expando_args *args); void deprecated_warning(const char *configname,unsigned int configlineno, const char *option,const char *repl1,const char *repl2); void deprecated_command (const char *name); void obsolete_option (const char *configname, unsigned int configlineno, const char *name); int string_to_cipher_algo (const char *string); int string_to_digest_algo (const char *string); const char *compress_algo_to_string(int algo); int string_to_compress_algo(const char *string); int check_compress_algo(int algo); int default_cipher_algo(void); int default_compress_algo(void); const char *compliance_option_string(void); void compliance_failure(void); struct parse_options { char *name; unsigned int bit; char **value; char *help; }; char *optsep(char **stringp); char *argsplit(char *string); int parse_options(char *str,unsigned int *options, struct parse_options *opts,int noisy); int has_invalid_email_chars (const char *s); int is_valid_mailbox (const char *name); const char *get_libexecdir (void); int path_access(const char *file,int mode); /* Temporary helpers. */ int pubkey_get_npkey( int algo ); int pubkey_get_nskey( int algo ); int pubkey_get_nsig( int algo ); int pubkey_get_nenc( int algo ); unsigned int pubkey_nbits( int algo, gcry_mpi_t *pkey ); int mpi_print( FILE *fp, gcry_mpi_t a, int mode ); /*-- status.c --*/ void set_status_fd ( int fd ); int is_status_enabled ( void ); void write_status ( int no ); void write_status_error (const char *where, gpg_error_t err); void write_status_errcode (const char *where, int errcode); void write_status_text ( int no, const char *text ); void write_status_buffer ( int no, const char *buffer, size_t len, int wrap ); void write_status_text_and_buffer ( int no, const char *text, const char *buffer, size_t len, int wrap ); void write_status_begin_signing (gcry_md_hd_t md); int cpr_enabled(void); char *cpr_get( const char *keyword, const char *prompt ); char *cpr_get_no_help( const char *keyword, const char *prompt ); char *cpr_get_utf8( const char *keyword, const char *prompt ); char *cpr_get_hidden( const char *keyword, const char *prompt ); void cpr_kill_prompt(void); int cpr_get_answer_is_yes( const char *keyword, const char *prompt ); int cpr_get_answer_yes_no_quit( const char *keyword, const char *prompt ); int cpr_get_answer_okay_cancel (const char *keyword, const char *prompt, int def_answer); /*-- helptext.c --*/ void display_online_help( const char *keyword ); /*-- encode.c --*/ int setup_symkey (STRING2KEY **symkey_s2k,DEK **symkey_dek); int encrypt_symmetric (const char *filename ); int encrypt_store (const char *filename ); int encrypt_crypt (int filefd, const char *filename, strlist_t remusr, int use_symkey, pk_list_t provided_keys, int outputfd); void encrypt_crypt_files (int nfiles, char **files, strlist_t remusr); int encrypt_filter (void *opaque, int control, iobuf_t a, byte *buf, size_t *ret_len); /*-- sign.c --*/ int complete_sig (PKT_signature *sig, PKT_public_key *pksk, gcry_md_hd_t md); int sign_file( strlist_t filenames, int detached, strlist_t locusr, int do_encrypt, strlist_t remusr, const char *outfile ); int clearsign_file( const char *fname, strlist_t locusr, const char *outfile ); int sign_symencrypt_file (const char *fname, strlist_t locusr); /*-- sig-check.c --*/ int check_revocation_keys (PKT_public_key *pk, PKT_signature *sig); int check_backsig(PKT_public_key *main_pk,PKT_public_key *sub_pk, PKT_signature *backsig); int check_key_signature( KBNODE root, KBNODE node, int *is_selfsig ); int check_key_signature2( KBNODE root, KBNODE node, PKT_public_key *check_pk, PKT_public_key *ret_pk, int *is_selfsig, u32 *r_expiredate, int *r_expired ); /*-- delkey.c --*/ int delete_keys( strlist_t names, int secret, int allow_both ); /*-- keyedit.c --*/ void keyedit_menu( const char *username, strlist_t locusr, strlist_t commands, int quiet, int seckey_check ); void keyedit_passwd (const char *username); void show_basic_key_info (KBNODE keyblock); /*-- keygen.c --*/ u32 parse_expire_string(const char *string); u32 ask_expire_interval(int object,const char *def_expire); u32 ask_expiredate(void); void generate_keypair( const char *fname, const char *card_serialno, const char *backup_encryption_dir ); int keygen_set_std_prefs (const char *string,int personal); PKT_user_id *keygen_get_std_prefs (void); int keygen_add_key_expire( PKT_signature *sig, void *opaque ); int keygen_add_std_prefs( PKT_signature *sig, void *opaque ); int keygen_upd_std_prefs( PKT_signature *sig, void *opaque ); int keygen_add_keyserver_url(PKT_signature *sig, void *opaque); int keygen_add_notations(PKT_signature *sig,void *opaque); int keygen_add_revkey(PKT_signature *sig, void *opaque); int make_backsig(PKT_signature *sig,PKT_public_key *pk, PKT_public_key *sub_pk,PKT_secret_key *sub_sk, u32 timestamp); int generate_subkeypair( KBNODE pub_keyblock, KBNODE sec_keyblock ); #ifdef ENABLE_CARD_SUPPORT int generate_card_subkeypair (KBNODE pub_keyblock, KBNODE sec_keyblock, int keyno, const char *serialno); int save_unprotected_key_to_card (PKT_secret_key *sk, int keyno); #endif /*-- openfile.c --*/ int overwrite_filep( const char *fname ); char *make_outfile_name( const char *iname ); char *ask_outfile_name( const char *name, size_t namelen ); int open_outfile (int inp_fd, const char *iname, int mode, iobuf_t *a); iobuf_t open_sigfile( const char *iname, progress_filter_context_t *pfx ); void try_make_homedir( const char *fname ); /*-- seskey.c --*/ void make_session_key( DEK *dek ); gcry_mpi_t encode_session_key( DEK *dek, unsigned nbits ); gcry_mpi_t encode_md_value( PKT_public_key *pk, PKT_secret_key *sk, gcry_md_hd_t md, int hash_algo ); /*-- import.c --*/ int parse_import_options(char *str,unsigned int *options,int noisy); void import_keys( char **fnames, int nnames, void *stats_hd, unsigned int options ); int import_keys_stream( iobuf_t inp,void *stats_hd,unsigned char **fpr, size_t *fpr_len,unsigned int options ); void *import_new_stats_handle (void); void import_release_stats_handle (void *p); void import_print_stats (void *hd); int collapse_uids( KBNODE *keyblock ); int auto_create_card_key_stub ( const char *serialnostr, const unsigned char *fpr1, const unsigned char *fpr2, const unsigned char *fpr3); /*-- export.c --*/ int parse_export_options(char *str,unsigned int *options,int noisy); int export_pubkeys( strlist_t users, unsigned int options ); int export_pubkeys_stream( iobuf_t out, strlist_t users, KBNODE *keyblock_out, unsigned int options ); int export_seckeys( strlist_t users ); int export_secsubkeys( strlist_t users ); /* dearmor.c --*/ int dearmor_file( const char *fname ); int enarmor_file( const char *fname ); /*-- revoke.c --*/ struct revocation_reason_info; int gen_revoke( const char *uname ); int gen_desig_revoke( const char *uname, strlist_t locusr); int revocation_reason_build_cb( PKT_signature *sig, void *opaque ); struct revocation_reason_info * ask_revocation_reason( int key_rev, int cert_rev, int hint ); void release_revocation_reason_info( struct revocation_reason_info *reason ); /*-- keylist.c --*/ void public_key_list( strlist_t list, int locate_mode ); void secret_key_list( strlist_t list ); void print_subpackets_colon(PKT_signature *sig); void reorder_keyblock (KBNODE keyblock); void list_keyblock( KBNODE keyblock, int secret, int fpr, void *opaque ); void print_fingerprint (PKT_public_key *pk, PKT_secret_key *sk, int mode); void print_revokers(PKT_public_key *pk); void show_policy_url(PKT_signature *sig,int indent,int mode); void show_keyserver_url(PKT_signature *sig,int indent,int mode); void show_notation(PKT_signature *sig,int indent,int mode,int which); void dump_attribs (const PKT_user_id *uid, PKT_public_key *pk); void set_attrib_fd(int fd); void print_seckey_info (PKT_public_key *pk); void print_pubkey_info (FILE *fp, PKT_public_key *pk); void print_card_key_info (FILE *fp, KBNODE keyblock); /*-- verify.c --*/ void print_file_status( int status, const char *name, int what ); int verify_signatures( int nfiles, char **files ); int verify_files( int nfiles, char **files ); int gpg_verify (ctrl_t ctrl, int sig_fd, int data_fd, estream_t out_fp); /*-- decrypt.c --*/ int decrypt_message( const char *filename ); gpg_error_t decrypt_message_fd (int input_fd, int output_fd); void decrypt_messages(int nfiles, char *files[]); /*-- plaintext.c --*/ int hash_datafiles( gcry_md_hd_t md, gcry_md_hd_t md2, strlist_t files, const char *sigfilename, int textmode ); int hash_datafile_by_fd ( gcry_md_hd_t md, gcry_md_hd_t md2, int data_fd, int textmode ); PKT_plaintext *setup_plaintext_name(const char *filename,IOBUF iobuf); /*-- signal.c --*/ void init_signals(void); void pause_on_sigusr( int which ); void block_all_signals(void); void unblock_all_signals(void); /*-- server.c --*/ int gpg_server (ctrl_t); #ifdef ENABLE_CARD_SUPPORT /*-- card-util.c --*/ void change_pin (int no, int allow_admin); void card_status (FILE *fp, char *serialno, size_t serialnobuflen); void card_edit (strlist_t commands); int card_generate_subkey (KBNODE pub_keyblock, KBNODE sec_keyblock); int card_store_subkey (KBNODE node, int use); #endif #define S2K_DECODE_COUNT(_val) ((16ul + ((_val) & 15)) << (((_val) >> 4) + 6)) #endif /*G10_MAIN_H*/ diff --git a/g10/packet.h b/g10/packet.h index a97fe07a3..54f8295c1 100644 --- a/g10/packet.h +++ b/g10/packet.h @@ -1,520 +1,520 @@ /* packet.h - OpenPGP packet definitions * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, * 2007 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 3 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, see . */ #ifndef G10_PACKET_H #define G10_PACKET_H #include "types.h" #include "../common/iobuf.h" -#include "../jnlib/strlist.h" +#include "../common/strlist.h" #include "cipher.h" #include "filter.h" #include "../common/openpgpdefs.h" #include "../common/userids.h" #define DEBUG_PARSE_PACKET 1 typedef struct packet_struct PACKET; /* PKT_GPG_CONTROL types */ typedef enum { CTRLPKT_CLEARSIGN_START = 1, CTRLPKT_PIPEMODE = 2, CTRLPKT_PLAINTEXT_MARK =3 } ctrlpkttype_t; typedef enum { PREFTYPE_NONE = 0, PREFTYPE_SYM = 1, PREFTYPE_HASH = 2, PREFTYPE_ZIP = 3 } preftype_t; typedef struct { byte type; byte value; } prefitem_t; typedef struct { int mode; byte hash_algo; byte salt[8]; u32 count; } STRING2KEY; typedef struct { byte version; byte cipher_algo; /* cipher algorithm used */ STRING2KEY s2k; byte seskeylen; /* keylength in byte or 0 for no seskey */ byte seskey[1]; } PKT_symkey_enc; typedef struct { u32 keyid[2]; /* 64 bit keyid */ byte version; byte pubkey_algo; /* algorithm used for public key scheme */ byte throw_keyid; gcry_mpi_t data[PUBKEY_MAX_NENC]; } PKT_pubkey_enc; typedef struct { u32 keyid[2]; /* 64 bit keyid */ byte sig_class; /* sig classification */ byte digest_algo; /* algorithm used for digest */ byte pubkey_algo; /* algorithm used for public key scheme */ byte last; /* a stupid flag */ } PKT_onepass_sig; typedef struct { size_t size; /* allocated */ size_t len; /* used */ byte data[1]; } subpktarea_t; struct revocation_key { byte class; byte algid; byte fpr[MAX_FINGERPRINT_LEN]; }; /* Object to keep information about a PKA DNS record. */ typedef struct { int valid; /* An actual PKA record exists for EMAIL. */ int checked; /* Set to true if the FPR has been checked against the actual key. */ char *uri; /* Malloced string with the URI. NULL if the URI is not available.*/ unsigned char fpr[20]; /* The fingerprint as stored in the PKA RR. */ char email[1];/* The email address from the notation data. */ } pka_info_t; /* Object to keep information pertaining to a signature. */ typedef struct { struct { unsigned checked:1; /* Signature has been checked. */ unsigned valid:1; /* Signature is good (if checked is set). */ unsigned chosen_selfsig:1; /* A selfsig that is the chosen one. */ unsigned unknown_critical:1; unsigned exportable:1; unsigned revocable:1; unsigned policy_url:1; /* At least one policy URL is present */ unsigned notation:1; /* At least one notation is present */ unsigned pref_ks:1; /* At least one preferred keyserver is present */ unsigned expired:1; unsigned pka_tried:1; /* Set if we tried to retrieve the PKA record. */ } flags; u32 keyid[2]; /* 64 bit keyid */ u32 timestamp; /* Signature made (seconds since Epoch). */ u32 expiredate; /* Expires at this date or 0 if not at all. */ byte version; byte sig_class; /* Sig classification, append for MD calculation. */ byte pubkey_algo; /* Algorithm used for public key scheme */ /* (PUBKEY_ALGO_xxx) */ byte digest_algo; /* Algorithm used for digest (DIGEST_ALGO_xxxx). */ byte trust_depth; byte trust_value; const byte *trust_regexp; struct revocation_key **revkey; int numrevkeys; pka_info_t *pka_info; /* Malloced PKA data or NULL if not available. See also flags.pka_tried. */ subpktarea_t *hashed; /* All subpackets with hashed data (v4 only). */ subpktarea_t *unhashed; /* Ditto for unhashed data. */ byte digest_start[2]; /* First 2 bytes of the digest. */ gcry_mpi_t data[PUBKEY_MAX_NSIG]; } PKT_signature; #define ATTRIB_IMAGE 1 /* This is the cooked form of attributes. */ struct user_attribute { byte type; const byte *data; u32 len; }; /* (See also keybox-search-desc.h) */ struct gpg_pkt_user_id_s { int ref; /* reference counter */ int len; /* length of the name */ struct user_attribute *attribs; int numattribs; byte *attrib_data; /* if this is not NULL, the packet is an attribute */ unsigned long attrib_len; byte *namehash; int help_key_usage; u32 help_key_expire; int help_full_count; int help_marginal_count; int is_primary; /* 2 if set via the primary flag, 1 if calculated */ int is_revoked; int is_expired; u32 expiredate; /* expires at this date or 0 if not at all */ prefitem_t *prefs; /* list of preferences (may be NULL)*/ u32 created; /* according to the self-signature */ byte selfsigversion; struct { /* TODO: Move more flags here */ unsigned int mdc:1; unsigned int ks_modify:1; unsigned int compacted:1; } flags; char name[1]; }; typedef struct gpg_pkt_user_id_s PKT_user_id; struct revoke_info { /* revoked at this date */ u32 date; /* the keyid of the revoking key (selfsig or designated revoker) */ u32 keyid[2]; /* the algo of the revoking key */ byte algo; }; /**************** * Note about the pkey/skey elements: We assume that the secret keys * has the same elemts as the public key at the begin of the array, so * that npkey < nskey and it is possible to compare the secret and * public keys by comparing the first npkey elements of pkey againts skey. */ typedef struct { u32 timestamp; /* key made */ u32 expiredate; /* expires at this date or 0 if not at all */ u32 max_expiredate; /* must not expire past this date */ struct revoke_info revoked; byte hdrbytes; /* number of header bytes */ byte version; byte selfsigversion; /* highest version of all of the self-sigs */ byte pubkey_algo; /* algorithm used for public key scheme */ byte pubkey_usage; /* for now only used to pass it to getkey() */ byte req_usage; /* hack to pass a request to getkey() */ byte req_algo; /* Ditto */ u32 has_expired; /* set to the expiration date if expired */ int is_revoked; /* key has been revoked, 1 if by the owner, 2 if by a designated revoker */ int maybe_revoked; /* a designated revocation is present, but without the key to check it */ int is_valid; /* key (especially subkey) is valid */ int dont_cache; /* do not cache this */ byte backsig; /* 0=none, 1=bad, 2=good */ u32 main_keyid[2]; /* keyid of the primary key */ u32 keyid[2]; /* calculated by keyid_from_pk() */ byte is_primary; byte is_disabled; /* 0 for unset, 1 for enabled, 2 for disabled. */ prefitem_t *prefs; /* list of preferences (may be NULL) */ int mdc_feature; /* mdc feature set */ PKT_user_id *user_id; /* if != NULL: found by that uid */ struct revocation_key *revkey; int numrevkeys; u32 trust_timestamp; byte trust_depth; byte trust_value; const byte *trust_regexp; gcry_mpi_t pkey[PUBKEY_MAX_NPKEY]; } PKT_public_key; /* Evaluates as true if the pk is disabled, and false if it isn't. If there is no disable value cached, fill one in. */ #define pk_is_disabled(a) (((a)->is_disabled)?((a)->is_disabled==2):(cache_disabled_value((a)))) typedef struct { u32 timestamp; /* key made */ u32 expiredate; /* expires at this date or 0 if not at all */ u32 max_expiredate; /* must not expire past this date */ byte hdrbytes; /* number of header bytes */ byte version; byte pubkey_algo; /* algorithm used for public key scheme */ byte pubkey_usage; byte req_usage; byte req_algo; u32 has_expired; /* set to the expiration date if expired */ int is_revoked; /* key has been revoked */ int is_valid; /* key (especially subkey) is valid */ u32 main_keyid[2]; /* keyid of the primary key */ u32 keyid[2]; byte is_primary; byte is_protected; /* The secret info is protected and must */ /* be decrypted before use, the protected */ /* MPIs are simply (void*) pointers to memory */ /* and should never be passed to a mpi_xxx() */ struct { byte algo; /* cipher used to protect the secret information*/ byte sha1chk; /* SHA1 is used instead of a 16 bit checksum */ STRING2KEY s2k; byte ivlen; /* used length of the iv */ byte iv[16]; /* initialization vector for CFB mode */ } protect; gcry_mpi_t skey[PUBKEY_MAX_NSKEY]; u16 csum; /* checksum */ } PKT_secret_key; typedef struct { int len; /* length of data */ char data[1]; } PKT_comment; typedef struct { u32 len; /* reserved */ byte new_ctb; byte algorithm; iobuf_t buf; /* IOBUF reference */ } PKT_compressed; typedef struct { u32 len; /* Remaining length of encrypted data. */ int extralen; /* This is (blocksize+2). Used by build_packet. */ byte new_ctb; /* uses a new CTB */ byte is_partial; /* partial length encoded */ byte mdc_method; /* > 0: integrity protected encrypted data packet */ iobuf_t buf; /* IOBUF reference */ } PKT_encrypted; typedef struct { byte hash[20]; } PKT_mdc; typedef struct { unsigned int trustval; unsigned int sigcache; } PKT_ring_trust; typedef struct { u32 len; /* length of encrypted data */ iobuf_t buf; /* IOBUF reference */ byte new_ctb; byte is_partial; /* partial length encoded */ int mode; u32 timestamp; int namelen; char name[1]; } PKT_plaintext; typedef struct { int control; size_t datalen; char data[1]; } PKT_gpg_control; /* combine all packets into a union */ struct packet_struct { pkttype_t pkttype; union { void *generic; PKT_symkey_enc *symkey_enc; /* PKT_SYMKEY_ENC */ PKT_pubkey_enc *pubkey_enc; /* PKT_PUBKEY_ENC */ PKT_onepass_sig *onepass_sig; /* PKT_ONEPASS_SIG */ PKT_signature *signature; /* PKT_SIGNATURE */ PKT_public_key *public_key; /* PKT_PUBLIC_[SUB)KEY */ PKT_secret_key *secret_key; /* PKT_SECRET_[SUB]KEY */ PKT_comment *comment; /* PKT_COMMENT */ PKT_user_id *user_id; /* PKT_USER_ID */ PKT_compressed *compressed; /* PKT_COMPRESSED */ PKT_encrypted *encrypted; /* PKT_ENCRYPTED[_MDC] */ PKT_mdc *mdc; /* PKT_MDC */ PKT_ring_trust *ring_trust; /* PKT_RING_TRUST */ PKT_plaintext *plaintext; /* PKT_PLAINTEXT */ PKT_gpg_control *gpg_control; /* PKT_GPG_CONTROL */ } pkt; }; #define init_packet(a) do { (a)->pkttype = 0; \ (a)->pkt.generic = NULL; \ } while(0) struct notation { char *name; char *value; char *altvalue; unsigned char *bdat; size_t blen; struct { unsigned int critical:1; unsigned int ignore:1; } flags; struct notation *next; }; /*-- mainproc.c --*/ void reset_literals_seen(void); int proc_packets( void *ctx, iobuf_t a ); int proc_signature_packets( void *ctx, iobuf_t a, strlist_t signedfiles, const char *sigfile ); int proc_signature_packets_by_fd ( void *anchor, IOBUF a, int signed_data_fd ); int proc_encryption_packets( void *ctx, iobuf_t a ); int list_packets( iobuf_t a ); /*-- parse-packet.c --*/ int set_packet_list_mode( int mode ); #if DEBUG_PARSE_PACKET int dbg_search_packet( iobuf_t inp, PACKET *pkt, off_t *retpos, int with_uid, const char* file, int lineno ); int dbg_parse_packet( iobuf_t inp, PACKET *ret_pkt, const char* file, int lineno ); int dbg_copy_all_packets( iobuf_t inp, iobuf_t out, const char* file, int lineno ); int dbg_copy_some_packets( iobuf_t inp, iobuf_t out, off_t stopoff, const char* file, int lineno ); int dbg_skip_some_packets( iobuf_t inp, unsigned n, const char* file, int lineno ); #define search_packet( a,b,c,d ) \ dbg_search_packet( (a), (b), (c), (d), __FILE__, __LINE__ ) #define parse_packet( a, b ) \ dbg_parse_packet( (a), (b), __FILE__, __LINE__ ) #define copy_all_packets( a,b ) \ dbg_copy_all_packets((a),(b), __FILE__, __LINE__ ) #define copy_some_packets( a,b,c ) \ dbg_copy_some_packets((a),(b),(c), __FILE__, __LINE__ ) #define skip_some_packets( a,b ) \ dbg_skip_some_packets((a),(b), __FILE__, __LINE__ ) #else int search_packet( iobuf_t inp, PACKET *pkt, off_t *retpos, int with_uid ); int parse_packet( iobuf_t inp, PACKET *ret_pkt); int copy_all_packets( iobuf_t inp, iobuf_t out ); int copy_some_packets( iobuf_t inp, iobuf_t out, off_t stopoff ); int skip_some_packets( iobuf_t inp, unsigned n ); #endif int parse_signature( iobuf_t inp, int pkttype, unsigned long pktlen, PKT_signature *sig ); const byte *enum_sig_subpkt ( const subpktarea_t *subpkts, sigsubpkttype_t reqtype, size_t *ret_n, int *start, int *critical ); const byte *parse_sig_subpkt ( const subpktarea_t *buffer, sigsubpkttype_t reqtype, size_t *ret_n ); const byte *parse_sig_subpkt2 ( PKT_signature *sig, sigsubpkttype_t reqtype, size_t *ret_n ); int parse_one_sig_subpkt( const byte *buffer, size_t n, int type ); void parse_revkeys(PKT_signature *sig); int parse_attribute_subpkts(PKT_user_id *uid); void make_attribute_uidname(PKT_user_id *uid, size_t max_namelen); PACKET *create_gpg_control ( ctrlpkttype_t type, const byte *data, size_t datalen ); /*-- build-packet.c --*/ int build_packet( iobuf_t inp, PACKET *pkt ); u32 calc_packet_length( PACKET *pkt ); void build_sig_subpkt( PKT_signature *sig, sigsubpkttype_t type, const byte *buffer, size_t buflen ); void build_sig_subpkt_from_sig( PKT_signature *sig ); int delete_sig_subpkt(subpktarea_t *buffer, sigsubpkttype_t type ); void build_attribute_subpkt(PKT_user_id *uid,byte type, const void *buf,u32 buflen, const void *header,u32 headerlen); struct notation *string_to_notation(const char *string,int is_utf8); struct notation *sig_to_notation(PKT_signature *sig); void free_notation(struct notation *notation); /*-- free-packet.c --*/ void free_symkey_enc( PKT_symkey_enc *enc ); void free_pubkey_enc( PKT_pubkey_enc *enc ); void free_seckey_enc( PKT_signature *enc ); int digest_algo_from_sig( PKT_signature *sig ); void release_public_key_parts( PKT_public_key *pk ); void free_public_key( PKT_public_key *key ); void release_secret_key_parts( PKT_secret_key *sk ); void free_secret_key( PKT_secret_key *sk ); void free_attributes(PKT_user_id *uid); void free_user_id( PKT_user_id *uid ); void free_comment( PKT_comment *rem ); void free_packet( PACKET *pkt ); prefitem_t *copy_prefs (const prefitem_t *prefs); PKT_public_key *copy_public_key( PKT_public_key *d, PKT_public_key *s ); void copy_public_parts_to_secret_key( PKT_public_key *pk, PKT_secret_key *sk ); PKT_secret_key *copy_secret_key( PKT_secret_key *d, PKT_secret_key *s ); PKT_signature *copy_signature( PKT_signature *d, PKT_signature *s ); PKT_user_id *scopy_user_id (PKT_user_id *sd ); int cmp_public_keys( PKT_public_key *a, PKT_public_key *b ); int cmp_secret_keys( PKT_secret_key *a, PKT_secret_key *b ); int cmp_signatures( PKT_signature *a, PKT_signature *b ); int cmp_public_secret_key( PKT_public_key *pk, PKT_secret_key *sk ); int cmp_user_ids( PKT_user_id *a, PKT_user_id *b ); /*-- sig-check.c --*/ int signature_check( PKT_signature *sig, gcry_md_hd_t digest ); int signature_check2( PKT_signature *sig, gcry_md_hd_t digest, u32 *r_expiredate, int *r_expired, int *r_revoked, PKT_public_key *ret_pk ); /*-- seckey-cert.c --*/ int is_secret_key_protected( PKT_secret_key *sk ); int check_secret_key( PKT_secret_key *sk, int retries ); int protect_secret_key( PKT_secret_key *sk, DEK *dek ); /*-- pubkey-enc.c --*/ int get_session_key( PKT_pubkey_enc *k, DEK *dek ); int get_override_session_key( DEK *dek, const char *string ); /*-- compress.c --*/ int handle_compressed( void *ctx, PKT_compressed *cd, int (*callback)(iobuf_t, void *), void *passthru ); /*-- encr-data.c --*/ int decrypt_data( void *ctx, PKT_encrypted *ed, DEK *dek ); /*-- plaintext.c --*/ int handle_plaintext( PKT_plaintext *pt, md_filter_context_t *mfx, int nooutput, int clearsig ); int ask_for_detached_datafile( gcry_md_hd_t md, gcry_md_hd_t md2, const char *inname, int textmode ); /*-- sign.c --*/ int make_keysig_packet( PKT_signature **ret_sig, PKT_public_key *pk, PKT_user_id *uid, PKT_public_key *subpk, PKT_public_key *pksk, int sigclass, int digest_algo, int sigversion, u32 timestamp, u32 duration, int (*mksubpkt)(PKT_signature *, void *), void *opaque ); int update_keysig_packet( PKT_signature **ret_sig, PKT_signature *orig_sig, PKT_public_key *pk, PKT_user_id *uid, PKT_public_key *subpk, PKT_public_key *pksk, int (*mksubpkt)(PKT_signature *, void *), void *opaque ); /*-- keygen.c --*/ PKT_user_id *generate_user_id (KBNODE keyblock); #endif /*G10_PACKET_H*/ diff --git a/g10/rmd160.c b/g10/rmd160.c index f89193707..febfa618a 100644 --- a/g10/rmd160.c +++ b/g10/rmd160.c @@ -1,425 +1,425 @@ /* rmd160.c - RIPE-MD160 * Copyright (C) 1998, 1999, 2000, 2001, 2008 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 3 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, see . */ /* For historic reasons gpg uses RIPE-MD160 to to identify names in the trustdb. It would be better to change that to SHA-1, to take advantage of a SHA-1 hardware operation provided by some CPUs. This would break trustdb compatibility and thus we don't want to do it now. We do not use the libgcrypt provided implementation of RMD160 because that is not available in FIPS mode, thus for the sake of gpg internal non-cryptographic, purposes, we use this separate implementation. */ #include #include #include #include -#include "../jnlib/types.h" +#include "../common/types.h" #include "rmd160.h" /* * Rotate the 32 bit integer X by N bytes. */ #if defined(__GNUC__) && defined(__i386__) static inline u32 rol (u32 x, int n) { __asm__("roll %%cl,%0" :"=r" (x) :"0" (x),"c" (n)); return x; } #else #define rol(x,n) ( ((x) << (n)) | ((x) >> (32-(n))) ) #endif /* Structure holding the context for the RIPE-MD160 computation. */ typedef struct { u32 h0, h1, h2, h3, h4; u32 nblocks; unsigned char buf[64]; int count; } rmd160_context_t; static void rmd160_init (rmd160_context_t *hd) { hd->h0 = 0x67452301; hd->h1 = 0xEFCDAB89; hd->h2 = 0x98BADCFE; hd->h3 = 0x10325476; hd->h4 = 0xC3D2E1F0; hd->nblocks = 0; hd->count = 0; } /* * Transform the message X which consists of 16 32-bit-words. */ static void transform (rmd160_context_t *hd, const unsigned char *data) { u32 a,b,c,d,e,aa,bb,cc,dd,ee,t; #ifdef BIG_ENDIAN_HOST u32 x[16]; { int i; unsigned char *p2, *p1; for (i=0, p1=data, p2=(unsigned char*)x; i < 16; i++, p2 += 4 ) { p2[3] = *p1++; p2[2] = *p1++; p2[1] = *p1++; p2[0] = *p1++; } } #else u32 x[16]; memcpy (x, data, 64); #endif #define K0 0x00000000 #define K1 0x5A827999 #define K2 0x6ED9EBA1 #define K3 0x8F1BBCDC #define K4 0xA953FD4E #define KK0 0x50A28BE6 #define KK1 0x5C4DD124 #define KK2 0x6D703EF3 #define KK3 0x7A6D76E9 #define KK4 0x00000000 #define F0(x,y,z) ( (x) ^ (y) ^ (z) ) #define F1(x,y,z) ( ((x) & (y)) | (~(x) & (z)) ) #define F2(x,y,z) ( ((x) | ~(y)) ^ (z) ) #define F3(x,y,z) ( ((x) & (z)) | ((y) & ~(z)) ) #define F4(x,y,z) ( (x) ^ ((y) | ~(z)) ) #define R(a,b,c,d,e,f,k,r,s) do { t = a + f(b,c,d) + k + x[r]; \ a = rol(t,s) + e; \ c = rol(c,10); \ } while(0) /* Left lane. */ a = hd->h0; b = hd->h1; c = hd->h2; d = hd->h3; e = hd->h4; R( a, b, c, d, e, F0, K0, 0, 11 ); R( e, a, b, c, d, F0, K0, 1, 14 ); R( d, e, a, b, c, F0, K0, 2, 15 ); R( c, d, e, a, b, F0, K0, 3, 12 ); R( b, c, d, e, a, F0, K0, 4, 5 ); R( a, b, c, d, e, F0, K0, 5, 8 ); R( e, a, b, c, d, F0, K0, 6, 7 ); R( d, e, a, b, c, F0, K0, 7, 9 ); R( c, d, e, a, b, F0, K0, 8, 11 ); R( b, c, d, e, a, F0, K0, 9, 13 ); R( a, b, c, d, e, F0, K0, 10, 14 ); R( e, a, b, c, d, F0, K0, 11, 15 ); R( d, e, a, b, c, F0, K0, 12, 6 ); R( c, d, e, a, b, F0, K0, 13, 7 ); R( b, c, d, e, a, F0, K0, 14, 9 ); R( a, b, c, d, e, F0, K0, 15, 8 ); R( e, a, b, c, d, F1, K1, 7, 7 ); R( d, e, a, b, c, F1, K1, 4, 6 ); R( c, d, e, a, b, F1, K1, 13, 8 ); R( b, c, d, e, a, F1, K1, 1, 13 ); R( a, b, c, d, e, F1, K1, 10, 11 ); R( e, a, b, c, d, F1, K1, 6, 9 ); R( d, e, a, b, c, F1, K1, 15, 7 ); R( c, d, e, a, b, F1, K1, 3, 15 ); R( b, c, d, e, a, F1, K1, 12, 7 ); R( a, b, c, d, e, F1, K1, 0, 12 ); R( e, a, b, c, d, F1, K1, 9, 15 ); R( d, e, a, b, c, F1, K1, 5, 9 ); R( c, d, e, a, b, F1, K1, 2, 11 ); R( b, c, d, e, a, F1, K1, 14, 7 ); R( a, b, c, d, e, F1, K1, 11, 13 ); R( e, a, b, c, d, F1, K1, 8, 12 ); R( d, e, a, b, c, F2, K2, 3, 11 ); R( c, d, e, a, b, F2, K2, 10, 13 ); R( b, c, d, e, a, F2, K2, 14, 6 ); R( a, b, c, d, e, F2, K2, 4, 7 ); R( e, a, b, c, d, F2, K2, 9, 14 ); R( d, e, a, b, c, F2, K2, 15, 9 ); R( c, d, e, a, b, F2, K2, 8, 13 ); R( b, c, d, e, a, F2, K2, 1, 15 ); R( a, b, c, d, e, F2, K2, 2, 14 ); R( e, a, b, c, d, F2, K2, 7, 8 ); R( d, e, a, b, c, F2, K2, 0, 13 ); R( c, d, e, a, b, F2, K2, 6, 6 ); R( b, c, d, e, a, F2, K2, 13, 5 ); R( a, b, c, d, e, F2, K2, 11, 12 ); R( e, a, b, c, d, F2, K2, 5, 7 ); R( d, e, a, b, c, F2, K2, 12, 5 ); R( c, d, e, a, b, F3, K3, 1, 11 ); R( b, c, d, e, a, F3, K3, 9, 12 ); R( a, b, c, d, e, F3, K3, 11, 14 ); R( e, a, b, c, d, F3, K3, 10, 15 ); R( d, e, a, b, c, F3, K3, 0, 14 ); R( c, d, e, a, b, F3, K3, 8, 15 ); R( b, c, d, e, a, F3, K3, 12, 9 ); R( a, b, c, d, e, F3, K3, 4, 8 ); R( e, a, b, c, d, F3, K3, 13, 9 ); R( d, e, a, b, c, F3, K3, 3, 14 ); R( c, d, e, a, b, F3, K3, 7, 5 ); R( b, c, d, e, a, F3, K3, 15, 6 ); R( a, b, c, d, e, F3, K3, 14, 8 ); R( e, a, b, c, d, F3, K3, 5, 6 ); R( d, e, a, b, c, F3, K3, 6, 5 ); R( c, d, e, a, b, F3, K3, 2, 12 ); R( b, c, d, e, a, F4, K4, 4, 9 ); R( a, b, c, d, e, F4, K4, 0, 15 ); R( e, a, b, c, d, F4, K4, 5, 5 ); R( d, e, a, b, c, F4, K4, 9, 11 ); R( c, d, e, a, b, F4, K4, 7, 6 ); R( b, c, d, e, a, F4, K4, 12, 8 ); R( a, b, c, d, e, F4, K4, 2, 13 ); R( e, a, b, c, d, F4, K4, 10, 12 ); R( d, e, a, b, c, F4, K4, 14, 5 ); R( c, d, e, a, b, F4, K4, 1, 12 ); R( b, c, d, e, a, F4, K4, 3, 13 ); R( a, b, c, d, e, F4, K4, 8, 14 ); R( e, a, b, c, d, F4, K4, 11, 11 ); R( d, e, a, b, c, F4, K4, 6, 8 ); R( c, d, e, a, b, F4, K4, 15, 5 ); R( b, c, d, e, a, F4, K4, 13, 6 ); aa = a; bb = b; cc = c; dd = d; ee = e; /* Right lane. */ a = hd->h0; b = hd->h1; c = hd->h2; d = hd->h3; e = hd->h4; R( a, b, c, d, e, F4, KK0, 5, 8); R( e, a, b, c, d, F4, KK0, 14, 9); R( d, e, a, b, c, F4, KK0, 7, 9); R( c, d, e, a, b, F4, KK0, 0, 11); R( b, c, d, e, a, F4, KK0, 9, 13); R( a, b, c, d, e, F4, KK0, 2, 15); R( e, a, b, c, d, F4, KK0, 11, 15); R( d, e, a, b, c, F4, KK0, 4, 5); R( c, d, e, a, b, F4, KK0, 13, 7); R( b, c, d, e, a, F4, KK0, 6, 7); R( a, b, c, d, e, F4, KK0, 15, 8); R( e, a, b, c, d, F4, KK0, 8, 11); R( d, e, a, b, c, F4, KK0, 1, 14); R( c, d, e, a, b, F4, KK0, 10, 14); R( b, c, d, e, a, F4, KK0, 3, 12); R( a, b, c, d, e, F4, KK0, 12, 6); R( e, a, b, c, d, F3, KK1, 6, 9); R( d, e, a, b, c, F3, KK1, 11, 13); R( c, d, e, a, b, F3, KK1, 3, 15); R( b, c, d, e, a, F3, KK1, 7, 7); R( a, b, c, d, e, F3, KK1, 0, 12); R( e, a, b, c, d, F3, KK1, 13, 8); R( d, e, a, b, c, F3, KK1, 5, 9); R( c, d, e, a, b, F3, KK1, 10, 11); R( b, c, d, e, a, F3, KK1, 14, 7); R( a, b, c, d, e, F3, KK1, 15, 7); R( e, a, b, c, d, F3, KK1, 8, 12); R( d, e, a, b, c, F3, KK1, 12, 7); R( c, d, e, a, b, F3, KK1, 4, 6); R( b, c, d, e, a, F3, KK1, 9, 15); R( a, b, c, d, e, F3, KK1, 1, 13); R( e, a, b, c, d, F3, KK1, 2, 11); R( d, e, a, b, c, F2, KK2, 15, 9); R( c, d, e, a, b, F2, KK2, 5, 7); R( b, c, d, e, a, F2, KK2, 1, 15); R( a, b, c, d, e, F2, KK2, 3, 11); R( e, a, b, c, d, F2, KK2, 7, 8); R( d, e, a, b, c, F2, KK2, 14, 6); R( c, d, e, a, b, F2, KK2, 6, 6); R( b, c, d, e, a, F2, KK2, 9, 14); R( a, b, c, d, e, F2, KK2, 11, 12); R( e, a, b, c, d, F2, KK2, 8, 13); R( d, e, a, b, c, F2, KK2, 12, 5); R( c, d, e, a, b, F2, KK2, 2, 14); R( b, c, d, e, a, F2, KK2, 10, 13); R( a, b, c, d, e, F2, KK2, 0, 13); R( e, a, b, c, d, F2, KK2, 4, 7); R( d, e, a, b, c, F2, KK2, 13, 5); R( c, d, e, a, b, F1, KK3, 8, 15); R( b, c, d, e, a, F1, KK3, 6, 5); R( a, b, c, d, e, F1, KK3, 4, 8); R( e, a, b, c, d, F1, KK3, 1, 11); R( d, e, a, b, c, F1, KK3, 3, 14); R( c, d, e, a, b, F1, KK3, 11, 14); R( b, c, d, e, a, F1, KK3, 15, 6); R( a, b, c, d, e, F1, KK3, 0, 14); R( e, a, b, c, d, F1, KK3, 5, 6); R( d, e, a, b, c, F1, KK3, 12, 9); R( c, d, e, a, b, F1, KK3, 2, 12); R( b, c, d, e, a, F1, KK3, 13, 9); R( a, b, c, d, e, F1, KK3, 9, 12); R( e, a, b, c, d, F1, KK3, 7, 5); R( d, e, a, b, c, F1, KK3, 10, 15); R( c, d, e, a, b, F1, KK3, 14, 8); R( b, c, d, e, a, F0, KK4, 12, 8); R( a, b, c, d, e, F0, KK4, 15, 5); R( e, a, b, c, d, F0, KK4, 10, 12); R( d, e, a, b, c, F0, KK4, 4, 9); R( c, d, e, a, b, F0, KK4, 1, 12); R( b, c, d, e, a, F0, KK4, 5, 5); R( a, b, c, d, e, F0, KK4, 8, 14); R( e, a, b, c, d, F0, KK4, 7, 6); R( d, e, a, b, c, F0, KK4, 6, 8); R( c, d, e, a, b, F0, KK4, 2, 13); R( b, c, d, e, a, F0, KK4, 13, 6); R( a, b, c, d, e, F0, KK4, 14, 5); R( e, a, b, c, d, F0, KK4, 0, 15); R( d, e, a, b, c, F0, KK4, 3, 13); R( c, d, e, a, b, F0, KK4, 9, 11); R( b, c, d, e, a, F0, KK4, 11, 11); t = hd->h1 + d + cc; hd->h1 = hd->h2 + e + dd; hd->h2 = hd->h3 + a + ee; hd->h3 = hd->h4 + b + aa; hd->h4 = hd->h0 + c + bb; hd->h0 = t; } /* Update the message digest with the content of (INBUF,INLEN). */ static void rmd160_write (rmd160_context_t *hd, const unsigned char *inbuf, size_t inlen) { if( hd->count == 64 ) { /* Flush the buffer. */ transform (hd, hd->buf); hd->count = 0; hd->nblocks++; } if (!inbuf) return; if (hd->count) { for (; inlen && hd->count < 64; inlen--) hd->buf[hd->count++] = *inbuf++; rmd160_write (hd, NULL, 0); if (!inlen) return; } while (inlen >= 64) { transform (hd, inbuf); hd->count = 0; hd->nblocks++; inlen -= 64; inbuf += 64; } for (; inlen && hd->count < 64; inlen--) hd->buf[hd->count++] = *inbuf++; } /* Complete the message computation. */ static void rmd160_final( rmd160_context_t *hd ) { u32 t, msb, lsb; unsigned char *p; rmd160_write (hd, NULL, 0); /* Flush buffer. */ t = hd->nblocks; /* Multiply by 64 to make a byte count. */ lsb = t << 6; msb = t >> 26; /* Add the count. */ t = lsb; if ((lsb += hd->count) < t) msb++; /* Multiply by 8 to make a bit count. */ t = lsb; lsb <<= 3; msb <<= 3; msb |= t >> 29; if (hd->count < 56) { /* Enough room. */ hd->buf[hd->count++] = 0x80; /* Pad character. */ while (hd->count < 56) hd->buf[hd->count++] = 0; } else { /* Need one extra block. */ hd->buf[hd->count++] = 0x80; /* Pad character. */ while (hd->count < 64) hd->buf[hd->count++] = 0; rmd160_write (hd, NULL, 0); /* Flush buffer. */ memset (hd->buf, 0, 56); /* Fill next block with zeroes. */ } /* Append the 64 bit count. */ hd->buf[56] = lsb; hd->buf[57] = lsb >> 8; hd->buf[58] = lsb >> 16; hd->buf[59] = lsb >> 24; hd->buf[60] = msb; hd->buf[61] = msb >> 8; hd->buf[62] = msb >> 16; hd->buf[63] = msb >> 24; transform (hd, hd->buf); p = hd->buf; #define X(a) do { *p++ = hd->h##a; *p++ = hd->h##a >> 8; \ *p++ = hd->h##a >> 16; *p++ = hd->h##a >> 24; } while(0) X(0); X(1); X(2); X(3); X(4); #undef X } /* * Compines function to put the hash value of the supplied BUFFER into * OUTBUF which must have a size of 20 bytes. */ void rmd160_hash_buffer (void *outbuf, const void *buffer, size_t length) { rmd160_context_t hd; rmd160_init (&hd); rmd160_write (&hd, buffer, length); rmd160_final (&hd); memcpy (outbuf, hd.buf, 20); } diff --git a/g13/Makefile.am b/g13/Makefile.am index 84004cb34..362f060de 100644 --- a/g13/Makefile.am +++ b/g13/Makefile.am @@ -1,46 +1,46 @@ # g13/Makefile.am # Copyright (C) 2009 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 3 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, see . ## Process this file with automake to produce Makefile.in bin_PROGRAMS = g13 AM_CPPFLAGS = -I$(top_srcdir)/gl -I$(top_srcdir)/intl -I$(top_srcdir)/common include $(top_srcdir)/am/cmacros.am AM_CFLAGS = $(LIBGCRYPT_CFLAGS) $(LIBASSUAN_CFLAGS) $(PTH_CFLAGS) g13_SOURCES = \ g13.c g13.h \ keyblob.h \ utils.c utils.h \ server.c server.h \ create.c create.h \ mount.c mount.h \ mountinfo.c mountinfo.h \ call-gpg.c call-gpg.h \ runner.c runner.h \ backend.c backend.h \ be-encfs.c be-encfs.h \ be-truecrypt.c be-truecrypt.h -g13_LDADD = $(libcommonpth) ../jnlib/libjnlib.a ../gl/libgnu.a \ +g13_LDADD = $(libcommonpth) ../gl/libgnu.a \ $(LIBGCRYPT_LIBS) $(LIBASSUAN_LIBS) $(PTH_LIBS) \ $(GPG_ERROR_LIBS) $(LIBINTL) diff --git a/jnlib/README b/jnlib/README deleted file mode 100644 index 5536e1ade..000000000 --- a/jnlib/README +++ /dev/null @@ -1,8 +0,0 @@ -JNLIB - This is a collection of utility function which are too small -to put into a library. The code here is licensed under the LGPL. - -libjnlib-config.h should be be modified for each project to make these -functions fit into the software. Mainly these are memory functions in -case you need another allocator. - - diff --git a/kbx/ChangeLog b/kbx/ChangeLog index ea4fef8e7..d88500a0e 100644 --- a/kbx/ChangeLog +++ b/kbx/ChangeLog @@ -1,345 +1,352 @@ +2010-03-10 Werner Koch + + * Makefile.am (kbxutil_LDADD, $(PROGRAMS)): Remove libjnlib.a. + + * keybox-search.c, keybox-init.c, keybox-defs.h, kbxutil.c: + Replace "jnlib" include file part by "common". + 2010-03-08 Werner Koch Use macros for iobuf_ioctl commands. 2009-12-08 Werner Koch * keybox-search-desc.h (keydb_search_desc): Use u32 type for KID. Extend the skip function ptr. (gpg_pkt_user_id_t): New. * keybox-search.c (has_short_kid, has_long_kid): Change to use u32 args for KID. 2008-12-09 Werner Koch * kbxutil.c (main): Call i18n_init before init_common_subsystems. 2008-11-20 Werner Koch * keybox-update.c (create_tmp_file) [USE_ONLY_8DOT3]: Use other suffixes to avoid conflicts with gpg uses filenames. 2008-11-11 Werner Koch * Makefile.am (kbxutil_LDADD): Change order of libs. ($(PROGRAMS)): Ditto for documentation. 2008-10-20 Werner Koch * keybox-update.c (blob_filecopy): Remove unused arg n_packets. (keybox_insert_cert): Adjust for that. (keybox_update_cert): Mark unused args. (keybox_set_flags): Ditto. * keybox-blob.c (create_blob_trailer): Ditto. * keybox-search.c (keybox_get_flags): Ditto. * keybox-dump.c (_keybox_dump_find_dups): Ditto. * kbxutil.c (my_gcry_logger): Ditto. 2008-05-06 Werner Koch * keybox-file.c (_keybox_read_blob2): Return GPG_ERR_TOO_SHORT if we get an EOF for 2nd to 5th byte as a better error message. Always use gpg_error_from_syserror and gpg_err_code_from_syserror. This is to avoid cases where we expect an error but due to an errno set to 0 we get back a success status. 2008-04-01 Werner Koch * keybox-init.c (keybox_new, keybox_release): Track used handles. (_keybox_close_file): New. * keybox-update.c (keybox_insert_cert, keybox_set_flags) (keybox_delete, keybox_compress): Use the new close function. 2008-03-13 Werner Koch * keybox-blob.c (x509_email_kludge): Use the same code as in ..sm/keylist.c so that email parts are not only detected at the start of the DN. Reported by Yoshiaki Kasahara. 2007-08-24 Werner Koch * keybox-init.c (keybox_register_file): Use same_file_p. 2007-08-23 Werner Koch * kbxutil.c: New commands --find-dups and --cut. New options --from an --to. * keybox-dump.c (hash_blob_rawdata): New. (_keybox_dump_find_dups): New. (open_file): Factor some code out to this. (_keybox_dump_cut_records): New. 2007-06-26 Werner Koch * kbxutil.c: Include init.h 2007-06-15 Werner Koch * Makefile.am (kbxutil_LDADD): Add W32SOCKLIBS. 2007-06-12 Werner Koch * kbxutil.c (main): Replace some calls by init_common_subsystems. 2007-06-06 Werner Koch * kbxutil.c (i18n_init): Remove. 2007-03-20 Werner Koch * keybox.h (KEYBOX_FLAG_BLOB_SECRET, KEYBOX_FLAG_BLOB_EPHEMERAL): New. * keybox-update.c (keybox_compress): Use it here instead of a magic constant. 2007-01-31 Werner Koch * Makefile.am (kbxutil_LDADD): Use GPG_ERROR_LIBS instead of -l. Reordered args. 2007-01-25 Werner Koch * Makefile.am (kbxutil_LDADD): Added LIBICONV. Noted by Billy Halsey. 2006-11-15 Werner Koch * kbxutil.c (dump_openpgp_key): Cast printf argument. 2006-10-20 Werner Koch * keybox-search.c (blob_x509_has_grip, has_keygrip): New. (keybox_search): Implement new search mode. * keybox-search-desc.h (KEYDB_SEARCH_MODE_KEYGRIP): New. (keydb_search_desc): New member GRIP. 2006-09-20 Werner Koch * Makefile.am ($(PROGRAMS): New. 2006-09-14 Werner Koch Replaced all call gpg_error_from_errno(errno) by gpg_error_from_syserror(). 2005-10-08 Marcus Brinkmann * Makefile.am (kbxutil_LDADD): Add ../gl/libgnu.a after ../jnlib/libjnlib.a. 2005-06-15 Werner Koch * keybox-file.c (_keybox_read_blob2): Make IMAGE unsigned. (_keybox_write_blob): * keybox-blob.c (create_blob_finish, _keybox_create_x509_blob): Fixed warnings about signed/unsigned pointer mismatches. (x509_email_kludge): Ditto. (_keybox_new_blob): Changed arg IMAGE to unsigned char *. (_keybox_get_blob_image): Changed return type to unsigned char*. 2005-06-01 Werner Koch * keybox-file.c (ftello) [!HAVE_FSEEKO]: New replacement function. Copied from ../common/ftello.c. * keybox-update.c (fseeko) [!HAVE_FSEEKO]: New replacement function. Copied from ../common/iobuf.c. 2004-12-18 Werner Koch * keybox-defs.h (map_assuan_err): Define in terms of map_assuan_err_with_source. 2004-12-07 Werner Koch * keybox-init.c (keybox_release): Close the file pointer. 2004-11-26 Werner Koch * Makefile.am (kbxutil_LDADD): Add ../common/libcommon.a * keybox-defs.h: Include stringhelp.h. 2004-09-30 Werner Koch * kbxutil.c (i18n_init): Always use LC_ALL. * Makefile.am: Adjusted for gettext 0.14. 2004-08-24 Werner Koch * kbxutil.c: New command --import-openpgp. (main): Updated libgcrypt initialization stuff. (my_gcry_logger): New. (read_file): New. Taken from ../agent/protect-tool. (dump_fpr, dump_openpgp_key, import_openpgp): New. * keybox-openpgp.c: New. 2004-06-18 Werner Koch * keybox-dump.c (_keybox_dump_file): New arg STATS_ONLY. (update_stats): New. * kbxutil.c (main): New command --stats. 2004-04-23 Werner Koch * keybox-blob.c (_keybox_update_header_blob): New. * keybox-update.c (blob_filecopy): Handle header blob. * keybox-file.c (_keybox_read_blob2): New. Moved code from _keybox_read_blob to there. * keybox-dump.c (dump_header_blob): Print header info. 2004-04-21 Werner Koch * keybox-search.c (_keybox_get_flag_location): Add flag KEYBOX_FLAG_CREATED_AT. * keybox-update.c (keybox_compress): New. * keybox-search.c (get32, get16, blob_get_type) (blob_get_blob_flags, has_short_kid, has_long_kid) (has_fingerprint, has_issuer, has_issuer_sn, has_sn, has_subject) (has_subject_or_alt, has_mail): inline them. * keybox-update.c (blob_filecopy): Fixed an error/eof check (s/if(fread)/if(nread)/). * keybox-dump.c (_keybox_dump_blob): Really print the timestamps. 2004-04-20 Werner Koch * keybox-defs.h: Include jnlib/types.h and remove our own definitions for byte.u16 and u32. 2004-02-02 Werner Koch * keybox.h (keybox_flag_t): New. * keybox-search.c (get_flag_from_image, keybox_get_flags): New. (_keybox_get_flag_location): New. 2003-11-12 Werner Koch Adjusted for API changes in Libksba. * keybox-blob.c: Include time.h 2003-06-03 Werner Koch Changed all error codes in all files to the new libgpg-error scheme. * keybox-defs.h: Include gpg-error.h . (KeyboxError): Removed. * Makefile.am: Removed keybox-error.c stuff. 2002-11-14 Werner Koch * keybox-search.c (blob_cmp_name) : Fixed length compare; there is no 0 stored since nearly a year. 2002-10-31 Neal H. Walfield * Makefile.am (AM_CPPFLAGS): Fix ytpo. 2002-08-10 Werner Koch * keybox-search.c (blob_cmp_fpr_part): New. (has_short_kid, has_long_kid): Implemented. 2002-07-22 Werner Koch * keybox-defs.h: New BLOBTYPTE_EMPTY. * keybox-dump.c (_keybox_dump_blob): Handle new type. * keybox-file.c (_keybox_read_blob): Skip over empty blobs. Store the file offset. * keybox-blob.c (_keybox_new_blob): Add new arg OFF. (_keybox_get_blob_fileoffset): New. * keybox-update.c (keybox_delete): Implemented. 2002-06-19 Werner Koch * keybox-init.c (keybox_set_ephemeral): New. * keybox-blob.c (create_blob_header): Store ephemeral flag. (_keybox_create_x509_blob): Pass epheermal flag on. * keybox-update.c (keybox_insert_cert): Ditto. * keybox-search.c (blob_get_blob_flags): New. (keybox_search): Ignore ephemeral blobs when not in ephemeral mode. * keybox-dump.c (_keybox_dump_blob): Print blob flags as strings. 2002-02-25 Werner Koch * keybox-search.c (blob_cmp_mail): Use case-insensitive compare because mail addresses are in general case insensitive (well RFC2822 allows for case sensitive mailbox parts, but this is in general considired a Bad Thing). Add additional substr parameter to allow for substring matches within the mail address. Change all callers to pass this along. (blob_cmp_name): Likewise but do the case-insensitive search only in sub string mode. (keybox_search): Implement MAILSUB and SUBSTR mode. 2002-01-21 Werner Koch * keybox-search.c (keybox_search): Allow KEYDB_SEARCH_MODE_FPR20. 2002-01-15 Werner Koch * keybox-search.c (blob_cmp_fpr): New. (has_fingerprint): Implemented; 2001-12-20 Werner Koch * keybox-blob.c (_keybox_create_x509_blob): Skip the leading parenthesis of the serial number's S-exp. (_keybox_create_x509_blob): And fixed length calculation. (create_blob_header): Don't add an offset when writing the serial. 2001-12-18 Werner Koch * Makefile.am (AM_CPPFLAGS): Add flags for libksba * keybox-blob.c (_keybox_create_x509_blob): Use gcry_sexp_canon_len to get the length of the serial number. (_keybox_release_blob): Need to use a new serialbuf to free the memory. 2001-12-17 Werner Koch * keybox-search.c: Changed the way the serial number is represented. 2001-12-15 Werner Koch * keybox-search.c (blob_cmp_name): There is no terminating 0 stored for the uid; fixed length compare. 2001-12-14 Werner Koch * keybox-blob.c (x509_email_kludge): New. (_keybox_create_x509_blob): Insert an extra email address if the subject's DN has an email part. * keybox-defs.h: Added the xtoi_2 and digitp macros. 2001-12-13 Werner Koch * keybox-search.c (blob_cmp_name): Kludge to allow searching for more than one name. (has_subject_or_alt): New. (blob_cmp_mail): New. (has_mail): New. (keybox_search): Implemented exact search and exact mail search. * kbx/keybox-blob.c (_keybox_create_x509_blob): Insert alternate names. Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 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/kbx/Makefile.am b/kbx/Makefile.am index 14e8fa5e2..81a7d3f24 100644 --- a/kbx/Makefile.am +++ b/kbx/Makefile.am @@ -1,53 +1,53 @@ # Keybox Makefile # Copyright (C) 2001, 2002, 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 3 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, see . ## Process this file with automake to produce Makefile.in localedir = $(datadir)/locale INCLUDES = -I../intl -DLOCALEDIR=\"$(localedir)\" EXTRA_DIST = mkerrors AM_CPPFLAGS = -I$(top_srcdir)/gl -I$(top_srcdir)/common -I$(top_srcdir)/intl \ $(LIBGCRYPT_CFLAGS) $(KSBA_CFLAGS) noinst_LIBRARIES = libkeybox.a bin_PROGRAMS = kbxutil common_sources = \ keybox.h keybox-defs.h keybox-search-desc.h \ keybox-util.c \ keybox-init.c \ keybox-blob.c \ keybox-file.c \ keybox-search.c \ keybox-update.c \ keybox-openpgp.c \ keybox-dump.c libkeybox_a_SOURCES = $(common_sources) # We need W32SOCKLIBS because the init subsystem code in libcommon # requires it - although we don't actually need it. It is easier # to do it this way. kbxutil_SOURCES = kbxutil.c $(common_sources) -kbxutil_LDADD = ../common/libcommon.a ../jnlib/libjnlib.a ../gl/libgnu.a \ +kbxutil_LDADD = ../common/libcommon.a ../gl/libgnu.a \ $(KSBA_LIBS) $(LIBGCRYPT_LIBS) \ $(GPG_ERROR_LIBS) $(LIBINTL) $(LIBICONV) $(W32SOCKLIBS) -$(PROGRAMS) : ../common/libcommon.a ../jnlib/libjnlib.a ../gl/libgnu.a +$(PROGRAMS) : ../common/libcommon.a ../gl/libgnu.a diff --git a/kbx/kbxutil.c b/kbx/kbxutil.c index 459281110..592f7d467 100644 --- a/kbx/kbxutil.c +++ b/kbx/kbxutil.c @@ -1,594 +1,594 @@ /* kbxutil.c - The Keybox utility * Copyright (C) 2000, 2001, 2004, 2007 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 3 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, see . */ #include #include #include #include #include #include #include #include #include #include #define JNLIB_NEED_LOG_LOGV -#include "../jnlib/logging.h" -#include "../jnlib/argparse.h" -#include "../jnlib/stringhelp.h" -#include "../jnlib/utf8conv.h" +#include "../common/logging.h" +#include "../common/argparse.h" +#include "../common/stringhelp.h" +#include "../common/utf8conv.h" #include "i18n.h" #include "init.h" #include "keybox-defs.h" #include enum cmd_and_opt_values { aNull = 0, oArmor = 'a', oDryRun = 'n', oOutput = 'o', oQuiet = 'q', oVerbose = 'v', aNoSuchCmd = 500, /* force other values not to be a letter */ aFindByFpr, aFindByKid, aFindByUid, aStats, aImportOpenPGP, aFindDups, aCut, oDebug, oDebugAll, oNoArmor, oFrom, oTo, aTest }; static ARGPARSE_OPTS opts[] = { { 300, NULL, 0, N_("@Commands:\n ") }, /* { aFindByFpr, "find-by-fpr", 0, "|FPR| find key using it's fingerprnt" }, */ /* { aFindByKid, "find-by-kid", 0, "|KID| find key using it's keyid" }, */ /* { aFindByUid, "find-by-uid", 0, "|NAME| find key by user name" }, */ { aStats, "stats", 0, "show key statistics" }, { aImportOpenPGP, "import-openpgp", 0, "import OpenPGP keyblocks"}, { aFindDups, "find-dups", 0, "find duplicates" }, { aCut, "cut", 0, "export records" }, { 301, NULL, 0, N_("@\nOptions:\n ") }, { oFrom, "from", 4, "|N|first record to export" }, { oTo, "to", 4, "|N|last record to export" }, /* { oArmor, "armor", 0, N_("create ascii armored output")}, */ /* { oArmor, "armour", 0, "@" }, */ /* { oOutput, "output", 2, N_("use as output file")}, */ { oVerbose, "verbose", 0, N_("verbose") }, { oQuiet, "quiet", 0, N_("be somewhat more quiet") }, { oDryRun, "dry-run", 0, N_("do not make any changes") }, { oDebug, "debug" ,4|16, N_("set debugging flags")}, { oDebugAll, "debug-all" ,0, N_("enable full debugging")}, {0} /* end of list */ }; void myexit (int rc); int keybox_errors_seen = 0; static const char * my_strusage( int level ) { const char *p; switch( level ) { case 11: p = "kbxutil (GnuPG)"; break; case 13: p = VERSION; break; case 17: p = PRINTABLE_OS_NAME; break; case 19: p = _("Please report bugs to <@EMAIL@>.\n"); break; case 1: case 40: p = _("Usage: kbxutil [options] [files] (-h for help)"); break; case 41: p = _("Syntax: kbxutil [options] [files]\n" "list, export, import Keybox data\n"); break; default: p = NULL; } return p; } /* Used by gcry for logging */ static void my_gcry_logger (void *dummy, int level, const char *fmt, va_list arg_ptr) { (void)dummy; /* Map the log levels. */ switch (level) { case GCRY_LOG_CONT: level = JNLIB_LOG_CONT; break; case GCRY_LOG_INFO: level = JNLIB_LOG_INFO; break; case GCRY_LOG_WARN: level = JNLIB_LOG_WARN; break; case GCRY_LOG_ERROR:level = JNLIB_LOG_ERROR; break; case GCRY_LOG_FATAL:level = JNLIB_LOG_FATAL; break; case GCRY_LOG_BUG: level = JNLIB_LOG_BUG; break; case GCRY_LOG_DEBUG:level = JNLIB_LOG_DEBUG; break; default: level = JNLIB_LOG_ERROR; break; } log_logv (level, fmt, arg_ptr); } /* static void */ /* wrong_args( const char *text ) */ /* { */ /* log_error("usage: kbxutil %s\n", text); */ /* myexit ( 1 ); */ /* } */ #if 0 static int hextobyte( const byte *s ) { int c; if( *s >= '0' && *s <= '9' ) c = 16 * (*s - '0'); else if( *s >= 'A' && *s <= 'F' ) c = 16 * (10 + *s - 'A'); else if( *s >= 'a' && *s <= 'f' ) c = 16 * (10 + *s - 'a'); else return -1; s++; if( *s >= '0' && *s <= '9' ) c += *s - '0'; else if( *s >= 'A' && *s <= 'F' ) c += 10 + *s - 'A'; else if( *s >= 'a' && *s <= 'f' ) c += 10 + *s - 'a'; else return -1; return c; } #endif #if 0 static char * format_fingerprint ( const char *s ) { int i, c; byte fpr[20]; for (i=0; i < 20 && *s; ) { if ( *s == ' ' || *s == '\t' ) { s++; continue; } c = hextobyte(s); if (c == -1) { return NULL; } fpr[i++] = c; s += 2; } return gcry_xstrdup ( fpr ); } #endif #if 0 static int format_keyid ( const char *s, u32 *kid ) { char helpbuf[9]; switch ( strlen ( s ) ) { case 8: kid[0] = 0; kid[1] = strtoul( s, NULL, 16 ); return 10; case 16: mem2str( helpbuf, s, 9 ); kid[0] = strtoul( helpbuf, NULL, 16 ); kid[1] = strtoul( s+8, NULL, 16 ); return 11; } return 0; /* error */ } #endif static char * read_file (const char *fname, size_t *r_length) { FILE *fp; char *buf; size_t buflen; if (!strcmp (fname, "-")) { size_t nread, bufsize = 0; fp = stdin; buf = NULL; buflen = 0; #define NCHUNK 8192 do { bufsize += NCHUNK; if (!buf) buf = xtrymalloc (bufsize); else buf = xtryrealloc (buf, bufsize); if (!buf) log_fatal ("can't allocate buffer: %s\n", strerror (errno)); nread = fread (buf+buflen, 1, NCHUNK, fp); if (nread < NCHUNK && ferror (fp)) { log_error ("error reading `[stdin]': %s\n", strerror (errno)); xfree (buf); return NULL; } buflen += nread; } while (nread == NCHUNK); #undef NCHUNK } else { struct stat st; fp = fopen (fname, "rb"); if (!fp) { log_error ("can't open `%s': %s\n", fname, strerror (errno)); return NULL; } if (fstat (fileno(fp), &st)) { log_error ("can't stat `%s': %s\n", fname, strerror (errno)); fclose (fp); return NULL; } buflen = st.st_size; buf = xtrymalloc (buflen+1); if (!buf) log_fatal ("can't allocate buffer: %s\n", strerror (errno)); if (fread (buf, buflen, 1, fp) != 1) { log_error ("error reading `%s': %s\n", fname, strerror (errno)); fclose (fp); xfree (buf); return NULL; } fclose (fp); } *r_length = buflen; return buf; } static void dump_fpr (const unsigned char *buffer, size_t len) { int i; for (i=0; i < len; i++, buffer++) { if (len == 20) { if (i == 10) putchar (' '); printf (" %02X%02X", buffer[0], buffer[1]); i++; buffer++; } else { if (i && !(i % 8)) putchar (' '); printf (" %02X", buffer[0]); } } } static void dump_openpgp_key (keybox_openpgp_info_t info, const unsigned char *image) { printf ("pub %02X%02X%02X%02X", info->primary.keyid[4], info->primary.keyid[5], info->primary.keyid[6], info->primary.keyid[7] ); dump_fpr (info->primary.fpr, info->primary.fprlen); putchar ('\n'); if (info->nsubkeys) { struct _keybox_openpgp_key_info *k; k = &info->subkeys; do { printf ("sub %02X%02X%02X%02X", k->keyid[4], k->keyid[5], k->keyid[6], k->keyid[7] ); dump_fpr (k->fpr, k->fprlen); putchar ('\n'); k = k->next; } while (k); } if (info->nuids) { struct _keybox_openpgp_uid_info *u; u = &info->uids; do { printf ("uid\t\t%.*s\n", (int)u->len, image + u->off); u = u->next; } while (u); } } static void import_openpgp (const char *filename) { gpg_error_t err; char *buffer; size_t buflen, nparsed; unsigned char *p; struct _keybox_openpgp_info info; buffer = read_file (filename, &buflen); if (!buffer) return; p = (unsigned char *)buffer; for (;;) { err = _keybox_parse_openpgp (p, buflen, &nparsed, &info); assert (nparsed <= buflen); if (err) { if (gpg_err_code (err) == GPG_ERR_NO_DATA) break; log_info ("%s: failed to parse OpenPGP keyblock: %s\n", filename, gpg_strerror (err)); } else { dump_openpgp_key (&info, p); _keybox_destroy_openpgp_info (&info); } p += nparsed; buflen -= nparsed; } xfree (buffer); } int main( int argc, char **argv ) { ARGPARSE_ARGS pargs; enum cmd_and_opt_values cmd = 0; unsigned long from = 0, to = ULONG_MAX; set_strusage( my_strusage ); gcry_control (GCRYCTL_DISABLE_SECMEM); log_set_prefix ("kbxutil", 1); /* Make sure that our subsystems are ready. */ i18n_init (); init_common_subsystems (); /* Check that the libraries are suitable. Do it here because the option parsing may need services of the library. */ if (!gcry_check_version (NEED_LIBGCRYPT_VERSION) ) { log_fatal (_("%s is too old (need %s, have %s)\n"), "libgcrypt", NEED_LIBGCRYPT_VERSION, gcry_check_version (NULL) ); } gcry_set_log_handler (my_gcry_logger, NULL); /*create_dotlock(NULL); register locking cleanup */ - /* We need to use the gcry malloc function because jnlib does use them */ + /* We need to use the gcry malloc function because jnlib uses them. */ keybox_set_malloc_hooks (gcry_malloc, gcry_realloc, gcry_free); ksba_set_malloc_hooks (gcry_malloc, gcry_realloc, gcry_free ); pargs.argc = &argc; pargs.argv = &argv; pargs.flags= 1; /* do not remove the args */ while (arg_parse( &pargs, opts) ) { switch (pargs.r_opt) { case oVerbose: /*opt.verbose++;*/ /*gcry_control( GCRYCTL_SET_VERBOSITY, (int)opt.verbose );*/ break; case oDebug: /*opt.debug |= pargs.r.ret_ulong; */ break; case oDebugAll: /*opt.debug = ~0;*/ break; case aFindByFpr: case aFindByKid: case aFindByUid: case aStats: case aImportOpenPGP: case aFindDups: case aCut: cmd = pargs.r_opt; break; case oFrom: from = pargs.r.ret_ulong; break; case oTo: to = pargs.r.ret_ulong; break; default: pargs.err = 2; break; } } if (to < from) log_error ("record number of \"--to\" is lower than \"--from\" one\n"); if (log_get_errorcount(0) ) myexit(2); if (!cmd) { /* Default is to list a KBX file */ if (!argc) _keybox_dump_file (NULL, 0, stdout); else { for (; argc; argc--, argv++) _keybox_dump_file (*argv, 0, stdout); } } else if (cmd == aStats ) { if (!argc) _keybox_dump_file (NULL, 1, stdout); else { for (; argc; argc--, argv++) _keybox_dump_file (*argv, 1, stdout); } } else if (cmd == aFindDups ) { if (!argc) _keybox_dump_find_dups (NULL, 0, stdout); else { for (; argc; argc--, argv++) _keybox_dump_find_dups (*argv, 0, stdout); } } else if (cmd == aCut ) { if (!argc) _keybox_dump_cut_records (NULL, from, to, stdout); else { for (; argc; argc--, argv++) _keybox_dump_cut_records (*argv, from, to, stdout); } } else if (cmd == aImportOpenPGP) { if (!argc) import_openpgp ("-"); else { for (; argc; argc--, argv++) import_openpgp (*argv); } } #if 0 else if ( cmd == aFindByFpr ) { char *fpr; if ( argc != 2 ) wrong_args ("kbxfile foingerprint"); fpr = format_fingerprint ( argv[1] ); if ( !fpr ) log_error ("invalid formatted fingerprint\n"); else { kbxfile_search_by_fpr ( argv[0], fpr ); gcry_free ( fpr ); } } else if ( cmd == aFindByKid ) { u32 kid[2]; int mode; if ( argc != 2 ) wrong_args ("kbxfile short-or-long-keyid"); mode = format_keyid ( argv[1], kid ); if ( !mode ) log_error ("invalid formatted keyID\n"); else { kbxfile_search_by_kid ( argv[0], kid, mode ); } } else if ( cmd == aFindByUid ) { if ( argc != 2 ) wrong_args ("kbxfile userID"); kbxfile_search_by_uid ( argv[0], argv[1] ); } #endif else log_error ("unsupported action\n"); myexit(0); return 8; /*NEVER REACHED*/ } void myexit( int rc ) { /* if( opt.debug & DBG_MEMSTAT_VALUE ) {*/ /* gcry_control( GCRYCTL_DUMP_MEMORY_STATS ); */ /* gcry_control( GCRYCTL_DUMP_RANDOM_STATS ); */ /* }*/ /* if( opt.debug ) */ /* gcry_control( GCRYCTL_DUMP_SECMEM_STATS ); */ rc = rc? rc : log_get_errorcount(0)? 2 : keybox_errors_seen? 1 : 0; exit(rc ); } diff --git a/kbx/keybox-defs.h b/kbx/keybox-defs.h index 626f3e5c3..98d23b326 100644 --- a/kbx/keybox-defs.h +++ b/kbx/keybox-defs.h @@ -1,261 +1,261 @@ /* keybox-defs.h - interal Keybox defintions * Copyright (C) 2001, 2004 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 3 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, see . */ #ifndef KEYBOX_DEFS_H #define KEYBOX_DEFS_H 1 #ifdef GPG_ERR_SOURCE_DEFAULT #error GPG_ERR_SOURCE_DEFAULT already defined #endif #define GPG_ERR_SOURCE_DEFAULT GPG_ERR_SOURCE_KEYBOX #include #define map_assuan_err(a) \ map_assuan_err_with_source (GPG_ERR_SOURCE_DEFAULT, (a)) #include /* off_t */ /* We include the type defintions from jnlib instead of defining our owns here. This will not allow us build KBX in a standalone way but there is currently no need for it anyway. Same goes for stringhelp.h which for example provides a replacement for stpcpy - - fixme: Better the LIBOBJ mechnism. */ -#include "../jnlib/types.h" -#include "../jnlib/stringhelp.h" + fixme: Better use the LIBOBJ mechnism. */ +#include "../common/types.h" +#include "../common/stringhelp.h" #include "keybox.h" enum { BLOBTYPE_EMPTY = 0, BLOBTYPE_HEADER = 1, BLOBTYPE_PGP = 2, BLOBTYPE_X509 = 3 }; typedef struct keyboxblob *KEYBOXBLOB; typedef struct keybox_name *KB_NAME; typedef struct keybox_name const *CONST_KB_NAME; struct keybox_name { /* Link to the next resources, so that we can walk all resources. */ KB_NAME next; /* True if this is a keybox with secret keys. */ int secret; /*DOTLOCK lockhd;*/ /* A table with all the handles accessing this resources. HANDLE_TABLE_SIZE gives the allocated length of this table unused entrues are set to NULL. HANDLE_TABLE may be NULL. */ KEYBOX_HANDLE *handle_table; size_t handle_table_size; /* Not yet used. */ int is_locked; /* Not yet used. */ int did_full_scan; /* The name of the resource file. */ char fname[1]; }; struct keybox_handle { CONST_KB_NAME kb; int secret; /* this is for a secret keybox */ FILE *fp; int eof; int error; int ephemeral; struct { KEYBOXBLOB blob; off_t offset; size_t pk_no; size_t uid_no; unsigned int n_packets; /*used for delete and update*/ } found; struct { char *name; char *pattern; } word_match; }; /* Openpgp helper structures. */ struct _keybox_openpgp_key_info { struct _keybox_openpgp_key_info *next; unsigned char keyid[8]; int fprlen; /* Either 16 or 20 */ unsigned char fpr[20]; }; struct _keybox_openpgp_uid_info { struct _keybox_openpgp_uid_info *next; size_t off; size_t len; }; struct _keybox_openpgp_info { int is_secret; /* True if this is a secret key. */ unsigned int nsubkeys;/* Total number of subkeys. */ unsigned int nuids; /* Total number of user IDs in the keyblock. */ unsigned int nsigs; /* Total number of signatures in the keyblock. */ /* Note, we use 2 structs here to better cope with the most common use of having one primary and one subkey - this allows us to statically allocate this structure and only malloc stuff for more than one subkey. */ struct _keybox_openpgp_key_info primary; struct _keybox_openpgp_key_info subkeys; struct _keybox_openpgp_uid_info uids; }; typedef struct _keybox_openpgp_info *keybox_openpgp_info_t; /* Don't know whether this is needed: */ /* static struct { */ /* const char *homedir; */ /* int dry_run; */ /* int quiet; */ /* int verbose; */ /* int preserve_permissions; */ /* } keybox_opt; */ /*-- keybox-init.c --*/ void _keybox_close_file (KEYBOX_HANDLE hd); /*-- keybox-blob.c --*/ #ifdef KEYBOX_WITH_OPENPGP /* fixme */ #endif /*KEYBOX_WITH_OPENPGP*/ #ifdef KEYBOX_WITH_X509 int _keybox_create_x509_blob (KEYBOXBLOB *r_blob, ksba_cert_t cert, unsigned char *sha1_digest, int as_ephemeral); #endif /*KEYBOX_WITH_X509*/ int _keybox_new_blob (KEYBOXBLOB *r_blob, unsigned char *image, size_t imagelen, off_t off); void _keybox_release_blob (KEYBOXBLOB blob); const unsigned char *_keybox_get_blob_image (KEYBOXBLOB blob, size_t *n); off_t _keybox_get_blob_fileoffset (KEYBOXBLOB blob); void _keybox_update_header_blob (KEYBOXBLOB blob); /*-- keybox-openpgp.c --*/ gpg_error_t _keybox_parse_openpgp (const unsigned char *image, size_t imagelen, size_t *nparsed, keybox_openpgp_info_t info); void _keybox_destroy_openpgp_info (keybox_openpgp_info_t info); /*-- keybox-file.c --*/ int _keybox_read_blob (KEYBOXBLOB *r_blob, FILE *fp); int _keybox_read_blob2 (KEYBOXBLOB *r_blob, FILE *fp, int *skipped_deleted); int _keybox_write_blob (KEYBOXBLOB blob, FILE *fp); int _keybox_write_header_blob (FILE *fp); /*-- keybox-search.c --*/ gpg_err_code_t _keybox_get_flag_location (const unsigned char *buffer, size_t length, int what, size_t *flag_off, size_t *flag_size); /*-- keybox-dump.c --*/ int _keybox_dump_blob (KEYBOXBLOB blob, FILE *fp); int _keybox_dump_file (const char *filename, int stats_only, FILE *outfp); int _keybox_dump_find_dups (const char *filename, int print_them, FILE *outfp); int _keybox_dump_cut_records (const char *filename, unsigned long from, unsigned long to, FILE *outfp); /*-- keybox-util.c --*/ void *_keybox_malloc (size_t n); void *_keybox_calloc (size_t n, size_t m); void *_keybox_realloc (void *p, size_t n); void _keybox_free (void *p); #define xtrymalloc(a) _keybox_malloc ((a)) #define xtrycalloc(a,b) _keybox_calloc ((a),(b)) #define xtryrealloc(a,b) _keybox_realloc((a),(b)) #define xfree(a) _keybox_free ((a)) #define DIM(v) (sizeof(v)/sizeof((v)[0])) #define DIMof(type,member) DIM(((type *)0)->member) #ifndef STR # define STR(v) #v #endif #define STR2(v) STR(v) /* a couple of handy macros */ #define return_if_fail(expr) do { \ if (!(expr)) { \ fprintf (stderr, "%s:%d: assertion `%s' failed\n", \ __FILE__, __LINE__, #expr ); \ return; \ } } while (0) #define return_null_if_fail(expr) do { \ if (!(expr)) { \ fprintf (stderr, "%s:%d: assertion `%s' failed\n", \ __FILE__, __LINE__, #expr ); \ return NULL; \ } } while (0) #define return_val_if_fail(expr,val) do { \ if (!(expr)) { \ fprintf (stderr, "%s:%d: assertion `%s' failed\n", \ __FILE__, __LINE__, #expr ); \ return (val); \ } } while (0) #define never_reached() do { \ fprintf (stderr, "%s:%d: oops; should never get here\n", \ __FILE__, __LINE__ ); \ } while (0) /* some macros to replace ctype ones and avoid locale problems */ #define digitp(p) (*(p) >= '0' && *(p) <= '9') #define hexdigitp(a) (digitp (a) \ || (*(a) >= 'A' && *(a) <= 'F') \ || (*(a) >= 'a' && *(a) <= 'f')) /* the atoi macros assume that the buffer has only valid digits */ #define atoi_1(p) (*(p) - '0' ) #define atoi_2(p) ((atoi_1(p) * 10) + atoi_1((p)+1)) #define atoi_4(p) ((atoi_2(p) * 100) + atoi_2((p)+2)) #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)) #endif /*KEYBOX_DEFS_H*/ diff --git a/kbx/keybox-dump.c b/kbx/keybox-dump.c index b671089a0..4be8501a1 100644 --- a/kbx/keybox-dump.c +++ b/kbx/keybox-dump.c @@ -1,699 +1,699 @@ /* keybox-dump.c - Debug helpers * Copyright (C) 2001, 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 3 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, see . */ #include #include #include #include #include #include "keybox-defs.h" #include /* Argg, we can't include ../common/util.h */ char *bin2hexcolon (const void *buffer, size_t length, char *stringbuf); static ulong get32 (const byte *buffer) { ulong a; a = *buffer << 24; a |= buffer[1] << 16; a |= buffer[2] << 8; a |= buffer[3]; return a; } static ulong get16 (const byte *buffer) { ulong a; a = *buffer << 8; a |= buffer[1]; return a; } void print_string (FILE *fp, const byte *p, size_t n, int delim) { for ( ; n; n--, p++ ) { if (*p < 0x20 || (*p >= 0x7f && *p < 0xa0) || *p == delim) { putc('\\', fp); if( *p == '\n' ) putc('n', fp); else if( *p == '\r' ) putc('r', fp); else if( *p == '\f' ) putc('f', fp); else if( *p == '\v' ) putc('v', fp); else if( *p == '\b' ) putc('b', fp); else if( !*p ) putc('0', fp); else fprintf(fp, "x%02x", *p ); } else putc(*p, fp); } } static int dump_header_blob (const byte *buffer, size_t length, FILE *fp) { unsigned long n; if (length < 32) { fprintf (fp, "[blob too short]\n"); return -1; } fprintf (fp, "Version: %d\n", buffer[5]); if ( memcmp (buffer+8, "KBXf", 4)) fprintf (fp, "[Error: invalid magic number]\n"); n = get32 (buffer+16); fprintf( fp, "created-at: %lu\n", n ); n = get32 (buffer+20); fprintf( fp, "last-maint: %lu\n", n ); return 0; } /* Dump one block to FP */ int _keybox_dump_blob (KEYBOXBLOB blob, FILE *fp) { const byte *buffer; size_t length; int type; ulong n, nkeys, keyinfolen; ulong nuids, uidinfolen; ulong nsigs, siginfolen; ulong rawdata_off, rawdata_len; ulong nserial; const byte *p; buffer = _keybox_get_blob_image (blob, &length); if (length < 32) { fprintf (fp, "[blob too short]\n"); return -1; } n = get32( buffer ); if (n > length) fprintf (fp, "[blob larger than length - output truncated]\n"); else length = n; /* ignore the rest */ fprintf (fp, "Length: %lu\n", n ); type = buffer[4]; switch (type) { case BLOBTYPE_EMPTY: fprintf (fp, "Type: Empty\n"); return 0; case BLOBTYPE_HEADER: fprintf (fp, "Type: Header\n"); return dump_header_blob (buffer, length, fp); case BLOBTYPE_PGP: fprintf (fp, "Type: OpenPGP\n"); break; case BLOBTYPE_X509: fprintf (fp, "Type: X.509\n"); break; default: fprintf (fp, "Type: %d\n", type); fprintf (fp, "[can't dump this blob type]\n"); return 0; } fprintf (fp, "Version: %d\n", buffer[5]); if (length < 40) { fprintf (fp, "[blob too short]\n"); return -1; } n = get16 (buffer + 6); fprintf( fp, "Blob-Flags: %04lX", n); if (n) { int any = 0; fputs (" (", fp); if ((n & 1)) { fputs ("secret", fp); any++; } if ((n & 2)) { if (any) putc (',', fp); fputs ("ephemeral", fp); any++; } putc (')', fp); } putc ('\n', fp); rawdata_off = get32 (buffer + 8); rawdata_len = get32 (buffer + 12); fprintf( fp, "Data-Offset: %lu\n", rawdata_off ); fprintf( fp, "Data-Length: %lu\n", rawdata_len ); if (rawdata_off > length || rawdata_len > length || rawdata_off+rawdata_off > length) fprintf (fp, "[Error: raw data larger than blob]\n"); nkeys = get16 (buffer + 16); fprintf (fp, "Key-Count: %lu\n", nkeys ); if (!nkeys) fprintf (fp, "[Error: no keys]\n"); if (nkeys > 1 && type == BLOBTYPE_X509) fprintf (fp, "[Error: only one key allowed for X509]\n"); keyinfolen = get16 (buffer + 18 ); fprintf (fp, "Key-Info-Length: %lu\n", keyinfolen); /* fixme: check bounds */ p = buffer + 20; for (n=0; n < nkeys; n++, p += keyinfolen) { int i; ulong kidoff, kflags; fprintf (fp, "Key-Fpr[%lu]: ", n ); for (i=0; i < 20; i++ ) fprintf (fp, "%02X", p[i]); kidoff = get32 (p + 20); fprintf (fp, "\nKey-Kid-Off[%lu]: %lu\n", n, kidoff ); fprintf (fp, "Key-Kid[%lu]: ", n ); /* fixme: check bounds */ for (i=0; i < 8; i++ ) fprintf (fp, "%02X", buffer[kidoff+i] ); kflags = get16 (p + 24 ); fprintf( fp, "\nKey-Flags[%lu]: %04lX\n", n, kflags); } /* serial number */ fputs ("Serial-No: ", fp); nserial = get16 (p); p += 2; if (!nserial) fputs ("none", fp); else { for (; nserial; nserial--, p++) fprintf (fp, "%02X", *p); } putc ('\n', fp); /* user IDs */ nuids = get16 (p); fprintf (fp, "Uid-Count: %lu\n", nuids ); uidinfolen = get16 (p + 2); fprintf (fp, "Uid-Info-Length: %lu\n", uidinfolen); /* fixme: check bounds */ p += 4; for (n=0; n < nuids; n++, p += uidinfolen) { ulong uidoff, uidlen, uflags; uidoff = get32( p ); uidlen = get32( p+4 ); if (type == BLOBTYPE_X509 && !n) { fprintf (fp, "Issuer-Off: %lu\n", uidoff ); fprintf (fp, "Issuer-Len: %lu\n", uidlen ); fprintf (fp, "Issuer: \""); } else if (type == BLOBTYPE_X509 && n == 1) { fprintf (fp, "Subject-Off: %lu\n", uidoff ); fprintf (fp, "Subject-Len: %lu\n", uidlen ); fprintf (fp, "Subject: \""); } else { fprintf (fp, "Uid-Off[%lu]: %lu\n", n, uidoff ); fprintf (fp, "Uid-Len[%lu]: %lu\n", n, uidlen ); fprintf (fp, "Uid[%lu]: \"", n ); } print_string (fp, buffer+uidoff, uidlen, '\"'); fputs ("\"\n", fp); uflags = get16 (p + 8); if (type == BLOBTYPE_X509 && !n) { fprintf (fp, "Issuer-Flags: %04lX\n", uflags ); fprintf (fp, "Issuer-Validity: %d\n", p[10] ); } else if (type == BLOBTYPE_X509 && n == 1) { fprintf (fp, "Subject-Flags: %04lX\n", uflags ); fprintf (fp, "Subject-Validity: %d\n", p[10] ); } else { fprintf (fp, "Uid-Flags[%lu]: %04lX\n", n, uflags ); fprintf (fp, "Uid-Validity[%lu]: %d\n", n, p[10] ); } } nsigs = get16 (p); fprintf (fp, "Sig-Count: %lu\n", nsigs ); siginfolen = get16 (p + 2); fprintf (fp, "Sig-Info-Length: %lu\n", siginfolen ); /* fixme: check bounds */ p += 4; for (n=0; n < nsigs; n++, p += siginfolen) { ulong sflags; sflags = get32 (p); fprintf (fp, "Sig-Expire[%lu]: ", n ); if (!sflags) fputs ("[not checked]", fp); else if (sflags == 1 ) fputs ("[missing key]", fp); else if (sflags == 2 ) fputs ("[bad signature]", fp); else if (sflags < 0x10000000) fprintf (fp, "[bad flag %0lx]", sflags); else if (sflags == 0xffffffff) fputs ("0", fp ); else fputs ("a time"/*strtimestamp( sflags )*/, fp ); putc ('\n', fp ); } fprintf (fp, "Ownertrust: %d\n", p[0] ); fprintf (fp, "All-Validity: %d\n", p[1] ); p += 4; n = get32 (p); p += 4; fprintf (fp, "Recheck-After: %lu\n", n ); n = get32 (p ); p += 4; fprintf( fp, "Latest-Timestamp: %lu\n", n ); n = get32 (p ); p += 4; fprintf (fp, "Created-At: %lu\n", n ); n = get32 (p ); p += 4; fprintf (fp, "Reserved-Space: %lu\n", n ); /* check that the keyblock is at the correct offset and other bounds */ /*fprintf (fp, "Blob-Checksum: [MD5-hash]\n");*/ return 0; } /* Compute the SHA_1 checksum of teh rawdata in BLOB and aput it into DIGEST. */ static int hash_blob_rawdata (KEYBOXBLOB blob, unsigned char *digest) { const unsigned char *buffer; size_t n, length; int type; ulong rawdata_off, rawdata_len; buffer = _keybox_get_blob_image (blob, &length); if (length < 32) return -1; n = get32 (buffer); if (n < length) length = n; /* Blob larger than length in header - ignore the rest. */ type = buffer[4]; switch (type) { case BLOBTYPE_PGP: case BLOBTYPE_X509: break; case BLOBTYPE_EMPTY: case BLOBTYPE_HEADER: default: memset (digest, 0, 20); return 0; } if (length < 40) return -1; rawdata_off = get32 (buffer + 8); rawdata_len = get32 (buffer + 12); if (rawdata_off > length || rawdata_len > length || rawdata_off+rawdata_off > length) return -1; /* Out of bounds. */ gcry_md_hash_buffer (GCRY_MD_SHA1, digest, buffer+rawdata_off, rawdata_len); return 0; } struct file_stats_s { unsigned long too_short_blobs; unsigned long too_large_blobs; unsigned long total_blob_count; unsigned long empty_blob_count; unsigned long header_blob_count; unsigned long pgp_blob_count; unsigned long x509_blob_count; unsigned long unknown_blob_count; unsigned long non_flagged; unsigned long secret_flagged; unsigned long ephemeral_flagged; }; static int update_stats (KEYBOXBLOB blob, struct file_stats_s *s) { const unsigned char *buffer; size_t length; int type; unsigned long n; buffer = _keybox_get_blob_image (blob, &length); if (length < 32) { s->too_short_blobs++; return -1; } n = get32( buffer ); if (n > length) s->too_large_blobs++; else length = n; /* ignore the rest */ s->total_blob_count++; type = buffer[4]; switch (type) { case BLOBTYPE_EMPTY: s->empty_blob_count++; return 0; case BLOBTYPE_HEADER: s->header_blob_count++; return 0; case BLOBTYPE_PGP: s->pgp_blob_count++; break; case BLOBTYPE_X509: s->x509_blob_count++; break; default: s->unknown_blob_count++; return 0; } if (length < 40) { s->too_short_blobs++; return -1; } n = get16 (buffer + 6); if (n) { if ((n & 1)) s->secret_flagged++; if ((n & 2)) s->ephemeral_flagged++; } else s->non_flagged++; return 0; } static FILE * open_file (const char **filename, FILE *outfp) { FILE *fp; if (!*filename) { *filename = "-"; fp = stdin; } else fp = fopen (*filename, "rb"); if (!fp) { int save_errno = errno; fprintf (outfp, "can't open `%s': %s\n", *filename, strerror(errno)); - errno = save_errno; + gpg_err_set_errno (save_errno); } return fp; } int _keybox_dump_file (const char *filename, int stats_only, FILE *outfp) { FILE *fp; KEYBOXBLOB blob; int rc; unsigned long count = 0; struct file_stats_s stats; memset (&stats, 0, sizeof stats); if (!(fp = open_file (&filename, outfp))) return gpg_error_from_syserror (); while ( !(rc = _keybox_read_blob (&blob, fp)) ) { if (stats_only) { update_stats (blob, &stats); } else { fprintf (outfp, "BEGIN-RECORD: %lu\n", count ); _keybox_dump_blob (blob, outfp); fprintf (outfp, "END-RECORD\n"); } _keybox_release_blob (blob); count++; } if (rc == -1) rc = 0; if (rc) fprintf (outfp, "error reading `%s': %s\n", filename, gpg_strerror (rc)); if (fp != stdin) fclose (fp); if (stats_only) { fprintf (outfp, "Total number of blobs: %8lu\n" " header: %8lu\n" " empty: %8lu\n" " openpgp: %8lu\n" " x509: %8lu\n" " non flagged: %8lu\n" " secret flagged: %8lu\n" " ephemeral flagged: %8lu\n", stats.total_blob_count, stats.header_blob_count, stats.empty_blob_count, stats.pgp_blob_count, stats.x509_blob_count, stats.non_flagged, stats.secret_flagged, stats.ephemeral_flagged); if (stats.unknown_blob_count) fprintf (outfp, " unknown blob types: %8lu\n", stats.unknown_blob_count); if (stats.too_short_blobs) fprintf (outfp, " too short blobs: %8lu\n", stats.too_short_blobs); if (stats.too_large_blobs) fprintf (outfp, " too large blobs: %8lu\n", stats.too_large_blobs); } return rc; } struct dupitem_s { unsigned long recno; unsigned char digest[20]; }; static int cmp_dupitems (const void *arg_a, const void *arg_b) { struct dupitem_s *a = (struct dupitem_s *)arg_a; struct dupitem_s *b = (struct dupitem_s *)arg_b; return memcmp (a->digest, b->digest, 20); } int _keybox_dump_find_dups (const char *filename, int print_them, FILE *outfp) { FILE *fp; KEYBOXBLOB blob; int rc; unsigned long recno = 0; unsigned char zerodigest[20]; struct dupitem_s *dupitems; size_t dupitems_size, dupitems_count, lastn, n; char fprbuf[3*20+1]; (void)print_them; memset (zerodigest, 0, sizeof zerodigest); if (!(fp = open_file (&filename, outfp))) return gpg_error_from_syserror (); dupitems_size = 1000; dupitems = malloc (dupitems_size * sizeof *dupitems); if (!dupitems) { gpg_error_t tmperr = gpg_error_from_syserror (); fprintf (outfp, "error allocating array for `%s': %s\n", filename, strerror(errno)); return tmperr; } dupitems_count = 0; while ( !(rc = _keybox_read_blob (&blob, fp)) ) { unsigned char digest[20]; if (hash_blob_rawdata (blob, digest)) fprintf (outfp, "error in blob %ld of `%s'\n", recno, filename); else if (memcmp (digest, zerodigest, 20)) { if (dupitems_count >= dupitems_size) { struct dupitem_s *tmp; dupitems_size += 1000; tmp = realloc (dupitems, dupitems_size * sizeof *dupitems); if (!tmp) { gpg_error_t tmperr = gpg_error_from_syserror (); fprintf (outfp, "error reallocating array for `%s': %s\n", filename, strerror(errno)); free (dupitems); return tmperr; } dupitems = tmp; } dupitems[dupitems_count].recno = recno; memcpy (dupitems[dupitems_count].digest, digest, 20); dupitems_count++; } _keybox_release_blob (blob); recno++; } if (rc == -1) rc = 0; if (rc) fprintf (outfp, "error reading `%s': %s\n", filename, gpg_strerror (rc)); if (fp != stdin) fclose (fp); qsort (dupitems, dupitems_count, sizeof *dupitems, cmp_dupitems); for (lastn=0, n=1; n < dupitems_count; lastn=n, n++) { if (!memcmp (dupitems[lastn].digest, dupitems[n].digest, 20)) { bin2hexcolon (dupitems[lastn].digest, 20, fprbuf); fprintf (outfp, "fpr=%s recno=%lu", fprbuf, dupitems[lastn].recno); do fprintf (outfp, " %lu", dupitems[n].recno); while (++n < dupitems_count && !memcmp (dupitems[lastn].digest, dupitems[n].digest, 20)); putc ('\n', outfp); n--; } } free (dupitems); return rc; } /* Print records with record numbers FROM to TO to OUTFP. */ int _keybox_dump_cut_records (const char *filename, unsigned long from, unsigned long to, FILE *outfp) { FILE *fp; KEYBOXBLOB blob; int rc; unsigned long recno = 0; if (!(fp = open_file (&filename, stderr))) return gpg_error_from_syserror (); while ( !(rc = _keybox_read_blob (&blob, fp)) ) { if (recno > to) break; /* Ready. */ if (recno >= from) { if ((rc = _keybox_write_blob (blob, outfp))) { fprintf (stderr, "error writing output: %s\n", gpg_strerror (rc)); goto leave; } } _keybox_release_blob (blob); recno++; } if (rc == -1) rc = 0; if (rc) fprintf (stderr, "error reading `%s': %s\n", filename, gpg_strerror (rc)); leave: if (fp != stdin) fclose (fp); return rc; } diff --git a/kbx/keybox-init.c b/kbx/keybox-init.c index e4138647e..c364277e3 100644 --- a/kbx/keybox-init.c +++ b/kbx/keybox-init.c @@ -1,202 +1,202 @@ /* keybox-init.c - Initalization of the library * Copyright (C) 2001 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 3 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, see . */ #include #include #include #include #include #include -#include "../jnlib/mischelp.h" +#include "../common/mischelp.h" #include "keybox-defs.h" static KB_NAME kb_names; /* Register a filename for plain keybox files. Returns a pointer to be used to create a handles and so on. Returns NULL to indicate that FNAME has already been registered. */ void * keybox_register_file (const char *fname, int secret) { KB_NAME kr; for (kr=kb_names; kr; kr = kr->next) { if (same_file_p (kr->fname, fname) ) return NULL; /* Already registered. */ } kr = xtrymalloc (sizeof *kr + strlen (fname)); if (!kr) return NULL; strcpy (kr->fname, fname); kr->secret = !!secret; kr->handle_table = NULL; kr->handle_table_size = 0; /* kr->lockhd = NULL;*/ kr->is_locked = 0; kr->did_full_scan = 0; /* keep a list of all issued pointers */ kr->next = kb_names; kb_names = kr; /* create the offset table the first time a function here is used */ /* if (!kb_offtbl) */ /* kb_offtbl = new_offset_hash_table (); */ return kr; } int keybox_is_writable (void *token) { KB_NAME r = token; return r? !access (r->fname, W_OK) : 0; } /* Create a new handle for the resource associated with TOKEN. SECRET is just a cross-check. The returned handle must be released using keybox_release (). */ KEYBOX_HANDLE keybox_new (void *token, int secret) { KEYBOX_HANDLE hd; KB_NAME resource = token; int idx; assert (resource && !resource->secret == !secret); hd = xtrycalloc (1, sizeof *hd); if (hd) { hd->kb = resource; hd->secret = !!secret; if (!resource->handle_table) { resource->handle_table_size = 3; resource->handle_table = xtrycalloc (resource->handle_table_size, sizeof *resource->handle_table); if (!resource->handle_table) { resource->handle_table_size = 0; xfree (hd); return NULL; } } for (idx=0; idx < resource->handle_table_size; idx++) if (!resource->handle_table[idx]) { resource->handle_table[idx] = hd; break; } if (!(idx < resource->handle_table_size)) { KEYBOX_HANDLE *tmptbl; size_t newsize; newsize = resource->handle_table_size + 5; tmptbl = xtryrealloc (resource->handle_table, newsize * sizeof (*tmptbl)); if (!tmptbl) { xfree (hd); return NULL; } resource->handle_table = tmptbl; resource->handle_table_size = newsize; resource->handle_table[idx] = hd; for (idx++; idx < resource->handle_table_size; idx++) resource->handle_table[idx] = NULL; } } return hd; } void keybox_release (KEYBOX_HANDLE hd) { if (!hd) return; if (hd->kb->handle_table) { int idx; for (idx=0; idx < hd->kb->handle_table_size; idx++) if (hd->kb->handle_table[idx] == hd) hd->kb->handle_table[idx] = NULL; } _keybox_release_blob (hd->found.blob); if (hd->fp) { fclose (hd->fp); hd->fp = NULL; } xfree (hd->word_match.name); xfree (hd->word_match.pattern); xfree (hd); } const char * keybox_get_resource_name (KEYBOX_HANDLE hd) { if (!hd || !hd->kb) return NULL; return hd->kb->fname; } int keybox_set_ephemeral (KEYBOX_HANDLE hd, int yes) { if (!hd) return gpg_error (GPG_ERR_INV_HANDLE); hd->ephemeral = yes; return 0; } /* Close the file of the resource identified by HD. For consistent results this fucntion closes the files of all handles pointing to the resource identified by HD. */ void _keybox_close_file (KEYBOX_HANDLE hd) { int idx; KEYBOX_HANDLE roverhd; if (!hd || !hd->kb || !hd->kb->handle_table) return; for (idx=0; idx < hd->kb->handle_table_size; idx++) if ((roverhd = hd->kb->handle_table[idx])) { if (roverhd->fp) { fclose (roverhd->fp); roverhd->fp = NULL; } } assert (!hd->fp); } diff --git a/kbx/keybox-search.c b/kbx/keybox-search.c index be4ca4579..96c873dbe 100644 --- a/kbx/keybox-search.c +++ b/kbx/keybox-search.c @@ -1,1045 +1,1045 @@ /* keybox-search.c - Search operations * Copyright (C) 2001, 2002, 2003, 2004 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 3 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, see . */ #include #include #include #include #include #include -#include "../jnlib/stringhelp.h" /* ascii_xxxx() */ +#include "../common/stringhelp.h" /* ascii_xxxx() */ #include "keybox-defs.h" #include #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 sn_array_s { int snlen; unsigned char *sn; }; static inline ulong get32 (const byte *buffer) { ulong a; a = *buffer << 24; a |= buffer[1] << 16; a |= buffer[2] << 8; a |= buffer[3]; return a; } static inline ulong get16 (const byte *buffer) { ulong a; a = *buffer << 8; a |= buffer[1]; return a; } static inline int blob_get_type (KEYBOXBLOB blob) { const unsigned char *buffer; size_t length; buffer = _keybox_get_blob_image (blob, &length); if (length < 32) return -1; /* blob too short */ return buffer[4]; } static inline unsigned int blob_get_blob_flags (KEYBOXBLOB blob) { const unsigned char *buffer; size_t length; buffer = _keybox_get_blob_image (blob, &length); if (length < 8) return 0; /* oops */ return get16 (buffer + 6); } /* Return information on the flag WHAT within the blob BUFFER,LENGTH. Return the offset and the length (in bytes) of the flag in FLAGOFF,FLAG_SIZE. */ gpg_err_code_t _keybox_get_flag_location (const unsigned char *buffer, size_t length, int what, size_t *flag_off, size_t *flag_size) { size_t pos; size_t nkeys, keyinfolen; size_t nuids, uidinfolen; size_t nserial; size_t nsigs, siginfolen; switch (what) { case KEYBOX_FLAG_BLOB: if (length < 8) return GPG_ERR_INV_OBJ; *flag_off = 6; *flag_size = 2; break; case KEYBOX_FLAG_OWNERTRUST: case KEYBOX_FLAG_VALIDITY: case KEYBOX_FLAG_CREATED_AT: if (length < 20) return GPG_ERR_INV_OBJ; /* Key info. */ nkeys = get16 (buffer + 16); keyinfolen = get16 (buffer + 18 ); if (keyinfolen < 28) return GPG_ERR_INV_OBJ; pos = 20 + keyinfolen*nkeys; if (pos+2 > length) return GPG_ERR_INV_OBJ; /* Out of bounds. */ /* Serial number. */ nserial = get16 (buffer+pos); pos += 2 + nserial; if (pos+4 > length) return GPG_ERR_INV_OBJ; /* Out of bounds. */ /* User IDs. */ nuids = get16 (buffer + pos); pos += 2; uidinfolen = get16 (buffer + pos); pos += 2; if (uidinfolen < 12 ) return GPG_ERR_INV_OBJ; pos += uidinfolen*nuids; if (pos+4 > length) return GPG_ERR_INV_OBJ ; /* Out of bounds. */ /* Signature info. */ nsigs = get16 (buffer + pos); pos += 2; siginfolen = get16 (buffer + pos); pos += 2; if (siginfolen < 4 ) return GPG_ERR_INV_OBJ; pos += siginfolen*nsigs; if (pos+1+1+2+4+4+4+4 > length) return GPG_ERR_INV_OBJ ; /* Out of bounds. */ *flag_size = 1; *flag_off = pos; switch (what) { case KEYBOX_FLAG_VALIDITY: *flag_off += 1; break; case KEYBOX_FLAG_CREATED_AT: *flag_size = 4; *flag_off += 1+2+4+4+4; break; default: break; } break; default: return GPG_ERR_INV_FLAG; } return 0; } /* Return one of the flags WHAT in VALUE from teh blob BUFFER of LENGTH bytes. Return 0 on success or an raw error code. */ static gpg_err_code_t get_flag_from_image (const unsigned char *buffer, size_t length, int what, unsigned int *value) { gpg_err_code_t ec; size_t pos, size; *value = 0; ec = _keybox_get_flag_location (buffer, length, what, &pos, &size); if (!ec) switch (size) { case 1: *value = buffer[pos]; break; case 2: *value = get16 (buffer + pos); break; case 4: *value = get32 (buffer + pos); break; default: ec = GPG_ERR_BUG; break; } return ec; } static int blob_cmp_sn (KEYBOXBLOB blob, const unsigned char *sn, int snlen) { const unsigned char *buffer; size_t length; size_t pos, off; size_t nkeys, keyinfolen; size_t nserial; buffer = _keybox_get_blob_image (blob, &length); if (length < 40) return 0; /* blob too short */ /*keys*/ nkeys = get16 (buffer + 16); keyinfolen = get16 (buffer + 18 ); if (keyinfolen < 28) return 0; /* invalid blob */ pos = 20 + keyinfolen*nkeys; if (pos+2 > length) return 0; /* out of bounds */ /*serial*/ nserial = get16 (buffer+pos); off = pos + 2; if (off+nserial > length) return 0; /* out of bounds */ return nserial == snlen && !memcmp (buffer+off, sn, snlen); } static int blob_cmp_fpr (KEYBOXBLOB blob, const unsigned char *fpr) { const unsigned char *buffer; size_t length; size_t pos, off; size_t nkeys, keyinfolen; int idx; buffer = _keybox_get_blob_image (blob, &length); if (length < 40) return 0; /* blob too short */ /*keys*/ nkeys = get16 (buffer + 16); keyinfolen = get16 (buffer + 18 ); if (keyinfolen < 28) return 0; /* invalid blob */ pos = 20; if (pos + keyinfolen*nkeys > length) return 0; /* out of bounds */ for (idx=0; idx < nkeys; idx++) { off = pos + idx*keyinfolen; if (!memcmp (buffer + off, fpr, 20)) return 1; /* found */ } return 0; /* not found */ } static int blob_cmp_fpr_part (KEYBOXBLOB blob, const unsigned char *fpr, int fproff, int fprlen) { const unsigned char *buffer; size_t length; size_t pos, off; size_t nkeys, keyinfolen; int idx; buffer = _keybox_get_blob_image (blob, &length); if (length < 40) return 0; /* blob too short */ /*keys*/ nkeys = get16 (buffer + 16); keyinfolen = get16 (buffer + 18 ); if (keyinfolen < 28) return 0; /* invalid blob */ pos = 20; if (pos + keyinfolen*nkeys > length) return 0; /* out of bounds */ for (idx=0; idx < nkeys; idx++) { off = pos + idx*keyinfolen; if (!memcmp (buffer + off + fproff, fpr, fprlen)) return 1; /* found */ } return 0; /* not found */ } static int blob_cmp_name (KEYBOXBLOB blob, int idx, const char *name, size_t namelen, int substr) { const unsigned char *buffer; size_t length; size_t pos, off, len; size_t nkeys, keyinfolen; size_t nuids, uidinfolen; size_t nserial; buffer = _keybox_get_blob_image (blob, &length); if (length < 40) return 0; /* blob too short */ /*keys*/ nkeys = get16 (buffer + 16); keyinfolen = get16 (buffer + 18 ); if (keyinfolen < 28) return 0; /* invalid blob */ pos = 20 + keyinfolen*nkeys; if (pos+2 > length) return 0; /* out of bounds */ /*serial*/ nserial = get16 (buffer+pos); pos += 2 + nserial; if (pos+4 > length) return 0; /* out of bounds */ /* user ids*/ nuids = get16 (buffer + pos); pos += 2; uidinfolen = get16 (buffer + pos); pos += 2; if (uidinfolen < 12 /* should add a: || nuidinfolen > MAX_UIDINFOLEN */) return 0; /* invalid blob */ if (pos + uidinfolen*nuids > length) return 0; /* out of bounds */ if (idx < 0) { /* compare all names starting with that (negated) index */ idx = -idx; for ( ;idx < nuids; idx++) { size_t mypos = pos; mypos += idx*uidinfolen; off = get32 (buffer+mypos); len = get32 (buffer+mypos+4); if (off+len > length) return 0; /* error: better stop here out of bounds */ if (len < 1) continue; /* empty name */ if (substr) { if (ascii_memcasemem (buffer+off, len, name, namelen)) return 1; /* found */ } else { if (len == namelen && !memcmp (buffer+off, name, len)) return 1; /* found */ } } return 0; /* not found */ } else { if (idx > nuids) return 0; /* no user ID with that idx */ pos += idx*uidinfolen; off = get32 (buffer+pos); len = get32 (buffer+pos+4); if (off+len > length) return 0; /* out of bounds */ if (len < 1) return 0; /* empty name */ if (substr) { return !!ascii_memcasemem (buffer+off, len, name, namelen); } else { return len == namelen && !memcmp (buffer+off, name, len); } } } /* compare all email addresses of the subject. With SUBSTR given as True a substring search is done in the mail address */ static int blob_cmp_mail (KEYBOXBLOB blob, const char *name, size_t namelen, int substr) { const unsigned char *buffer; size_t length; size_t pos, off, len; size_t nkeys, keyinfolen; size_t nuids, uidinfolen; size_t nserial; int idx; /* fixme: this code is common to blob_cmp_mail */ buffer = _keybox_get_blob_image (blob, &length); if (length < 40) return 0; /* blob too short */ /*keys*/ nkeys = get16 (buffer + 16); keyinfolen = get16 (buffer + 18 ); if (keyinfolen < 28) return 0; /* invalid blob */ pos = 20 + keyinfolen*nkeys; if (pos+2 > length) return 0; /* out of bounds */ /*serial*/ nserial = get16 (buffer+pos); pos += 2 + nserial; if (pos+4 > length) return 0; /* out of bounds */ /* user ids*/ nuids = get16 (buffer + pos); pos += 2; uidinfolen = get16 (buffer + pos); pos += 2; if (uidinfolen < 12 /* should add a: || nuidinfolen > MAX_UIDINFOLEN */) return 0; /* invalid blob */ if (pos + uidinfolen*nuids > length) return 0; /* out of bounds */ if (namelen < 1) return 0; for (idx=1 ;idx < nuids; idx++) { size_t mypos = pos; mypos += idx*uidinfolen; off = get32 (buffer+mypos); len = get32 (buffer+mypos+4); if (off+len > length) return 0; /* error: better stop here out of bounds */ if (len < 2 || buffer[off] != '<') continue; /* empty name or trailing 0 not stored */ len--; /* one back */ if ( len < 3 || buffer[off+len] != '>') continue; /* not a proper email address */ len--; if (substr) { if (ascii_memcasemem (buffer+off+1, len, name, namelen)) return 1; /* found */ } else { if (len == namelen && !ascii_memcasecmp (buffer+off+1, name, len)) return 1; /* found */ } } return 0; /* not found */ } #ifdef KEYBOX_WITH_X509 /* Return true if the key in BLOB matches the 20 bytes keygrip GRIP. We don't have the keygrips as meta data, thus we need to parse the certificate. Fixme: We might want to return proper error codes instead of failing a search for invalid certificates etc. */ static int blob_x509_has_grip (KEYBOXBLOB blob, const unsigned char *grip) { int rc; const unsigned char *buffer; size_t length; size_t cert_off, cert_len; ksba_reader_t reader = NULL; ksba_cert_t cert = NULL; ksba_sexp_t p = NULL; gcry_sexp_t s_pkey; unsigned char array[20]; unsigned char *rcp; size_t n; buffer = _keybox_get_blob_image (blob, &length); if (length < 40) return 0; /* Too short. */ cert_off = get32 (buffer+8); cert_len = get32 (buffer+12); if (cert_off+cert_len > length) return 0; /* Too short. */ rc = ksba_reader_new (&reader); if (rc) return 0; /* Problem with ksba. */ rc = ksba_reader_set_mem (reader, buffer+cert_off, cert_len); if (rc) goto failed; rc = ksba_cert_new (&cert); if (rc) goto failed; rc = ksba_cert_read_der (cert, reader); if (rc) goto failed; p = ksba_cert_get_public_key (cert); if (!p) goto failed; n = gcry_sexp_canon_len (p, 0, NULL, NULL); if (!n) goto failed; rc = gcry_sexp_sscan (&s_pkey, NULL, (char*)p, n); if (rc) { gcry_sexp_release (s_pkey); goto failed; } rcp = gcry_pk_get_keygrip (s_pkey, array); gcry_sexp_release (s_pkey); if (!rcp) goto failed; /* Can't calculate keygrip. */ xfree (p); ksba_cert_release (cert); ksba_reader_release (reader); return !memcmp (array, grip, 20); failed: xfree (p); ksba_cert_release (cert); ksba_reader_release (reader); return 0; } #endif /*KEYBOX_WITH_X509*/ /* The has_foo functions are used as helpers for search */ static inline int has_short_kid (KEYBOXBLOB blob, u32 lkid) { unsigned char buf[4]; buf[0] = lkid >> 24; buf[1] = lkid >> 16; buf[2] = lkid >> 8; buf[3] = lkid; return blob_cmp_fpr_part (blob, buf, 16, 4); } static inline int has_long_kid (KEYBOXBLOB blob, u32 mkid, u32 lkid) { unsigned char buf[8]; buf[0] = mkid >> 24; buf[1] = mkid >> 16; buf[2] = mkid >> 8; buf[3] = mkid; buf[4] = lkid >> 24; buf[5] = lkid >> 16; buf[6] = lkid >> 8; buf[7] = lkid; return blob_cmp_fpr_part (blob, buf, 12, 8); } static inline int has_fingerprint (KEYBOXBLOB blob, const unsigned char *fpr) { return blob_cmp_fpr (blob, fpr); } static inline int has_keygrip (KEYBOXBLOB blob, const unsigned char *grip) { #ifdef KEYBOX_WITH_X509 if (blob_get_type (blob) == BLOBTYPE_X509) return blob_x509_has_grip (blob, grip); #endif return 0; } static inline int has_issuer (KEYBOXBLOB blob, const char *name) { size_t namelen; return_val_if_fail (name, 0); if (blob_get_type (blob) != BLOBTYPE_X509) return 0; namelen = strlen (name); return blob_cmp_name (blob, 0 /* issuer */, name, namelen, 0); } static inline int has_issuer_sn (KEYBOXBLOB blob, const char *name, const unsigned char *sn, int snlen) { size_t namelen; return_val_if_fail (name, 0); return_val_if_fail (sn, 0); if (blob_get_type (blob) != BLOBTYPE_X509) return 0; namelen = strlen (name); return (blob_cmp_sn (blob, sn, snlen) && blob_cmp_name (blob, 0 /* issuer */, name, namelen, 0)); } static inline int has_sn (KEYBOXBLOB blob, const unsigned char *sn, int snlen) { return_val_if_fail (sn, 0); if (blob_get_type (blob) != BLOBTYPE_X509) return 0; return blob_cmp_sn (blob, sn, snlen); } static inline int has_subject (KEYBOXBLOB blob, const char *name) { size_t namelen; return_val_if_fail (name, 0); if (blob_get_type (blob) != BLOBTYPE_X509) return 0; namelen = strlen (name); return blob_cmp_name (blob, 1 /* subject */, name, namelen, 0); } static inline int has_subject_or_alt (KEYBOXBLOB blob, const char *name, int substr) { size_t namelen; return_val_if_fail (name, 0); if (blob_get_type (blob) != BLOBTYPE_X509) return 0; namelen = strlen (name); return blob_cmp_name (blob, -1 /* all subject names*/, name, namelen, substr); } static inline int has_mail (KEYBOXBLOB blob, const char *name, int substr) { size_t namelen; return_val_if_fail (name, 0); if (blob_get_type (blob) != BLOBTYPE_X509) return 0; namelen = strlen (name); if (namelen && name[namelen-1] == '>') namelen--; return blob_cmp_mail (blob, name, namelen, substr); } static void release_sn_array (struct sn_array_s *array, size_t size) { size_t n; for (n=0; n < size; n++) xfree (array[n].sn); xfree (array); } /* The search API */ int keybox_search_reset (KEYBOX_HANDLE hd) { if (!hd) return gpg_error (GPG_ERR_INV_VALUE); if (hd->found.blob) { _keybox_release_blob (hd->found.blob); hd->found.blob = NULL; } if (hd->fp) { fclose (hd->fp); hd->fp = NULL; } hd->error = 0; hd->eof = 0; return 0; } /* Note: When in ephemeral mode the search function does visit all blobs but in standard mode, blobs flagged as ephemeral are ignored. */ int keybox_search (KEYBOX_HANDLE hd, KEYBOX_SEARCH_DESC *desc, size_t ndesc) { int rc; size_t n; int need_words, any_skip; KEYBOXBLOB blob = NULL; struct sn_array_s *sn_array = NULL; if (!hd) return gpg_error (GPG_ERR_INV_VALUE); /* clear last found result */ if (hd->found.blob) { _keybox_release_blob (hd->found.blob); hd->found.blob = NULL; } if (hd->error) return hd->error; /* still in error state */ if (hd->eof) return -1; /* still EOF */ /* figure out what information we need */ need_words = any_skip = 0; for (n=0; n < ndesc; n++) { switch (desc[n].mode) { case KEYDB_SEARCH_MODE_WORDS: need_words = 1; break; case KEYDB_SEARCH_MODE_FIRST: /* always restart the search in this mode */ keybox_search_reset (hd); break; default: break; } if (desc[n].skipfnc) any_skip = 1; if (desc[n].snlen == -1 && !sn_array) { sn_array = xtrycalloc (ndesc, sizeof *sn_array); if (!sn_array) return (hd->error = gpg_error_from_syserror ()); } } (void)need_words; /* Not yet implemented. */ if (!hd->fp) { hd->fp = fopen (hd->kb->fname, "rb"); if (!hd->fp) { hd->error = gpg_error_from_syserror (); xfree (sn_array); return hd->error; } } /* Kludge: We need to convert an SN given as hexstring to its binary representation - in some cases we are not able to store it in the search descriptor, because due to the way we use it, it is not possible to free allocated memory. */ if (sn_array) { const unsigned char *s; int i, odd; size_t snlen; for (n=0; n < ndesc; n++) { if (!desc[n].sn) ; else if (desc[n].snlen == -1) { unsigned char *sn; s = desc[n].sn; for (i=0; *s && *s != '/'; s++, i++) ; odd = (i & 1); snlen = (i+1)/2; sn_array[n].sn = xtrymalloc (snlen); if (!sn_array[n].sn) { hd->error = gpg_error_from_syserror (); release_sn_array (sn_array, n); return hd->error; } sn_array[n].snlen = snlen; sn = sn_array[n].sn; s = desc[n].sn; if (odd) { *sn++ = xtoi_1 (s); s++; } for (; *s && *s != '/'; s += 2) *sn++ = xtoi_2 (s); } else { const unsigned char *sn; sn = desc[n].sn; snlen = desc[n].snlen; sn_array[n].sn = xtrymalloc (snlen); if (!sn_array[n].sn) { hd->error = gpg_error_from_syserror (); release_sn_array (sn_array, n); return hd->error; } sn_array[n].snlen = snlen; memcpy (sn_array[n].sn, sn, snlen); } } } for (;;) { unsigned int blobflags; _keybox_release_blob (blob); blob = NULL; rc = _keybox_read_blob (&blob, hd->fp); if (rc) break; if (blob_get_type (blob) == BLOBTYPE_HEADER) continue; blobflags = blob_get_blob_flags (blob); if (!hd->ephemeral && (blobflags & 2)) continue; /* Not in ephemeral mode but blob is flagged ephemeral. */ for (n=0; n < ndesc; n++) { switch (desc[n].mode) { case KEYDB_SEARCH_MODE_NONE: never_reached (); break; case KEYDB_SEARCH_MODE_EXACT: if (has_subject_or_alt (blob, desc[n].u.name, 0)) goto found; break; case KEYDB_SEARCH_MODE_MAIL: if (has_mail (blob, desc[n].u.name, 0)) goto found; break; case KEYDB_SEARCH_MODE_MAILSUB: if (has_mail (blob, desc[n].u.name, 1)) goto found; break; case KEYDB_SEARCH_MODE_SUBSTR: if (has_subject_or_alt (blob, desc[n].u.name, 1)) goto found; break; case KEYDB_SEARCH_MODE_MAILEND: case KEYDB_SEARCH_MODE_WORDS: never_reached (); /* not yet implemented */ break; case KEYDB_SEARCH_MODE_ISSUER: if (has_issuer (blob, desc[n].u.name)) goto found; break; case KEYDB_SEARCH_MODE_ISSUER_SN: if (has_issuer_sn (blob, desc[n].u.name, sn_array? sn_array[n].sn : desc[n].sn, sn_array? sn_array[n].snlen : desc[n].snlen)) goto found; break; case KEYDB_SEARCH_MODE_SN: if (has_sn (blob, sn_array? sn_array[n].sn : desc[n].sn, sn_array? sn_array[n].snlen : desc[n].snlen)) goto found; break; case KEYDB_SEARCH_MODE_SUBJECT: if (has_subject (blob, desc[n].u.name)) goto found; break; case KEYDB_SEARCH_MODE_SHORT_KID: if (has_short_kid (blob, desc[n].u.kid[1])) goto found; break; case KEYDB_SEARCH_MODE_LONG_KID: if (has_long_kid (blob, desc[n].u.kid[0], desc[n].u.kid[1])) goto found; break; case KEYDB_SEARCH_MODE_FPR: case KEYDB_SEARCH_MODE_FPR20: if (has_fingerprint (blob, desc[n].u.fpr)) goto found; break; case KEYDB_SEARCH_MODE_KEYGRIP: if (has_keygrip (blob, desc[n].u.grip)) goto found; break; case KEYDB_SEARCH_MODE_FIRST: goto found; break; case KEYDB_SEARCH_MODE_NEXT: goto found; break; default: rc = gpg_error (GPG_ERR_INV_VALUE); goto found; } } continue; found: for (n=any_skip?0:ndesc; n < ndesc; n++) { /* if (desc[n].skipfnc */ /* && desc[n].skipfnc (desc[n].skipfncvalue, aki, NULL)) */ /* break; */ } if (n == ndesc) break; /* got it */ } if (!rc) { hd->found.blob = blob; } else if (rc == -1) { _keybox_release_blob (blob); hd->eof = 1; } else { _keybox_release_blob (blob); hd->error = rc; } if (sn_array) release_sn_array (sn_array, ndesc); return rc; } /* Functions to return a certificate or a keyblock. To be used after a successful search operation. */ #ifdef KEYBOX_WITH_X509 /* Return the last found cert. Caller must free it. */ int keybox_get_cert (KEYBOX_HANDLE hd, ksba_cert_t *r_cert) { const unsigned char *buffer; size_t length; size_t cert_off, cert_len; ksba_reader_t reader = NULL; ksba_cert_t cert = NULL; int rc; if (!hd) return gpg_error (GPG_ERR_INV_VALUE); if (!hd->found.blob) return gpg_error (GPG_ERR_NOTHING_FOUND); if (blob_get_type (hd->found.blob) != BLOBTYPE_X509) return gpg_error (GPG_ERR_WRONG_BLOB_TYPE); buffer = _keybox_get_blob_image (hd->found.blob, &length); if (length < 40) return gpg_error (GPG_ERR_TOO_SHORT); cert_off = get32 (buffer+8); cert_len = get32 (buffer+12); if (cert_off+cert_len > length) return gpg_error (GPG_ERR_TOO_SHORT); rc = ksba_reader_new (&reader); if (rc) return rc; rc = ksba_reader_set_mem (reader, buffer+cert_off, cert_len); if (rc) { ksba_reader_release (reader); /* fixme: need to map the error codes */ return gpg_error (GPG_ERR_GENERAL); } rc = ksba_cert_new (&cert); if (rc) { ksba_reader_release (reader); return rc; } rc = ksba_cert_read_der (cert, reader); if (rc) { ksba_cert_release (cert); ksba_reader_release (reader); /* fixme: need to map the error codes */ return gpg_error (GPG_ERR_GENERAL); } *r_cert = cert; ksba_reader_release (reader); return 0; } #endif /*KEYBOX_WITH_X509*/ /* Return the flags named WHAT at the address of VALUE. IDX is used only for certain flags and should be 0 if not required. */ int keybox_get_flags (KEYBOX_HANDLE hd, int what, int idx, unsigned int *value) { const unsigned char *buffer; size_t length; gpg_err_code_t ec; (void)idx; /* Not yet used. */ if (!hd) return gpg_error (GPG_ERR_INV_VALUE); if (!hd->found.blob) return gpg_error (GPG_ERR_NOTHING_FOUND); buffer = _keybox_get_blob_image (hd->found.blob, &length); ec = get_flag_from_image (buffer, length, what, value); return ec? gpg_error (ec):0; } diff --git a/keyserver/Makefile.am b/keyserver/Makefile.am index 96cd8d1c2..fd046cfc0 100644 --- a/keyserver/Makefile.am +++ b/keyserver/Makefile.am @@ -1,84 +1,84 @@ # Makefile.am - Makefile for keyservers # Copyright (C) 2001, 2002, 2004, 2005, 2006, # 2009 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 3 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, see . ## Process this file with automake to produce Makefile.in # Note that we have renamed the resulting binaries to from gpgkeys_foo # to gpg2keys_foo to allow for a non-conflicting installation of # gnupg1 and gnupg2. Having the same names for the helpers would # otherwise lead to trouble when to uninstall one of them. EXTRA_PROGRAMS = gpg2keys_ldap gpg2keys_hkp gpg2keys_finger gpg2keys_curl \ gpg2keys_kdns EXTRA_SCRIPTS = gpg2keys_mailto AM_CPPFLAGS = -I$(top_srcdir)/gl -I$(top_srcdir)/common -I$(top_srcdir)/intl AM_CFLAGS = $(LIBGCRYPT_CFLAGS) $(GPG_ERROR_CFLAGS) include $(top_srcdir)/am/cmacros.am libexec_PROGRAMS = $(GPGKEYS_LDAP) $(GPGKEYS_HKP) $(GPGKEYS_FINGER) \ $(GPGKEYS_CURL) $(GPGKEYS_KDNS) libexec_SCRIPTS = $(GPGKEYS_MAILTO) noinst_SCRIPTS = gpg2keys_test -common_libs = ../gl/libgnu.a ../common/libcommon.a ../jnlib/libjnlib.a +common_libs = ../gl/libgnu.a ../common/libcommon.a other_libs = $(LIBICONV) $(LIBINTL) $(CAPLIBS) gpg2keys_ldap_SOURCES = gpgkeys_ldap.c ksutil.c ksutil.h no-libgcrypt.c gpg2keys_ldap_CPPFLAGS = $(LDAP_CPPFLAGS) $(AM_CPPFLAGS) -gpg2keys_ldap_LDADD = ../jnlib/libjnlib.a $(LDAPLIBS) $(GPG_ERROR_LIBS) \ +gpg2keys_ldap_LDADD = $(common_libs) $(LDAPLIBS) $(GPG_ERROR_LIBS) \ $(NETLIBS) $(other_libs) gpg2keys_finger_SOURCES = gpgkeys_finger.c ksutil.c ksutil.h no-libgcrypt.c gpg2keys_finger_CPPFLAGS = $(AM_CPPFLAGS) gpg2keys_finger_LDADD = $(common_libs) $(GPG_ERROR_LIBS) \ $(NETLIBS) $(other_libs) gpg2keys_kdns_SOURCES = gpgkeys_kdns.c ksutil.c ksutil.h no-libgcrypt.c gpg2keys_kdns_CPPFLAGS = $(AM_CPPFLAGS) gpg2keys_kdns_LDADD = $(common_libs) $(GPG_ERROR_LIBS) \ $(ADNSLIBS) $(NETLIBS) $(other_libs) gpg2keys_curl_SOURCES = gpgkeys_curl.c ksutil.c ksutil.h no-libgcrypt.c gpg2keys_hkp_SOURCES = gpgkeys_hkp.c ksutil.c ksutil.h no-libgcrypt.c if FAKE_CURL gpg2keys_curl_SOURCES += curl-shim.c curl-shim.h gpg2keys_curl_CPPFLAGS = $(AM_CPPFLAGS) gpg2keys_curl_LDADD = $(common_libs) $(GPG_ERROR_LIBS) $(NETLIBS) $(DNSLIBS) \ $(other_libs) gpg2keys_hkp_SOURCES += curl-shim.c curl-shim.h gpg2keys_hkp_CPPFLAGS = $(AM_CPPFLAGS) gpg2keys_hkp_LDADD = $(common_libs) $(GPG_ERROR_LIBS) $(NETLIBS) $(DNSLIBS) \ $(other_libs) else # Note that we need to include all other libs here as well because # some compilers don't care about inline functions and insert # references to symbols used in unused inline functions. gpg2keys_curl_CPPFLAGS = $(LIBCURL_CPPFLAGS) $(AM_CPPFLAGS) gpg2keys_curl_LDADD = $(common_libs) $(GPG_ERROR_LIBS) $(NETLIBS) $(DNSLIBS) \ $(other_libs) $(LIBCURL) $(GETOPT) gpg2keys_hkp_CPPFLAGS = $(LIBCURL_CPPFLAGS) $(AM_CPPFLAGS) gpg2keys_hkp_LDADD = $(common_libs) $(GPG_ERROR_LIBS) $(NETLIBS) $(DNSLIBS) \ $(other_libs) $(LIBCURL) $(GETOPT) endif # Make sure that all libs are build before we use them. This is # important for things like make -j2. $(PROGRAMS): $(common_libs) diff --git a/po/POTFILES.in b/po/POTFILES.in index f31d10993..cac69a4a6 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -1,108 +1,109 @@ # List of files with translatable strings agent/call-pinentry.c agent/command-ssh.c agent/divert-scd.c agent/genkey.c agent/gpg-agent.c agent/preset-passphrase.c agent/protect-tool.c agent/trustlist.c agent/findkey.c common/exechelp.c common/http.c common/simple-pwquery.c common/sysutils.c common/yesno.c common/miscellaneous.c common/asshelp.c common/audit.c common/helpfile.c common/gettime.c +common/argparse.c +common/logging.c +common/utf8conv.c +common/dotlock.c + + g10/armor.c g10/build-packet.c g10/call-agent.c g10/card-util.c g10/dearmor.c g10/decrypt.c g10/delkey.c g10/encrypt.c g10/decrypt-data.c g10/exec.c g10/export.c g10/getkey.c g10/gpg.c g10/gpgv.c g10/helptext.c g10/import.c g10/keydb.c g10/keyedit.c g10/keygen.c g10/keyid.c g10/keylist.c g10/keyring.c g10/keyserver.c g10/mainproc.c g10/misc.c g10/openfile.c g10/parse-packet.c g10/passphrase.c g10/photoid.c g10/pkclist.c g10/plaintext.c g10/pubkey-enc.c g10/revoke.c g10/seckey-cert.c g10/seskey.c g10/sig-check.c g10/sign.c g10/skclist.c g10/tdbdump.c g10/tdbio.c g10/textfilter.c g10/trustdb.c g10/verify.c -jnlib/argparse.c -jnlib/logging.c -jnlib/utf8conv.c -jnlib/dotlock.c - kbx/kbxutil.c scd/app-nks.c scd/app-openpgp.c scd/app-dinsig.c scd/scdaemon.c sm/base64.c sm/call-agent.c sm/call-dirmngr.c sm/certchain.c sm/certcheck.c sm/certdump.c sm/certlist.c sm/certreqgen.c sm/certreqgen-ui.c sm/decrypt.c sm/delete.c sm/encrypt.c sm/export.c sm/gpgsm.c sm/import.c sm/keydb.c sm/keylist.c sm/misc.c sm/qualified.c sm/sign.c sm/verify.c tools/gpg-connect-agent.c tools/gpgconf-comp.c tools/gpgconf.c tools/no-libgcrypt.c tools/symcryptrun.c tools/gpg-check-pattern.c diff --git a/scd/ChangeLog b/scd/ChangeLog index 91694a056..44497364d 100644 --- a/scd/ChangeLog +++ b/scd/ChangeLog @@ -1,2420 +1,2424 @@ +2010-03-10 Werner Koch + + * Makefile.am (scdaemon_LDADD): Remove libjnlib.a. + 2009-12-15 Werner Koch * iso7816.c (do_generate_keypair): s/readonly/read_only/ because the first is a keyword in VMS C. 2009-12-03 Werner Koch * scdaemon.c (set_debug): Allow for numerical debug leveles. Print active debug flags. 2009-11-25 Marcus Brinkmann * command.c (scd_command_handler): Use assuan_fd_t and assuan_fdopen on fds. 2009-11-05 Marcus Brinkmann * command.c (scd_command_handler): Call assuan_init_socket_server, not assuan_init_socket_server_ext. 2009-11-04 Werner Koch * command.c (register_commands): Add help arg to assuan_register_command. Add help strings to all commands. 2009-11-02 Marcus Brinkmann * command.c (reset_notify): Take LINE arg and return error. (register_commands): Use assuan_handler_t type. 2009-10-25 Werner Koch * scdaemon.c (scd_deinit_default_ctrl): Release IN_DATA. * command.c (cmd_setdata): Release IN_DATA. Reported by Klaus Flittner. 2009-10-16 Marcus Brinkmann * AM_CFLAGS, scdaemon_LDADD: Use libassuan instead of libassuan-pth. * scdaemon.c: Invoke ASSUAN_SYSTEM_PTH_IMPL. (main): Call assuan_set_system_hooks and assuan_sock_init. 2009-09-23 Marcus Brinkmann * command.c: Include "scdaemon.h" before because of GPG_ERR_SOURCE_DEFAULT check. (option_handler, open_card, cmd_serialno, cmd_lean, cmd_readcert) (cmd_readkey, cmd_setdata, cmd_pksign, cmd_pkauth, cmd_pkdecrypt) (cmd_getattr, cmd_setattr, cmd_writecert, cmd_writekey) (cmd_genkey, cmd_random, cmd_passwd, cmd_checkpin, cmd_lock) (cmd_unlock, cmd_getinfo, cmd_restart, cmd_disconnect, cmd_apdu) (cmd_killscd): Return gpg_error_t instead of int. (scd_command_handler): Allocate assuan context before starting server. * scdaemon.c (main): Update to new Assuan API. 2009-09-03 Werner Koch * app-openpgp.c (do_decipher): Compute required Le. * iso7816.c (iso7816_decipher): Add new arg LE. * app-nks.c (do_decipher): Adjust for change. * iso7816.c (iso7816_put_data, iso7816_put_data_odd): Turn DATA into a void ptr. 2009-08-05 Werner Koch * app-openpgp.c (change_keyattr_from_string): New. (do_setattr): Support KEY-ATTR. 2009-07-29 Marcus Brinkmann * ccid-driver.c (print_pr_data): Fix 64 bit compat problem. 2009-07-24 Werner Koch * ccid-driver.c (parse_ccid_descriptor): Enable hack for SCR 3320. 2009-07-21 Werner Koch * ccid-driver.c [HAVE_PTH]: Include pth.h. (my_sleep): New. (bulk_in): s/gnupg_sleep/my_sleep/. 2009-07-20 Werner Koch * apdu.c [GNUPG_MAJOR_VERSION==1]: Include dynload.h. 2009-07-16 Werner Koch * command.c (update_reader_status_file): Test for unplugged reader. (TEST_CARD_REMOVAL): Ditto. * app.c (select_application): Ditto. * ccid-driver.c (bulk_out): Return CCID_DRIVER_ERR_NO_READER if a reader was unplugged. (struct ccid_driver_s): Turn nonnull_nad into an unsigned char. Turn apdu_level, auto_ifsd, powered_off, has_pinpad into bitfields. Add enodev_seen. * apdu.c (apdu_prepare_exit): New. (get_status_ccid): Return the status word and nut just -1. * scdaemon.c (scd_exit): Call it. 2009-07-13 Werner Koch * ccid-driver.c (struct ccid_driver_s): Add fields last_progress, progress_cb and progress_cb_arg. (ccid_set_progress_cb): New. (print_progress): New. (ccid_transceive): Call print_progress for wait time extensions. * apdu.c (struct reader_table_s): Add field set_progress_cb. (new_reader_slot): Clear that field. (open_ccid_reader): Set it to .. (set_progress_cb_ccid_reader): ... new fucntion. * app.c (print_progress_line): New. (lock_reader): Add arg CTRL to set a progress callback and change all callers to provide it. (unlock_reader): Remove the progress callback. 2009-07-10 Werner Koch * iso7816.c (iso7816_compute_ds): Add args EXTENDED_MODE and LE. Change all callers to use 0. (iso7816_internal_authenticate): Add args EXTENDED_MODE and LE. * app-openpgp.c (do_sign): Take exmode and Le from card capabilities and pass them to iso7816_compute_ds. (do_auth): Ditto for iso7816_internal_authenticate. (change_keyattr): Reset CHV verification status. 2009-07-09 Werner Koch * app-openpgp.c (change_keyattr): New. (do_writekey): Call it. * app-openpgp.c (does_key_exist): Add arg GENERATING. Change callers. 2009-06-30 Werner Koch * ccid-driver.c (ccid_transceive): Set RESYNCING flag. 2009-06-29 Werner Koch * ccid-driver.c (ccid_transceive): Add a hack to support extended length for Omnikey readers. (is_exlen_apdu): New. (parse_ccid_descriptor): Track short+extended apdu exchange level. 2009-06-18 Werner Koch * app-openpgp.c (verify_chv2): Remove special case for v2 cards. (get_public_key): Use extended mode. 2009-06-17 Werner Koch * iso7816.c (iso7816_get_data): Add arg EXTENDED_MODE. Change all callers. * app-openpgp.c (data_objects): Use bit flags. Add flag TRY_EXTLENGTH. (get_cached_data): Add arg TRY_EXTLEN and use it for iso7816_get_data. (get_one_do): Use extended length APDU if necessary. 2009-06-10 Werner Koch * app-openpgp.c (store_fpr): Change first arg to app_t; adjust callers. Flush the cache. 2009-06-09 Werner Koch * app-openpgp.c (do_readcert): Return NOT_FOUND if the retrieved data has a length of zero. (do_getattr): Add EXTCAP subkey "sm". 2009-05-20 Werner Koch * app-openpgp.c (verify_chv2): Add case for v2 cards. (verify_chv3): Factor some code out to .. (build_enter_admin_pin_prompt): .. new. (do_change_pin): Properly handle v2 cards. 2009-05-19 Werner Koch * scdaemon.c (create_server_socket): Use SUN_LEN. (JNLIB_NEED_AFLOCAL): Define. 2009-05-13 Werner Koch * ccid-driver.c (abort_cmd): Add arg SEQNO and change callers. (bulk_in): Retry on seqno mismatch. * apdu.c (send_le): Release result_buffer. (apdu_send_direct): Implemend extended length. * command.c (cmd_apdu): Add option "--exlen". 2009-05-11 Werner Koch * apdu.c (send_le): Replace log_error by log_info. 2009-05-08 Werner Koch * app-openpgp.c (do_genkey): Allow larger key sizes. (do_decipher): Ditto. * iso7816.c (do_generate_keypair): Add arg EXTENDED_MODE an LE. (iso7816_generate_keypair, iso7816_read_public_key): Ditto. Changed all callers. * apdu.c (send_le): Implement extended length return values. * ccid-driver.c (bulk_in): Retry on EAGAIN. (abort_cmd): Change seqno handling. 2009-04-28 Werner Koch * app-help.c (app_help_count_bits): New. * app-nks.c (switch_application): Detect mass signature cards. Take care of new NEED_APP_SELECT flag. (do_sign): Don't allow mass signature cards. (all_zero_p): New. (do_readkey): New. (app_select_nks): Register do_readkey. 2009-04-01 Werner Koch * app-openpgp.c (do_setattr, do_writekey): Prepare for extended length cards. 2009-03-31 Werner Koch * command.c (percent_plus_unescape): Remove. (cmd_setattr): Use percent_plus_unescape_inplace. 2009-03-30 Werner Koch * app-nks.c (do_decipher): Make it work for TCOS 3. * iso7816.c (iso7816_decipher): Add arg EXTENDED_MODE. * apdu.c (apdu_send): Add arg EXTENDED_MODE and change all callers. (apdu_send_le): Ditto. (apdu_send_direct): Ditto, but not yet functional. (send_le): Fix command chaining. Implement extended length option. * ccid-driver.c (ccid_transceive): Remove restriction on apdu length. (struct ccid_driver_s): Add field IFSC. (ccid_get_atr): Set IFSC. (ccid_transceive): Use negotiated IFSC and support S(IFS) command. 2009-03-26 Werner Koch * command.c (cmd_pksign): Allow more hash algorithms. * scdaemon.h (MAX_DIGEST_LEN): Change to 64. * apdu.c (open_ccid_reader): Clear the is_to flag. * app-nks.c (filelist): Add field KID. (do_getattr): Change standard authentication key. (do_sign): Setup a security environment for TCOS 3 cards and support all SHA-2 algorithms. 2009-03-24 Werner Koch * command.c (struct server_local_s): Add flag APP_CTX_MARKED_FOR_RELEASE. (do_reset): Set the flag. (open_card): Act on this flag. * app-common.h (struct app_ctx_s): Add flag NO_REUSE. (application_notify_card_reset): Set the flag. * app.c (select_application, release_application): Take care of that flag. 2009-03-20 Werner Koch * app-nks.c (keygripstr_from_pk_file): Fix for TCOS 3 cards. 2009-03-18 Werner Koch * apdu.c (open_pcsc_reader_wrapped): Use close_all_fds. * command.c (cmd_learn): Add option --keypairinfo. * app.c (app_write_learn_status): Add arg FLAGS. * app-common.h (struct app_ctx_s): Add arg FLAGS to LEARN_STATUS. Change all implementors. * app-p15.c (do_learn_status): Take care of flag bit 0. * app-nks.c (do_learn_status, do_learn_status_core): Ditto. 2009-03-10 Werner Koch * app-openpgp.c (send_key_attr): New. (do_getattr): New attribute KEY_ATTR. * command.c (send_status_direct): New. 2009-03-06 Werner Koch * app-nks.c (do_learn_status): Factor code out to.. (do_learn_status_core): .. new. (do_readcert, do_sign, do_decipher): Switch to SigG if needed. (verify_pin): Use DESC also for keypad based verify. 2009-03-05 Werner Koch * app-openpgp.c (verify_a_chv): Remove special case for keypads. (verify_chv3): Ditto. * app-nks.c (get_chv_status): New. (parse_pwidstr): New. (verify_pin): Add args PWID and DESC and use them. Remove the CHV1 caching. (do_change_pin): Allow PIN selection and add reset mode. (do_learn_status): Use NKS-NKS3 tag for TCOS 3 cards. (do_readcert, do_sign): Allow NKS-NKS3 tag. 2009-03-04 Werner Koch * app-nks.c (do_getattr): New. (app_select_nks): Register it. (verify_pin): Factor some code out to... (basic_pin_checks): New. (do_change_pin): Call the basic check. (app_select_nks): Move AID to .. (aid_nks): .. new. (aid_sigg): New. (switch_application): New. (do_getattr, do_learn_status, do_readcert, do_sign, do_decipher) (do_change_pin, do_check_pin): Make sure we are in NKS mode. 2009-03-03 Werner Koch * command.c (scd_command_handler): Remove dereference of STOPME after free. 2009-02-27 Werner Koch * app.c (get_supported_applications): New. * command.c (cmd_getinfo): New subcommand "app_list" (cmd_killscd): New. (register_commands): Register command KILLSCD. (struct server_local_s): Add field STOPME. (scd_command_handler): Act upon this. 2009-02-25 Werner Koch * apdu.c (apdu_get_status): Factor all code out to ... (apdu_private_get_status): .. new. Add arg NO_ATR_RESET. (apdu_connect): Call new function. * scdaemon.c: New option --debug-log-tid. (tid_log_callback): New. (main): Move debug-wait code after debug stream init. 2009-02-24 Werner Koch * ccid-driver.c (ccid_get_atr): Move debug output to .. (print_r2p_parameters): .. new. (print_r2p_header, print_pr_data, print_r2p_unknown) (print_r2p_datablock, print_r2p_slotstatus, print_r2p_escape) (print_r2p_datarate): New. (bulk_in): Call parameter printing. (ccid_set_debug_level): Add debug level 3. (convert_le_u16): New. (print_p2r_header, print_p2r_iccpoweron, print_p2r_iccpoweroff) (print_p2r_getslotstatus, print_p2r_xfrblock) (print_p2r_getparameters, print_p2r_resetparameters) (print_p2r_setparameters, print_p2r_escape, print_p2r_iccclock) (print_p2r_to0apdu, print_p2r_secure, print_p2r_mechanical) (print_p2r_abort, print_p2r_setdatarate, print_r2p_unknown): New. (bulk_out): Add arg NO_DEBUG and change all callers to pass 0. Call parameter printing. (ccid_slot_status): Call with NO_DEBUG set. (abort_cmd, send_escape_cmd, ccid_get_atr, ccid_get_atr) (ccid_transceive_apdu_level, ccid_transceive) (ccid_transceive_secure): Remove old debug print code. 2009-02-12 Werner Koch * command.c (cmd_getinfo): Add new subcommand "deny_admin". 2009-01-28 Werner Koch * scdaemon.c (main): Make --allow-admin the default and make the option a dummy. 2009-01-27 Werner Koch * app-geldkarte.c: Changed to use an AID. * app.c (app_munge_serialno): Add case for no serialno. (app_get_serial_and_stamp): Ditto. 2009-01-26 Werner Koch * app-geldkarte.c: New. * Makefile.am (card_apps): Add new file. * app.c (select_application): Test for geldkarte. 2009-01-12 Werner Koch * command.c (send_client_notifications) [HAVE_W32_SYSTEM]: Fix brackets. 2009-01-08 Werner Koch * iso7816.c (iso7816_read_record, iso7816_read_binary): Pass 0 for L_e because the problem with the CCID driver has gone. (iso7816_apdu_direct): New. * app-nks.c (filelist): Add NKS_VER field. Add NKS 3 specific entries. (app_local_s, do_deinit): New. (get_nks_version): New. (app_select_nks): Setup local data. (keygripstr_from_pk_file): Replace SLOT by APP and take care of NKS version > 2. (do_learn_status): Take care of NKS version. 2009-01-05 Werner Koch * apdu.c (apdu_get_status): Save the last status. 2008-12-18 Werner Koch * ccid-driver.c (abort_cmd): New. (bulk_in): Call abort_cmd after severe errors. * apdu.c (reader_table_s): Add field ANY_STATUS. (new_reader_slot): Clear it. (apdu_get_status): Use ANY_STATUS to update the change counter. Remove the use of the flag bit from LAST_STATUS everywhere. * command.c (update_reader_status_file): Factor code out to ... (send_client_notifications): New. Track signals already sent. (update_reader_status_file): Shutdown the reader after a failed apdu_get_status. 2008-12-09 Werner Koch * scdaemon.c (main): Call i18n_init before init_common_subsystems. 2008-12-08 Werner Koch * scdaemon.c (handle_connections): Sync ticker to the next full interval. (TIMERTICK_INTERVAL_USEC): Change to 500ms. 2008-12-05 Werner Koch * app-openpgp.c (app_local_s): Add field ALGO_ATTR_CHANGE. (app_select_openpgp): Parse new capability. (show_caps): Show new capability. 2008-12-03 Werner Koch * scdaemon.c (opts): Use ARGPARSE_ macros. Add option --card-timeout. * command.c (update_reader_status_file): Implement it. 2008-11-18 Werner Koch * scdaemon.c (make_libversion): New. (my_strusage): Print libgcrypt and libksba version. 2008-11-03 Werner Koch * command.c (server_local_s): Add field DISCONNECT_ALLOWED. (cmd_disconnect): Implement command. (open_card): Reset disconnect flag. (update_reader_status_file): Disconnect if allowed. * app-common.h (app_ctx_s): Remove INITIALIZED. Make REF_COUNT unsigned. * app.c (select_application): Remove INITIALIZED. (app_write_learn_status, app_readcert, app_readkey, app_getattr) (app_setattr, app_sign, app_decipher, app_writecert) (app_writekey, app_get_challenge, app_change_pin, app_check_pin): Replace INITIALIZED by REF_COUNT check. (application_notify_card_removed): Rename to .. (application_notify_card_reset): .. this. Change all callers. * command.c (do_reset): Call application_notify_card_reset after sending a reset. (update_reader_status_file): Add arg SET_CARD_REMOVED. (scd_update_reader_status_file): Pass true for new flag. (do_reset): Pass false for new flag. * app.c (app_get_serial_and_stamp): Use bin2hex. * app-help.c (app_help_get_keygrip_string): Ditto. * app-p15.c (send_certinfo, send_keypairinfo, do_getattr): Ditto. * app-openpgp.c (send_fpr_if_not_null, send_key_data) (retrieve_fpr_from_card, send_keypair_info): Ditto. * app-nks.c (keygripstr_from_pk_file): Ditto. * command.c (cmd_apdu): Ditto. 2008-10-21 Marcus Brinkmann * command.c (open_card): If connect error is SW_HOST_NO_CARD, return a more descriptive error. 2008-10-20 Werner Koch * pcsc-wrapper.c (read_32): Use provided arg and not stdin. Is called with stdin, though. (handle_close): Mark unused arg. (handle_status, handle_reset): Ditto. * ccid-driver.c (ccid_check_card_presence): Mark not yet used arg. * scdaemon.c (scd_deinit_default_ctrl): Mark unused arg. * command.c (cmd_unlock, cmd_restart, cmd_disconnect): Ditto. * apdu.c (ct_get_status): Ditto. (ct_send_apdu, pcsc_send_apdu_wrapped) (apdu_open_remote_reader): Ditto. * app.c (select_application): Ditto. * app-openpgp.c (do_writecert, do_change_pin, do_writekey): Ditto. * app-nks.c (do_change_pin, do_check_pin): Ditto. 2008-10-16 Werner Koch * command.c (cmd_disconnect): New dummy command. (register_commands): Register command. 2008-10-15 Werner Koch * command.c (scd_command_handler): Return true if there is no more active session. * scdaemon.c (start_connection_thread): Set shutdown flag if requested by command handler. (main): Make PIPE_SERVER module global. (handle_connections): Disable listen_fd if a shutdown is pending. 2008-10-14 Werner Koch * apdu.c (reader_table_s): Add fields connect_card and disconnect_card. (new_reader_slot): Set them to NULL. (apdu_connect, apdu_disconnect): New. (apdu_close_reader, apdu_shutdown_reader): Call apdu_disconnect. (connect_pcsc_card, disconnect_pcsc_card): new. (reset_pcsc_reader_direct): Implement in terms of disconnect_pcsc_card and connect_pcsc_card. (apdu_get_atr): Return NULL if there is no ATR. * sc-copykeys.c (main): Add call to apdu_connect. * command.c (open_card): Ditto. * apdu.h (SW_HOST_ALREADY_CONNECTED): New. (APDU_CARD_USABLE, APDU_CARD_PRESENT, APDU_CARD_ACTIVE): New. * apdu.c: Replace constants by the new macros. (open_pcsc_reader): Factor code out to ... (open_pcsc_reader_direct, open_pcsc_reader_wrapped): New. (reset_pcsc_reader): Factor code out to ... (reset_pcsc_reader_direct, reset_pcsc_reader_wrapped): New. (pcsc_get_status): Factor code out to ... (pcsc_get_status_direct, pcsc_get_status_wrapped): New. (pcsc_send_apdu): Factor code out to ... (pcsc_send_apdu_direct, pcsc_send_apdu_wrapped): New. (close_pcsc_reader): Factor code out to ... (close_pcsc_reader_direct, close_pcsc_reader_wrapped): New. * command.c (update_reader_status_file): Open the reader if not yet done. * scdaemon.c (TIMERTICK_INTERVAL_SEC, TIMERTICK_INTERVAL_USEC): New to replace TIMERTICK_INTERVAL. Chnage from 2s (4 under W32) to 250ms. 2008-10-13 Werner Koch * command.c (option_handler) [W32]: Use strtoul with base 16. (update_reader_status_file) [W32]: Set Event. (scd_command_handler): Use INT2FD to silent warning. 2008-09-29 Werner Koch * scdaemon.h (GCRY_MD_USER): Rename to GCRY_MODULE_ID_USER. (GCRY_MD_USER_TLS_MD5SHA1): Rename to MD_USER_TLS_MD5SHA1 and change all users. 2008-09-28 Marcus Brinkmann * apdu.c (pcsc_get_status): Fix last change. 2008-09-25 Werner Koch * app-openpgp.c (do_setattr): Do not allow setting of the reset code. (do_change_pin): Allow setting of the reset code. 2008-09-24 Werner Koch * app-openpgp.c (verify_chv3): Set the did_chv3 flag which was accidently removed on 2008-03-26. (verify_chv2): Revert last change. (do_change_pin): Do not change CHV2. Add reset code logic for v2 cards. * iso7816.c (iso7816_reset_retry_counter_with_rc): New. * app-openpgp.c (add_tlv, build_privkey_template): New. (do_writekey): Support v2 keys and other key lengths than 1024. * iso7816.c (iso7816_put_data_odd): New. 2008-09-23 Werner Koch * app-openpgp.c (do_sign): Support SHA-2 digests. (verify_chv2): No CHV auto-sync for v2 cards. (do_auth): Allow 2048 bit keys. (parse_algorithm_attribute): New. (rsa_key_format_t): New. (struct app_local_s): Add struct KEYATTR. 2008-09-23 Marcus Brinkmann * apdu.c (pcsc_get_status): Be more relaxed with the usable flag under Windows. 2008-09-23 Werner Koch * app-openpgp.c (do_setattr): Use command chaining for long values. * iso7816.c (iso7816_put_data): Add arg EXTENDED_MODE. Change all callers. * apdu.c (apdu_send_simple): Add arg EXTENDED_MODE. Change all callers. (send_le): Implement command chaining. * ccid-driver.c (ccid_transceive_apdu_level): Increase allowed APDU size. (ccid_transceive): Alow for APDUS of up to 259 bytes. * apdu.h: Add new SW_ codes. 2008-09-16 Werner Koch * command.c (cmd_writecert): New. (register_commands): Register it. * app-common.h (app_ctx_s): Add member WRITECERT. * app.c (app_writecert): New. * app-openpgp.c (do_writecert): New. (parse_historical): New. (show_extcap): New. (dump_all_do): Print only the length of longs DOs. * command.c (cmd_writekey, cmd_apdu, cmd_pksign) (cmd_passwd): Replace open coding by skip_options. 2008-08-30 Moritz * scdaemon.c (main): Use estream_asprintf instead of asprintf. * command.c (update_reader_status_file): Likewise. (cmd_serialno): Use estream_asprintf instead of asprintf and xfree instead of free to release memory allocated through (estream_)asprintf. (cmd_learn): Likewise. (pin_cb): Likewise. * app-openpgp.c (get_public_key): Likewise. 2008-08-18 Werner Koch * app-openpgp.c (do_setattr): Fix test for v2 cards. 2008-08-11 Werner Koch * apdu.c (reset_pcsc_reader, open_pcsc_reader) (reset_rapdu_reader, open_rapdu_reader): Allow ATRs of up to 33 bytes. Provide maximum size of ATR buffer using DIM. Such long ATR are never seen in reality but the PC/SC library of MAC OS X is just too buggy. Reported by Ludovic Rousseau. Fixes bug #948. 2008-07-30 Werner Koch * app-openpgp.c (verify_a_chv): Use xtrymalloc and make the prompt for CHV2 more user friendly. 2008-07-03 Werner Koch * app-openpgp.c (do_readcert): New. (app_local_s): Add fields IS_V2 and MAX_CERTLEN_3. (app_select_openpgp): Set them and register do_readcert. (do_setattr): Allow storing of the certificate. 2008-06-25 Werner Koch * app-dinsig.c (do_sign): Allow for SHA256. 2008-06-24 Werner Koch * app-common.h (app_ctx_s): Renamed reset_mode parameter of change_pin to mode_Flags and make it an unsigned int. (APP_CHANGE_FLAG_RESET, APP_CHANGE_FLAG_NULLPIN): New. * app-openpgp.c (do_change_pin): Adjust for that. * command.c (cmd_passwd): Add option --nullpin. * app-nks.c (do_check_pin, do_change_pin): New. (app_select_nks): Register new functions. 2008-04-21 Moritz Schulte (wk) * app-openpgp.c (verify_a_chv): Make use of the default CHV flag. 2008-03-26 Werner Koch * app-openpgp.c (verify_chv3): Support the keypad. 2008-02-09 Marcus Brinkmann * scdaemon.c (main): Use CONFIG_FILENAME as filename if it is set in gpgconf-list output. 2007-12-10 Werner Koch * app-openpgp.c (do_decipher): Take care of cryptograms shorter that 128 bytes. Fixes bug#851. 2007-11-14 Werner Koch * scdaemon.c (main): Pass STANDARD_SOCKET flag to create_server_socket. 2007-11-13 Werner Koch * scdaemon.c (start_connection_thread): Do not call assuan_sock_check_nonce if we are running in --server mode. 2007-11-07 Werner Koch * scdaemon.h: Remove errors.h. 2007-10-02 Werner Koch * command.c (cmd_getinfo): Add "pid" subcommand. 2007-10-01 Werner Koch * scdaemon.c (create_server_socket): Use Assuan socket wrappers and remove Windows specific code. (socket_nonce): New. (start_connection_thread): Check nonce. 2007-09-14 Marcus Brinkmann * scdaemon.c (main): New variable STANDARD_SOCKET, which is 1 for W32 targets. Use it for create_socket_name. 2007-08-07 Werner Koch * tlv.c, tlv.h: Move to ../common/. 2007-08-02 Werner Koch * scdaemon.c: Include gc-opt-flags.h and remove their definition here. 2007-08-01 Werner Koch * apdu.c (send_le): Implement exact length hack. Suggested by Sten Lindgren. 2007-07-05 Werner Koch * command.c (has_option_name, skip_options): New. (cmd_genkey): Add option --timestamp. (cmd_writekey): Enter confidential mode while inquiring the key data. * app.c (app_genkey): Add arg CREATETIME. * app-common.h (app_ctx_s): Likewise * app-openpgp.c (do_genkey): Ditto. Use it. 2007-07-04 Werner Koch * command.c (cmd_getinfo): New subcommand "version". * scdaemon.c (TIMERTICK_INTERVAL): New. (handle_connections) [W32]: Enable a dummy sigs event. (handle_connections): Use a proper count for select and not FD_SETSIZE. (fixed_gcry_pth_init, main): Kludge to fix pth initialization. 2007-06-21 Werner Koch * scdaemon.h (ctrl_t): Remove. It is now declared in ../common/util.h. 2007-06-18 Marcus Brinkmann * scdaemon.c (main): Percent escape output of --gpgconf-list. 2007-06-12 Werner Koch * scdaemon.c (main): Replace some calls by init_common_subsystems. 2007-06-11 Werner Koch * Makefile.am (scdaemon_LDADD): Use libcommonpth macro. * command.c (initialize_module_command): New. * scdaemon.c (main) [W32]: Do not use sigpipe code. (main): Call initialize_module_command. 2007-06-06 Werner Koch * app-openpgp.c (do_sign): Fix arithmetic on void*. * app.c (dump_mutex_state) [W32]: Handle the W32Pth case. * apdu.c: Remove dynload.h. * scdaemon.c (i18n_init): Remove. 2007-04-20 Werner Koch * sc-copykeys.c (my_gcry_logger): Removed. (main): Call setup_libgcrypt_logging helper. * scdaemon.c (my_gcry_logger): Removed. (main): Call setup_libgcrypt_logging helper. 2007-04-03 Werner Koch * command.c (cmd_getinfo): New subcommand "reader_list". * ccid-driver.c (scan_or_find_devices): Ignore EBUSY in scan mode for special transports. 2007-03-07 Werner Koch * app-dinsig.c: Include i18n.h. (verify_pin): Support PIN pads. * app-nks.c (verify_pin): Ditto. * ccid-driver.c (bulk_in): Handle time extension before checking the message type. (ccid_transceive_secure): Support the Cherry XX44 keyboard. Kudos to the nice folks at Cherry for helping with that. 2007-02-18 Werner Koch * scdaemon.c (DEFAULT_PCSC_DRIVER): Add a default for OS X. 2007-01-25 Werner Koch * Makefile.am (scdaemon_LDADD): Added LIBICONV. Noted by Billy Halsey. 2006-12-21 Werner Koch * app-openpgp.c (verify_chv2): Factored most code out into... (verify_a_chv): ... new. (do_sign): Factored verification code out to new function and take care of a keypad entered PIN. (compare_fingerprint): Print an additional diagnostic. 2006-11-28 Werner Koch * apdu.c (send_le, apdu_send_direct): Increase RESULTLEN to 258 to allow for full 256 byte and the status word. This might break some old PC/SC drivers or cards, but we will see. Suggested by Kenneth Wang. 2006-11-23 Werner Koch * command.c (scd_command_handler): Fixed use of CTRL. 2006-11-21 Werner Koch * Makefile.am (libexec_PROGRAMS): Put pscs-wrapper into libexec. Renamed to gnupg-pcsc-wrapper. * apdu.c (open_pcsc_reader): Use GNUPG_LIBEXECDIR to accces the wrapper. Suggested by Eric Dorland. 2006-11-20 Werner Koch * app-openpgp.c (verify_chv2): Support for keypads (only CHV2). * ccid-driver.c (ccid_transceive_secure): Made it work for Kaan and SCM. 2006-11-17 Werner Koch * ccid-driver.c (scan_or_find_devices): Use DEBUGOUT_2 instead of log_debug. Removed few other log_debug. * iso7816.c (iso7816_check_keypad): Allow for a SW of 0. * command.c (pin_cb): New mode to prompt for a keypad entry. * scdaemon.c (main) : Add disable-keypad. 2006-11-15 Werner Koch * app-p15.c (read_ef_odf): Cast one printf arg. * scdaemon.h (struct server_control_s): Add field THREAD_STARTUP. * command.c (scd_command_handler): Add new arg CTRL. * scdaemon.c (scd_init_default_ctrl): Made static. (scd_deinit_default_ctrl): New. (start_connection_thread): Call init/deinit of ctrl. (handle_connections): Allocate CTRL. * apdu.c (PCSC_ERR_MASK): New. (reset_pcsc_reader, pcsc_get_status, pcsc_send_apdu) (close_pcsc_reader, open_pcsc_reader): Use it after shifting error values. Reported by Henrik Nordstrom. Fixes bug #724. 2006-10-24 Werner Koch * scdaemon.h (GCRY_MD_USER_TLS_MD5SHA1): New. (MAX_DIGEST_LEN): Increased to 36. * app-p15.c (do_sign): Support for TLS_MD5SHA1. (do_auth): Detect TLS_MD5SHA1. (do_sign): Tweaks for that digest. 2006-10-23 Werner Koch * scdaemon.c (main): New command --gpgconf-test. 2006-10-17 Werner Koch * Makefile.am (scdaemon_LDADD): Link against libcommonpth. 2006-10-12 Werner Koch * apdu.c: Include pth.h after unistd.h for the sake of newer Pth versions. 2006-10-11 Werner Koch * app-openpgp.c (do_sign): Redirect to do_auth for OpenPGP.3. 2006-10-06 Werner Koch * Makefile.am (AM_CFLAGS): Use PTH version of libassuan. (scdaemon_LDADD): Ditto. * scdaemon.h (send_status_info): Mark with sentinel attribute. 2006-10-02 Marcus Brinkmann * command.c (update_reader_status_file): Increase buffer of NUMBUF2 (fixing typo). 2006-09-24 Marcus Brinkmann * app-openpgp.c (do_sign): Advance INDATA by the SHA1 resp. RMD160 prefix length. 2006-09-14 Werner Koch Replaced all call gpg_error_from_errno(errno) by gpg_error_from_syserror(). * command.c (scd_command_handler): Replaced init_connected_socket_server by init_socket_server_ext. 2006-09-07 Werner Koch * command.c (update_reader_status_file): Execute an event handler if available. 2006-09-06 Werner Koch * apdu.c (pcsc_end_transaction): * pcsc-wrapper.c (pcsc_end_transaction: Fixed dclaration. Reported by Bob Dunlop. * scdaemon.h (CTRL,APP): Removed and changed everywhere to ctrl_t/app_t. Replaced all Assuan error codes by libgpg-error codes. Removed all map_to_assuan_status and map_assuan_err. * scdaemon.c (main): Call assuan_set_assuan_err_source to have Assuan switch to gpg-error codes. * command.c (set_error): Adjusted. 2006-09-02 Marcus Brinkmann * command.c (get_reader_slot): Return the slot_table index, not the APDU slot number. (update_reader_status_file): Use the slot_table index in the update_card_removed invocation. 2006-09-01 Marcus Brinkmann * command.c (cmd_getinfo): Handle status command. 2006-08-30 Marcus Brinkmann * command.c (do_reset): Delay resetting CTRL->reader_slot until after update_card_removed invocation. 2006-08-28 Marcus Brinkmann * app-openpgp.c (do_decipher, do_sign): Allow "OPENPGP.2" resp. "OPENPGP.1" for KEYIDSTR. 2006-08-21 Werner Koch * pcsc-wrapper.c (handle_open, handle_close): Reset card and protocol on error/close. (handle_status): Don't set the state if the state is unknown. (handle_reset): Ignore an error if already disconnected. May happen due to system wake-up after hibernation. Suggested by Bob Dunlop. 2006-06-28 Werner Koch * app-openpgp.c (do_writekey): Fixed computation of memmove length. This led to garbled keys if E was larger than one byte. Thanks to Achim Pietig for hinting at the garbled E. 2006-06-09 Marcus Brinkmann * Makefile.am (scdaemon_LDADD): Add $(NETLIBS). 2006-04-14 Marcus Brinkmann * app.c (select_application): Cover up a slot mismatch error in case it happens (it shouldn't happen). (release_application): Use APP->slot. Lock the reader. (application_notify_card_removed): Lock the reader. 2006-04-11 Werner Koch * command.c (hex_to_buffer): New. (cmd_apdu): New. 2006-04-03 Werner Koch * scdaemon.c [__GLIBC__]: Default to libpcsclite.so.1. 2006-03-21 Werner Koch * command.c (cmd_pksign): Add --hash option. 2006-03-01 Werner Koch * command.c (status_file_update_lock): New. (scd_update_reader_status_file): Use lock and factor existing code out to .. (update_reader_status_file): .. this. (do_reset): Use the lock and call update_reader_status_file. 2006-02-20 Werner Koch * apdu.c (open_pcsc_reader): Fixed double free. Thanks to Moritz. 2006-02-09 Werner Koch * command.c (get_reader_slot, do_reset) (scd_update_reader_status_file): Rewrote. * app.c (release_application): Factored code out to .. (deallocate_app): new function. (select_application): Introduce new saved application stuff. (application_notify_card_removed): New. * command.c (update_card_removed): Call it here. (do_reset): And here. * app.c (check_application_conflict): New. * command.c (open_card): Use it here. (cmd_restart): New command. * command.c (cmd_lock): Fixed --wait option to actually terminate. 2006-02-08 Werner Koch * ccid-driver.c (ccid_get_atr): Read Parameter and select T=1 using these parameters. (scan_or_find_devices): Check for NULL r_fd. 2006-02-02 Werner Koch * ccid-driver.c (special_transport): New (ccid_open_reader, do_close_reader, ccid_shutdown_reader) (bulk_out, bulk_in): Add support for CardMan 4040 reader. * ccid-driver.c (scan_or_find_devices): Factored most code out to (scan_or_find_usb_device): .. new. (make_reader_id): Fixed vendor mask. 2006-01-01 Werner Koch * app-openpgp.c (do_sign): Give user error if hash algorithm is not supported by the card. 2005-12-06 Werner Koch * apdu.c (open_pcsc_reader): Check that pcsc-wrapper is actually installed. 2005-11-23 Werner Koch * app-nks.c (verify_pin): Give a special error message for a Nullpin. 2005-10-29 Werner Koch * ccid-driver.c (send_escape_cmd): New args RESULT, RESULTLEN and RESULTMAX. Changed all callers. (ccid_transceive_escape): New. 2005-10-27 Werner Koch * apdu.c [__CYGWIN__]: Make cygwin environment similar to _WIN32. Suggested by John P. Clizbe. * scdaemon.c [__CYGWIN__]: Set default PC/SC driver to winscard.dll. 2005-10-19 Werner Koch * ccid-driver.h (CCID_DRIVER_ERR_NO_KEYPAD): New. * apdu.h (SW_HOST_NO_KEYPAD): New. * iso7816.h (struct iso7816_pininfo_s): New. * iso7816.c (map_sw): Support new code. (iso7816_check_keypad): New. (iso7816_verify_kp, iso7816_change_reference_data_kp) (iso7816_reset_retry_counter_kp): New. Extended versions of the original functions. * apdu.c (host_sw_string): Support new code. (reader_table_s): New field CHECK_KEYPAD. (new_reader_slot, open_ct_reader, open_pcsc_reader) (open_ccid_reader, open_rapdu_reader): Initialize it. (check_ccid_keypad): New. (apdu_check_keypad): New. (apdu_send_le): Factored all code out to ... (send_le): .. new. Takes an additional arg; changed all callers of the orginal function to use this one with a NULL for the new arg. (apdu_send_simple_kp): New. (ct_send_apdu, pcsc_send_apdu, my_rapdu_send_apdu) (send_apdu_ccid): New arg PININFO. (send_apdu_ccid): Use the new arg. * scdaemon.c: New option --disable-keypad. 2005-10-08 Marcus Brinkmann * Makefile.am (scdaemon_LDADD): Add ../gl/libgnu.a after ../common/libcommon.a. 2005-09-20 Werner Koch * app-dinsig.c (verify_pin): Try ISO 9564 BCD encoding. * iso7816.c (iso7816_select_application): Add arg FLAGS. Changed all callers to pass 0. * app-openpgp.c (app_select_openpgp): But this one requires a special flag. * app-p15.c (app_select_p15): Don't use select application for the BELPIC. 2005-09-09 Werner Koch * pcsc-wrapper.c (main): Removed bogus free. * app-p15.c (do_auth): New. (do_getattr): New attribs $AUTHKEYID and $DISPSERIALNO. * app-openpgp.c (do_getattr): Ditto. 2005-09-08 Werner Koch * app-openpgp.c (do_getattr): New key $AUTHKEYID. 2005-09-06 Werner Koch * app-p15.c (do_sign): Tweaked for BELPIC cards. (read_home_df): New arg R_BELPIC. (app_select_p15): Set card type for BELPIC. 2005-09-05 Werner Koch * iso7816.c (iso7816_select_path): New. * app-p15.c (select_ef_by_path): Allow for direct path selection. (app_select_p15): Try using the Belgian variant of pkcs#15. (read_home_df): New. (read_ef_odf): Generalized. (read_ef_tokeninfo): New. (read_p15_info): Set serialnumber from TokenInfo. (app_select_p15): Don't munge serialNumber - that must be done only once. * iso7816.c (iso7816_read_binary): Use Le=0 when reading all data. Handle 6C00 error and take 6B00 as indication for EOF. * apdu.h (SW_EXACT_LENGTH_P): New. * apdu.c (new_reader_slot, reset_pcsc_reader, pcsc_get_status) (open_pcsc_reader): Set new reader state IS_T0. (apdu_send_le): When doing T=0 make sure not to send Lc and Le. Problem reported by Carl Meijer. (apdu_send_direct): Initialize RESULTLEN. * pcsc-wrapper.c (handle_status): Return the current protocol as a new third word. 2005-08-05 Werner Koch * apdu.c (open_rapdu_reader): Set the reader number. 2005-07-05 Werner Koch * app-openpgp.c (do_readkey): Return a mallcoed copy of the key as required by the description. Thanks to Moritz for tracking this problem down. 2005-06-21 Werner Koch * scdaemon.c (main): ifdef call to ccid_set_debug_level. * apdu.c (reset_pcsc_reader, open_pcsc_reader): Cast size_t to ulong for printf. 2005-06-06 Werner Koch * scdaemon.c (main): New option --debug-allow-core-dump. 2005-06-03 Werner Koch * scdaemon.c (handle_connections): Make sure that the signals we are handling are not blocked.Block signals while creating new threads. (handle_connections): Include the file descriptor into the name of the thread. 2005-06-02 Werner Koch * app.c (app_dump_state, dump_mutex_state): New. * scdaemon.c (handle_signal): Print it on SIGUSR1. * app-openpgp.c (do_writekey): Typo fix. * command.c (open_card): Check for locked state even if an application context is available. * app-common.h: Add REF_COUNT field. * app.c (release_application, select_application): Implement reference counting to share the context beween connections. * app.c (lock_reader, unlock_reader): Take SLOT instead of APP as argument. Changed all callers. (select_application): Unlock the reader on error. This should fix the hangs I noticed last week. * scdaemon.h: Removed card_ctx_t cruft. 2005-06-01 Werner Koch * scdaemon.c: Include mkdtemp.h. 2005-05-31 Werner Koch * tlv.c [GNUPG_MAJOR_VERSION==1]: Define constants instead of including a gnupg 1.4 header. 2005-05-30 Werner Koch * tlv.c: Add hack to compile without gpg-error.h when used with GnuPG 1.4. 2005-05-23 Werner Koch * Makefile.am: Do not build sc-copykeys anymore. * app-openpgp.c (app_openpgp_storekey, app_openpgp_readkey) (app_openpgp_cardinfo): Removed. * ccid-driver.c (parse_ccid_descriptor): SCR335 FW version 5.14 is good. (do_close_reader): Never do a reset. The caller should instead make sure that the reader has been closed properly. The new retry code in ccid_slot_status will make sure that the readersatrts up fine even if the last process didn't closed the USB connection properly. (ccid_get_atr): For certain readers try switching to ISO mode. Thanks to Ludovic Rousseau for this hint and the magic numbers. (print_command_failed): New. (bulk_in): Use it here. Add new arg NO_DEBUG. (ccid_slot_status): Disabled debugging. 2005-05-21 Werner Koch * scdaemon.c (handle_signal): Print thread info on SIGUSR1. 2005-05-20 Werner Koch * ccid-driver.c: Replaced macro DEBUG_T1 by a new debug level. (parse_ccid_descriptor): Mark SCR335 firmware version 5.18 good. (ccid_transceive): Arghhh. The seqno is another bit in the R-block than in the I block, this was wrong at one place. * scdaemon.c: New options --debug-ccid-driver and --debug-disable-ticker. * app-openpgp.c (do_genkey, do_writekey): Factored code to check for existing key out into .. (does_key_exist): .. New function. 2005-05-19 Werner Koch * tlv.c (parse_sexp): New. * command.c (cmd_writekey): New. * app.c (app_writekey): New. * app-common.c (app_t): Add function ptr WRITEKEY. * app-openpgp.c (do_writekey): New. * app-openpgp.c (do_readkey) [GNUPG_MAJOR_VERSION==1]: Return error. * app-common.h (app_t) [GNUPG_MAJOR_VERSION==1]: Add a field to store the Assuan context. 2005-05-17 Werner Koch * scdaemon.c: Removed non-pth code paths. (create_socket_name, create_server_socket): New. Taken from ../agent/gpg-agent. (cleanup): Changed to adjust for SOCKET_NAME now being malloced. (ticker_thread): Always use pth_event_occurred; it is again defined for all decent PTH versions. (handle_connections): New. Based on the gpg-agent code. (start_connection_thread): Ditto. (ticker_thread): Removed. (cleanup_sh): Removed. (main): Run the handler for the pipe server in a separate thread. This replaces the old ticker thread. (scd_get_socket_name): New. * command.c (cmd_getinfo): New command GETINFO. (scd_command_handler): Renamed argument and changed code to use an already connected FD. 2005-05-15 Werner Koch * app.c, app-common.h, app-nks.c, app-p15.c, app-dinsig.c * app-openpgp.c: Change most function return types from int to gpg_error_t. * command.c (pin_cb): Ditto. * sc-copykeys.c (pincb): Ditto. * app.c (lock_reader, unlock_reader): New. Changed call handler wrappers to make use of these functions. 2005-05-07 Werner Koch * ccid-driver.c (do_close_reader): Don't do a reset before close. Some folks reported that it makes the SCR335 hang less often. Look at the source on how to re-enable it. 2005-04-27 Werner Koch * app-p15.c (micardo_mse): New. (do_sign): Call it. * iso7816.c (iso7816_manage_security_env): Allow passing DATA as NULL to indicate an empty Lc. * tlv.c (find_tlv): Check that a found object fits into the buffer. (find_tlv_unchecked): New as replacement for the old non-checking variant. * app.c (select_application): Keep on using the non-checking variant. * app-openpgp.c (get_one_do, dump_all_do): Ditto. Removal of the old OpenSC based code. * app-p15.c: New. Basic support for pkcs15 cards without OpenSC. There are quite a couple of things missing but at least I can use my old TCOS cards from the Aegypten-1 development for signing. * app.c (select_application): Detect pkcs15 applications. * Makefile.am (scdaemon_SOURCES): Removed card.c, card-common.h and card-p15.c because they are now obsolete. Added app-p15.c. Removed all OpenSC stuff. * command.c (do_reset, open_card, cmd_serialno, cmd_learn) (cmd_readcert, cmd_readkey, cmd_pksign, cmd_pkdecrypt): Removed all special cases for the old card.c based mechanisms. * scdaemon.c, apdu.c: Removed all special cases for OpenSC. 2005-04-20 Werner Koch * command.c: Use GPG_ERR_LOCKED instead of EBUSY. 2005-04-14 Werner Koch * app-openpgp.c (retrieve_key_material): Rewritten. Return a proper error code. (retrieve_next_token): Removed. (retrieve_fpr_from_card): Rewritten to make use of DO caching and to take the KEYNO as arg. (get_public_key): Renamed variable for clarity. 2005-04-12 Werner Koch Basic support for several sessions. * command.c (scd_command_handler): Replace the primary_connection stuff by a real connection list. Release the local context on exit. (scd_update_reader_status_file): Update accordingly. Send signal to all connections who registered an event signal. (cmd_lock, cmd_unlock, register_commands): New commands LOCK and UNLOCK. (cmd_setdata, cmd_pksign, cmd_pkauth, cmd_pkdecrypt, cmd_setattr) (cmd_genkey, cmd_passwd, cmd_checkpin): Return an error if reader is locked. (do_reset): Handle locking. (open_card): Ditto. Share the reader slot with other sessions. (get_reader_slot): New. (update_card_removed): New. Use it in the TEST_CARD_REMOVAL macro. 2005-04-07 Werner Koch * app-openpgp.c (do_check_pin): Add hack to allow verification of CHV3. (get_public_key): Don't use gcry functions to create S-expressions. (do_deinit, do_readkey, do_genkey, send_keypair_info): Adjust for above change. 2005-03-29 Moritz Schulte * app-openpgp.c (retrieve_fpr_from_card): New function. (retrieve_next_token): New function. (retrieve_key_material): New function. (get_public_key): Implement retrival of key through expernal helper (gpg) in case the openpgp card is not cooperative enough. 2005-03-16 Werner Koch * ccid-driver.c (parse_ccid_descriptor): Make SCM workaround reader type specific. (scan_or_find_devices): Do not check the interface subclass in the SPR532 kludge, as this depends on the firmware version. (ccid_get_atr): Get the Slot status first. This solves the problem with readers hanging on recent Linux 2.6.x. (bulk_in): Add argument TIMEOUT and changed all callers to pass an appropriate one. Change the standard timeout from 10 to 5 seconds. (ccid_slot_status): Add a retry code with an initial short timeout. (do_close_reader): Do an usb_reset before closing the reader. 2005-02-25 Werner Koch * app-openpgp.c (get_public_key): Make sure not to return negative numbers. (do_sign): Allow passing of indata with algorithm prefix. (do_auth): Allow OPENPGP.3 as an alternative ID. * app.c (app_getattr): Return just the S/N but not the timestamp. 2005-02-24 Werner Koch * app.c (app_getattr): Return APPTYPE or SERIALNO type even if the application does dot support the getattr call. * app-openpgp.c (get_one_do): Never try to get a non cacheable object from the cache. (get_one_do): Add new arg to return an error code. Changed all callers. (do_getattr): Let it return a proper error code. * app.c (select_application): Return an error code and the application context in an new arg. * command.c (open_card): Adjusted for that. Don't use the fallback if no card is present. Return an error if the card has been removed without a reset. (do_reset, cmd_serialno): Clear that error flag. (TEST_CARD_REMOVAL): New. Use it with all command handlers. (scd_update_reader_status_file): Set the error flag on all changes. * scdaemon.c (ticker_thread): Termintate if a shutdown is pending. * apdu.c: Added some PCSC error codes. (pcsc_error_to_sw): New. (reset_pcsc_reader, pcsc_get_status, pcsc_send_apdu) (open_pcsc_reader): Do proper error code mapping. 2005-03-16 Werner Koch * ccid-driver.c (parse_ccid_descriptor): Make SCM workaround reader type specific. (scan_or_find_devices): Do not check the interface subclass in the SPR532 kludge, as this depends on the firmware version. (ccid_get_atr): Get the Slot status first. This solves the problem with readers hanging on recent Linux 2.6.x. 2005-02-22 Werner Koch * app-openpgp.c (app_local_s): New field PK. (do_deinit, do_genkey, app_openpgp_storekey): Clear it. (get_public_key, send_keypair_info): New. (do_learn_status): Send KEYPAIR info * app-common.h (app_ctx_t): Add function pointer READKEY. * app.c (app_readkey): New. * command.c (cmd_readkey): Use READKEY function if possible. 2005-01-26 Werner Koch * ccid-driver.c (parse_ccid_descriptor): Need the CSM workaround also for newer firmware versions. Need to get a list of fixed firmware versions and use that. 2005-01-25 Werner Koch * apdu.c (apdu_send_le, apdu_send_direct): Fix some compiler warnings. * app-openpgp.c (get_cached_data): New arg GET_IMMEDIATE to bypass the cache. Changed all callers. (get_one_do): Bypass the cache if the value would have been read directly for v1.1 cards.It makes things a bit slower but obnly for 1.0 cards and there are not that many cards out in the wild. This is required to fix a caching bug when generating new keys; as a side effect of the retrieval of the the C4 DO from the 6E DO the cached fingerprint will get updated to the old value and later when signing the generated key the checking of the fingerprint fails because it won't match the new one. Thanks to Moritz for analyzing this problem. (verify_chv3): Removed the CHV status reread logic because we won't cache the C4 DO anymore. 2004-12-28 Werner Koch * ccid-driver.c (find_endpoint): New. (scan_or_find_devices): Add new args to return endpoint info and interface number. (ccid_open_reader, ccid_shutdown_reader): Take care of these new args. (bulk_in, bulk_out): Use the correct endpoints. (ccid_transceive_apdu_level): New. (ccid_transceive): Divert to above. (parse_ccid_descriptor): Allow APDU level exchange mode. (do_close_reader): Pass the interface number to usb_release_interface. 2004-12-21 Werner Koch * scdaemon.c (main): Use default_homedir(). 2004-12-18 Werner Koch * scdaemon.c (main) [W32]: Remove special Pth initialize.. * scdaemon.h (map_assuan_err): Define in terms of map_assuan_err_with_source. 2004-12-15 Werner Koch * scdaemon.c [W32]: Various hacks to make it run under W32. * command.c (scd_update_reader_status_file) [W32]: Don't use kill. * apdu.c [W32]: Disable use of pcsc_wrapper. * Makefile.am (scdaemon_LDADD): Reorder libs. (sc_copykeys_LDADD): Add libassuan because it is needed for W32. 2004-12-06 Werner Koch * Makefile.am (pkglib_PROGRAMS): Build only for W32. 2004-10-22 Werner Koch * app-openpgp.c (verify_chv3): The minium length for CHV3 is 8. Changed string to match the other ones. 2004-10-21 Werner Koch * app-openpgp.c (do_sign): Replace asprintf by direct allocation. This avoids problems with missing vasprintf implementations in gnupg 1.4. * app-common.h (app_openpgp_storekey: Add prototype. 2004-10-20 Werner Koch * sc-investigate: Removed. * Makefile.am (sc_investigate): Removed. * pcsc-wrapper.c (load_pcsc_driver): Load get_status_change func. (handle_open): Succeed even without a present card. (handle_status, handle_reset): New. * apdu.c (apdu_open_reader): Load pcsc_get_status_change fucntion. (pcsc_get_status): Implemented. (reset_pcsc_reader): Implemented. (open_pcsc_reader): Succeed even with no card inserted. (open_ccid_reader): Set LAST_STATUS. * iso7816.c (iso7816_select_application): Always use 0 for P1. 2004-10-18 Werner Koch * ccid-driver.c (ccid_get_atr): Reset T=1 state info. 2004-10-14 Werner Koch * app-openpgp.c (parse_login_data): New. (app_select_openpgp): Call it. (do_setattr): Reparse it after change. 2004-10-06 Werner Koch * ccid-driver.c (ccid_open_reader): Store the vendor ID. (ccid_transceive_secure): New. (parse_ccid_descriptor): Workaround for an SCM reader problem. 2004-10-04 Werner Koch * ccid-driver.c (send_escape_cmd): New. 2004-09-30 Werner Koch * Makefile.am: Adjusted for gettext 0.14. * app-openpgp.c (do_sign): Add the error string to the verify failed messages. 2004-09-27 Werner Koch From gnupg 1.3 * app-openpgp.c: Made all strings translatable. (verify_chv3) [GNUPG_MAJOR_VERSION]: Make opt.allow_admin available for use in gnupg 2. (verify_chv3): Reimplemented countdown showing to use only functions from this module. Flush the CVH status cache on a successful read. (get_one_do): Hack to bypass the cache for cards versions > 1.0. (store_fpr): Store the creation date for card version > 1.0. * app-openpgp.c (app_openpgp_storekey): Call flush_cache. (get_cached_data): Move local data initialization to .. (app_select_openpgp): .. here. Read some flags for later use. (do_getattr): New read-only attribute EXTCAP. * apdu.c (open_pcsc_reader): Do not print empty reader string. * ccid-driver.c (do_close_reader): Factored some code out from ... (ccid_close_reader): ..here. (ccid_shutdown_reader): New. * apdu.c (apdu_shutdown_reader): New. (shutdown_ccid_reader): New. * apdu.c (open_ccid_reader): New arg PORTSTR. Pass it to ccid_open_reader. (apdu_open_reader): Pass portstr to open_ccid_reader. (apdu_open_reader): No fallback if a full CCID reader id has been given. * ccid-driver.c (ccid_get_reader_list): New. (ccid_open_reader): Changed API to take a string for the reader. Removed al the cruft for the libusb development vesion which seems not to be maintained anymore and there are no packages anyway. The stable library works just fine. (struct ccid_reader_id_s): Deleted and replaced everywhere by a simple string. (usb_get_string_simple): Removed. (bulk_in): Do valgrind hack here and not just everywhere. * ccid-driver.c (read_device_info): Removed. (make_reader_id, scan_or_find_devices): New. (ccid_open_reader): Simplified by make use of the new functions. (ccid_set_debug_level): New. Changed the macros to make use of it. It has turned out that it is often useful to enable debugging at runtime so I added this option. From gnupg 1.3 - David Shaw * app-openpgp.c (verify_chv3): Show a countdown of how many wrong admin PINs can be entered before the card is locked. * app-openpgp.c (get_cached_data): Avoid mallocing zero since it breaks us when using --enable-m-guard. * ccid-driver.c (usb_get_string_simple): Replacement function to work with older libusb. * ccid-driver.c (read_device_info): Fix segfault when usb device is not accessible. (ccid_open_reader): Allow working with an even older version of libusb (usb_busses global instead of usb_get_busses()). 2004-09-11 Werner Koch * app-openpgp.c (app_select_openpgp): Its app_munge_serialno and not app_number_serialno. 2004-08-20 Werner Koch * app.c (select_application): Fixed serial number extraction and added the BMI card workaround. (app_munge_serialno): New. * app-openpgp.c (app_select_openpgp): Try munging serialno. 2004-08-05 Werner Koch * scdaemon.c (main): New option --disable-application. * app.c (is_app_allowed): New. (select_application): Use it to check for disabled applications. * ccid-driver.h (CCID_DRIVER_ERR_ABORTED): New. * ccid-driver.c (ccid_open_reader): Support the stable 0.1 version of libusb. (ccid_get_atr): Handle short messages. * apdu.c (my_rapdu_get_status): Implemented. 2004-07-27 Moritz Schulte * apdu.c: Include . * Makefile.am: Use @DL_LIBS@ instead of -ldl. 2004-07-22 Werner Koch * Makefile.am: Make OpenSC lib link after libgcrypt. Do not link to pth. * apdu.c: Don't use Pth if we use OpenSC. * sc-investigate.c, scdaemon.c: Disable use of pth if OpenSC is used. * scdaemon.c (main): Bumbed thread stack size up to 512k. 2004-07-16 Werner Koch * apdu.c (reader_table_s): Add function pointers for the backends. (apdu_close_reader, apdu_get_status, apdu_activate) (send_apdu): Make use of them. (new_reader_slot): Intialize them to NULL. (dump_ccid_reader_status, ct_dump_reader_status): New. (dump_pcsc_reader_status): New. (open_ct_reader, open_pcsc_reader, open_ccid_reader) (open_osc_reader, open_rapdu_reader): Intialize function pointers. (ct_activate_card, ct_send_apdu, pcsc_send_apdu, osc_send_apdu) (error_string): Removed. Replaced by apdu_strerror. (get_ccid_error_string): Removed. (ct_activate_card): Remove the unused loop. (reset_ct_reader): Implemented. (ct_send_apdu): Activate the card if not yet done. (pcsc_send_apdu): Ditto. 2004-07-15 Werner Koch * ccid-driver.h: Add error codes. * ccid-driver.c: Implement more or less proper error codes all over the place. * apdu.c (apdu_send_direct): New. (get_ccid_error_string): Add some error code mappings. (send_apdu): Pass error codes along for drivers already supporting them. (host_sw_string): New. (get_ccid_error_string): Use above. (send_apdu_ccid): Reset the reader if it has not yet been done. (open_ccid_reader): Don't care if the ATR can't be read. (apdu_activate_card): New. (apdu_strerror): New. (dump_reader_status): Only enable it with opt.VERBOSE. * iso7816.c (map_sw): Add mappings for the new error codes. 2004-07-02 Werner Koch * apdu.c (open_ct_reader, open_pcsc_reader, open_ccid_reader) (reset_ccid_reader, open_osc_reader): Call dump_reader_status only in verbose mode. 2004-07-01 Werner Koch * sc-investigate.c: Initialize Pth which is now required. (interactive_shell): New command "readpk". * app-openpgp.c (do_getattr): Fix for sending CA-FPR. 2004-06-30 Werner Koch * app-openpgp.c (app_openpgp_readkey): Fixed check for valid exponent. 2004-06-18 Werner Koch * sc-investigate.c (my_read_line): Renamed from read_line. 2004-06-16 Werner Koch * apdu.c (osc_get_status): Fixed type in function name. Noted by Axel Thimm. Yes, I didn't tested it with OpenSC :-(. 2004-04-28 Werner Koch * app-openpgp.c (do_setattr): Sync FORCE_CHV1. 2004-04-27 Werner Koch * app-common.h: Do not include ksba.h for gnupg 1. 2004-04-26 Werner Koch * app-common.h: New members FNC.DEINIT and APP_LOCAL. * app.c (release_application): Call new deconstructor. * app-openpgp.c (do_deinit): New. (get_cached_data, flush_cache_item, flush_cache_after_error) (flush_cache): New. (get_one_do): Replaced arg SLOT by APP. Make used of cached data. (verify_chv2, verify_chv3): Flush some cache item after error. (do_change_pin): Ditto. (do_sign): Ditto. (do_setattr): Flush cache item. (do_genkey): Flush the entire cache. (compare_fingerprint): Use cached data. * scdaemon.c (main): Do the last change the usual way. This is so that we can easily test for versioned config files above. 2004-04-26 Marcus Brinkmann * scdaemon.c (main): For now, always print default filename for --gpgconf-list, and never /dev/null. 2004-04-21 Werner Koch * command.c (scd_update_reader_status_file): Send a signal back to the client. (option_handler): Parse the new event-signal option. * scdaemon.c (handle_signal): Do not use SIGUSR{1,2} anymore for changing the verbosity. 2004-04-20 Werner Koch * command.c (scd_update_reader_status_file): Write status files. * app-help.c (app_help_read_length_of_cert): Fixed calculation of R_CERTOFF. * pcsc-wrapper.c: New. * Makefile.am (pkglib_PROGRAMS): Install it here. * apdu.c (writen, readn): New. (open_pcsc_reader, pcsc_send_apdu, close_pcsc_reader): Use the pcsc-wrapper if we are using Pth. (apdu_send_le): Reinitialize RESULTLEN. Handle SW_EOF_REACHED like SW_SUCCESS. 2004-04-19 Werner Koch * ccid-driver.c (parse_ccid_descriptor): Store some of the reader features away. New arg HANDLE (read_device_info): New arg HANDLE. Changed caller. (bulk_in): Handle time extension requests. (ccid_get_atr): Setup parameters and the IFSD. (compute_edc): New. Factored out code. (ccid_transceive): Use default NADs when required. 2004-04-14 Werner Koch * scdaemon.h (server_control_s): Add member READER_SLOT. * scdaemon.c (scd_init_default_ctrl): Initialize READER_SLOT to -1. * command.c (open_card): Reuse an open slot. (reset_notify): Just reset the slot if supported by the reader. (do_reset): Factored code from above out. (scd_command_handler): Use it for cleanup. * apdu.h: New pseudo stati SW_HOST_NOT_SUPPORTED, SW_HOST_LOCKING_FAILED and SW_HOST_BUSY. * iso7816.c (map_sw): Map it. * ccid-driver.c (ccid_slot_status): Add arg STATUSBITS. * apdu.c (apdu_get_status): New. (ct_get_status, pcsc_get_status, ocsc_get_status): New stubs. (get_status_ccid): New. (apdu_reset): New. (reset_ct_reader, reset_pcsc_reader, reset_osc_reader): New stubs. (reset_ccid_reader): New. (apdu_enum_reader): New. * apdu.c (lock_slot, trylock_slot, unlock_slot): New helpers. (new_reader_slot) [USE_GNU_PTH]: Init mutex. (apdu_reset, apdu_get_status, apdu_send_le): Run functions in locked mode. * command.c (scd_update_reader_status_file): New. * scdaemon.c (handle_tick): Call it. 2004-04-13 Werner Koch * scdaemon.c: Convert to a Pth application. (handle_signal, ticker_thread, handle_tick): New. (main): Fire up the ticker thread in server mode. 2004-03-23 Werner Koch * scdaemon.c (main) : Fixed output for pcsc_driver. 2004-03-17 Werner Koch * tlv.c (parse_ber_header): Do not check for tag overflow - it does not make sense. Simplified the check for length overflow. * scdaemon.c (main) : Fixed default value quoting. 2004-03-16 Werner Koch * app-dinsig.c: Implemented. Based on app-nks.c and card-dinsig.c * app-nks.c (get_length_of_cert): Removed. * app-help.c: New. (app_help_read_length_of_cert): New. Code taken from above. New optional arg R_CERTOFF. * card-dinsig.c: Removed. * card.c (card_get_serial_and_stamp): Do not bind to the old and never finsiged card-dinsig.c. * iso7816.c (iso7816_read_binary): Allow for an NMAX > 254. 2004-03-11 Werner Koch * scdaemon.h (out_of_core): Removed. Replaced callers by standard gpg_error function. * apdu.c, iso7816.c, ccid-driver.c [GNUPG_SCD_MAIN_HEADER]: Allow to include a header defined by the compiler. This helps us to reuse the source in other software. 2004-03-10 Werner Koch * iso7816.c (iso7816_read_record): New arg SHORT_EF. Changed all callers. 2004-02-18 Werner Koch * sc-investigate.c (main): Setup the used character set. * scdaemon.c (main): Ditto. * scdaemon.c (set_debug): New. Add option --debug-level. (main): Add option --gpgconf-list. 2004-02-12 Werner Koch * Makefile.am: Include cmacros.am for common flags. 2004-01-29 Werner Koch * command.c (reset_notify): Release the application context and close the reader. 2004-01-28 Werner Koch * iso7816.c (iso7816_manage_security_env): New. (iso7816_decipher): Add PADIND argument. 2004-01-27 Werner Koch * command.c (cmd_readcert, cmd_readkey): Work on a copy of LINE. * app-common.h (app_ctx_s): Added readcert field. * app.c (app_readcert): New. * tlv.c (parse_ber_header): Added; taken from libksba. 2004-01-26 Werner Koch * card.c (map_sc_err): Use SCD as the error source. * command.c (open_card): ADD arg NAME to allow requesting a specific application. Changed all callers. (cmd_serialno): Allow optional argument to select the desired application. * app-nks.c: New. * scdaemon.h (opt): Add READER_PORT. * scdaemon.c (main): Set it here. * app.c (app_set_default_reader_port): Removed. (select_application): Add NAME arg and figure out a default serial number from the GDO. Add SLOT arg and remove all reader management. (release_application): New. (app_write_learn_status): Output an APPTYPE status line. * command.c (open_card): Adapt for select_application change. * app-openpgp.c (app_select_openpgp): Removed SN and SNLEN args and set it directly. Changed all callers. 2004-01-25 Werner Koch * iso7816.c (iso7816_select_application): P1 kludge for OpenPGP card. * app-openpgp.c (find_tlv): Factor out this function to .. * tlv.c, tlv.h: .. new. * scdaemon.h: Introduced app_t and ctrl_t as the new types for APP and CTRL. 2004-01-21 Werner Koch * apdu.c (apdu_send_le): Treat SW_EOF_REACHED as a warning. 2004-01-20 Werner Koch * iso7816.c (iso7816_read_binary): New. (iso7816_select_file): New. (iso7816_list_directory): New. * sc-investigate.c: Add option -i. (select_app, read_line, interactive_shell): New. 2004-01-16 Werner Koch * apdu.h: Add SW_FILE_NOT_FOUND. * iso7816.c (map_sw): Map it to GPG_ERR_ENOENT. * iso7816.c (iso7816_select_file): New. * app-dinsig.c: New file w/o any real code yet. * Makefile.am (scdaemon_SOURCES,sc_investigate_SOURCES): Add file. * sc-investigate.c: Add option --disable-ccid. 2003-12-19 Werner Koch * apdu.c (apdu_send_le): Send a get_response with the indicated length and not the 64 bytes we used for testing. * app-openpgp.c (verify_chv2, verify_chv3, do_sign): Check the minimum length of the passphrase, so that we don't need to decrement the retry counter. 2003-12-17 Werner Koch * card-p15.c (p15_enum_keypairs): Replaced KRC by RC. * card-dinsig.c (dinsig_enum_keypairs): Ditto. 2003-12-16 Werner Koch * scdaemon.c (main): Set the prefixes for assuan logging. 2003-11-17 Werner Koch * scdaemon.c, scdaemon.h: New options --allow-admin and --deny-admin. * app-openpgp.c (verify_chv3): Check it here. 2003-11-12 Werner Koch Adjusted for API changes in Libksba. 2003-10-30 Werner Koch * apdu.c (close_ct_reader, close_pcsc_reader): Implemented. (get_ccid_error_string): New. Not very useful messages, though. 2003-10-25 Werner Koch * ccid-driver.c (ccid_open_reader): Return an error if no USB devices are found. * command.c (cmd_genkey, cmd_passwd): Fixed faulty use of !spacep(). * apdu.c (apdu_open_reader): Hacks for PC/SC under Windows. 2003-10-20 Werner Koch * command.c (cmd_checkpin): New. (register_commands): Add command CHECKPIN. * app.c (app_check_pin): New. * app-openpgp.c (check_against_given_fingerprint): New. Factored out that code elsewhere. (do_check_pin): New. 2003-10-10 Werner Koch * ccid-driver.c (ccid_close_reader): New. * apdu.c (close_ccid_reader, close_ct_reader, close_csc_reader) (close_osc_reader, apdu_close_reader): New. Not all are properly implemented yet. 2003-10-09 Werner Koch * ccid-driver.c (ccid_transceive): Add T=1 chaining for sending. 2003-10-08 Werner Koch * app-openpgp.c (do_getattr): Support SERIALNO and AID. 2003-10-01 Werner Koch * ccid-driver.c: Detect GnuPG 1.3 and include appropriate files. * apdu.c: Ditto. * app-openpgp.c: Ditto. * iso7816.c: Ditto. (generate_keypair): Renamed to .. (do_generate_keypair): .. this. * app-common.h [GNUPG_MAJOR_VERSION]: New. * iso7816.h [GNUPG_MAJOR_VERSION]: Include cardglue.h 2003-09-30 Werner Koch * command.c (cmd_getattr): New command GETATTR. * app.c (app_setattr): New. (do_getattr): New. (do_learn_status): Reimplemented in terms of do_getattr. * app-openpgp.c (do_change_pin): Make sure CVH1 and CHV2 are always synced. (verify_chv2, verify_chv3): New. Factored out common code. (do_setattr, do_sign, do_auth, do_decipher): Change the names of the prompts to match that we have only 2 different PINs. (app_select_openpgp): Check whether the card enforced CHV1. (convert_sig_counter_value): New. Factor out code from get_sig_counter. 2003-09-28 Werner Koch * app-openpgp.c (dump_all_do): Use gpg_err_code and not gpg_error. 2003-09-19 Werner Koch * ccid-driver.c (parse_ccid_descriptor): New. (read_device_info): New. (ccid_open_reader): Check that the device has all required features. 2003-09-06 Werner Koch * scdaemon.c (main): --pcsc-driver again defaults to pcsclite. David Corcoran was so kind to remove the GPL incompatible advertisng clause from pcsclite. * apdu.c (apdu_open_reader): Actually make pcsc-driver option work. 2003-09-05 Werner Koch * ccid-driver.c: More work, data can now actually be retrieved. * ccid-driver.c, ccid-driver.h: Alternativley allow use under BSD conditions. 2003-09-02 Werner Koch * scdaemon.c, scdaemon.h: New option --pcsc-ccid. * ccid-driver.c, ccid-driver.h: New but far from being useful. * Makefile.am: Add above. * apdu.c: Add support for that ccid driver. 2003-08-26 Timo Schulz * apdu.c (new_reader_slot): Only set 'is_osc' when OpenSC is used. 2003-08-25 Werner Koch * command.c (cmd_setattr): Use a copy of LINE. (cmd_genkey): Use a copy of KEYNO. (cmd_passwd): Use a copy of CHVNOSTR. (cmd_pksign, cmd_pkauth, cmd_pkdecrypt): s/strdup/xtrystrdup/. 2003-08-19 Werner Koch * scdaemon.c, scdaemon.h: New option --pcsc-driver. * apdu.c (apdu_open_reader): Use that option here instead of a hardcoded one. 2003-08-18 Werner Koch * Makefile.am: Add OPENSC_LIBS to all programs. * scdaemon.c, scdaemon.h: New option --disable-opensc. * card.c (card_open): Implement it. * apdu.c (open_osc_reader, osc_send_apdu): New. (apdu_open_reader) [HAVE_OPENSC]: Use the opensc driver if not disabled. (error_string) [HAVE_OPENSC]: Use sc_strerror. (send_apdu) [HAVE_OPENSC]: Call osc_apdu_send. * card-p15.c (p15_enum_keypairs, p15_prepare_key): Adjusted for libgpg-error. 2003-08-14 Timo Schulz * apdu.c (ct_activate_card): Change the code a little to avoid problems with other readers. * Always use 'dynload.h' instead of 'dlfcn.h'. 2003-08-05 Werner Koch * app-openpgp.c (dump_all_do): Don't analyze constructed DOs after an error. 2003-08-04 Werner Koch * app.c (app_set_default_reader_port): New. (select_application): Use it here. * scdaemon.c (main): and here. * sc-copykeys.c: --reader-port does now take a string. * sc-investigate.c, scdaemon.c: Ditto. * apdu.c (apdu_open_reader): Ditto. Load pcsclite if no ctapi driver is configured. Always include code for ctapi. (new_reader_slot): Don't test for already used ports and remove port arg. (open_pcsc_reader, pcsc_send_apdu, pcsc_error_string): New. (apdu_send_le): Changed RC to long to cope with PC/SC. * scdaemon.c, scdaemon.h: New option --ctapi-driver. * sc-investigate.c, sc-copykeys.c: Ditto. 2003-07-31 Werner Koch * Makefile.am (scdaemon_LDADD): Added INTLLIBS. 2003-07-28 Werner Koch * app-openpgp.c (do_setattr): Change implementation. Allow all useful DOs. 2003-07-27 Werner Koch Adjusted for gcry_mpi_print and gcry_mpi_scan API change. 2003-07-24 Werner Koch * app-openpgp.c (do_learn_status): Print more status information. (app_select_openpgp): Store the card version. (store_fpr): Add argument card_version and fix DOs for old cards. (app_openpgp_storekey): Likewise. 2003-07-23 Werner Koch * command.c (cmd_pkauth): New. (cmd_setdata): Check whether data was given at all to avoid passing 0 to malloc. * app.c (app_auth): New. * app-openpgp.c (do_auth): New. 2003-07-22 Werner Koch * command.c (cmd_passwd): New. * app.c (app_change_pin): New. * app-openpgp.c (do_change_pin): New. * iso7816.c (iso7816_reset_retry_counter): Implemented. * sc-investigate.c (main): New option --gen-random. * iso7816.c (iso7816_get_challenge): Don't create APDUs with a length larger than 255. 2003-07-17 Werner Koch * command.c (cmd_random): New command RANDOM. * iso7816.c (map_sw): New. Use it in this file to return meaningful error messages. Changed all public fucntions to return a gpg_error_t. (iso7816_change_reference_data): New. * apdu.c (apdu_open_reader): Use faked status words for soem system errors. 2003-07-16 Werner Koch * apdu.c (apdu_send_simple): Use apdu_send_le so that we can specify not to send Le as it should be. 2003-07-15 Werner Koch * Makefile.am: Add sc-copykeys program. * sc-copykeys.c: New. * app-openpgp.c (app_openpgp_storekey): New. (app_openpgp_cardinfo): New. (count_bits): New. (store_fpr): And use it here to get the actual length in bit. 2003-07-03 Werner Koch * app-openpgp.c (do_setattr): Add setting of the URL. (app_select_openpgp): Dump card data only in very verbose mode. (do_decipher): New. 2003-07-02 Werner Koch * app-openpgp.c (get_sig_counter): New. (do_sign): Print the signature counter and enable the PIN callback. (do_genkey): Implement the PIN callback. 2003-07-01 Werner Koch * app-openpgp.c (store_fpr): Fixed fingerprint calculation. 2003-06-26 Werner Koch * app-openpgp.c (find_tlv): Fixed length header parsing. * app.c (app_genkey): New. * command.c (cmd_genkey): New. 2003-06-25 Werner Koch * command.c (percent_plus_unescape): New. (cmd_setattr): New. 2003-06-24 Werner Koch * command.c (send_status_info): New. * app-openpgp.c (app_select_openpgp): Replace SLOT arg by APP arg and setup the function pointers in APP on success. Changed callers. * app.c: New. * app-common.h: New. * scdaemon.h (APP): New type to handle applications. (server_control_s): Add an APP context field. * command.c (cmd_serialno): Handle applications. (cmd_pksign): Ditto. (cmd_pkdecrypt): Ditto. (reset_notify): Ditto. (cmd_learn): For now return error for application contexts. (cmd_readcert): Ditto. (cmd_readkey): Ditto. 2003-06-04 Werner Koch * card.c (map_sc_err): Renamed gpg_make_err to gpg_err_make. Renamed error codes from INVALID to INV and removed _ERROR suffixes. 2003-06-03 Werner Koch Changed all error codes in all files to the new libgpg-error scheme. * scdaemon.h: Include gpg-error.h and errno.h * card.c (map_sc_err): Use unknown for the error source. * Makefile.am: Link with libgpg-error 2003-05-14 Werner Koch * atr.c, atr.h: New. * sc-investigate.c: Dump the ATR in a human readable format. 2003-05-08 Werner Koch * scdaemon.h (DBG_CARD_IO_VALUE): New. * sc-investigate.c: New. * scdaemon.c (main): Removed --print-atr option. * iso7816.c, iso7816.h, app-openpgp.c: New. 2003-04-29 Werner Koch * scdaemon.c: New options --print-atr and --reader-port * apdu.c, apdu.h: New * card.c, card-p15.c, card-dinsig.c: Allow build without OpenSC. * Makefile.am (LDFLAGS): Removed. * command.c (register_commands): Adjusted for new Assuan semantics. 2002-08-21 Werner Koch * scdaemon.c (main): New option --daemon so that the program is not accidently started in the background. 2002-08-16 Werner Koch * scdaemon.c: Include i18n.h. * card-common.h (struct p15_private_s): Forward declaration. Add it to card_ctx_s. * card.c (card_close): Make sure private data is released. (card_enum_certs): New. * card-p15.c (p15_release_private_data): New. (init_private_data): New to work around an OpenSC weirdness. (p15_enum_keypairs): Do an OpenSC get_objects only once. (p15_enum_certs): New. (card_p15_bind): Bind new function. * command.c (cmd_learn): Return information about the certificates. 2002-08-09 Werner Koch * card.c (card_get_serial_and_stamp): Use the tokeinfo serial number as a fallback. Add a special prefix for serial numbers. 2002-07-30 Werner Koch Changes to cope with OpenSC 0.7.0: * card.c: Removed the check for the packed opensc version. Changed include file names of opensc. (map_sc_err): Adjusted error codes for new opensc version. * card-p15.c: Changed include filename of opensc. * card-dinsig.c: Ditto. * card-p15.c (p15_decipher): Add flags argument to OpenSC call. 2002-07-24 Werner Koch * card.c (find_simple_tlv, find_iccsn): New. (card_get_serial_and_stamp): Improved serial number parser. 2002-06-27 Werner Koch * scdaemon.c (main): Use GNUPG_DEFAULT_HOMEDIR constant. 2002-06-15 Werner Koch * card-dinsig.c: Documented some stuff from the DIN norm. 2002-04-15 Werner Koch * command.c (cmd_pksign, cmd_pkdecrypt): Use a copy of the key ID. 2002-04-12 Werner Koch * scdaemon.c: New option --debug-sc N. * card.c (card_open): set it here. * card-p15.c (p15_prepare_key): Factored out common code from ... (p15_sign, p15_decipher): here and made the decryption work the regular way. 2002-04-10 Werner Koch * card.c (card_open): Return immediately when no reader is available. 2002-03-27 Werner Koch * card.c (card_open, card_close): Adjusted for changes in OpenSC. 2002-03-10 Werner Koch * card-p15.c, card-dinsig.c, card-common.h: New. * card.c: Factored most code out to the new modules, so that we can better support different types of card applications. 2002-01-26 Werner Koch * scdaemon.c scdaemon.h, command.c: New. Based on the code from the gpg-agent. Copyright 2002, 2003, 2004, 2005, 2007, 2008 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/scd/Makefile.am b/scd/Makefile.am index ae623ace8..923ebfee0 100644 --- a/scd/Makefile.am +++ b/scd/Makefile.am @@ -1,69 +1,69 @@ # Copyright (C) 2002, 2003, 2005 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 3 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, see . ## Process this file with automake to produce Makefile.in bin_PROGRAMS = scdaemon if ! HAVE_W32_SYSTEM libexec_PROGRAMS = gnupg-pcsc-wrapper endif AM_CPPFLAGS = -I$(top_srcdir)/gl -I$(top_srcdir)/intl -I$(top_srcdir)/common include $(top_srcdir)/am/cmacros.am AM_CFLAGS = $(LIBGCRYPT_CFLAGS) \ $(KSBA_CFLAGS) $(LIBASSUAN_CFLAGS) $(PTH_CFLAGS) card_apps = app-openpgp.c app-nks.c app-dinsig.c app-p15.c app-geldkarte.c scdaemon_SOURCES = \ scdaemon.c scdaemon.h \ command.c \ apdu.c apdu.h \ ccid-driver.c ccid-driver.h \ iso7816.c iso7816.h \ app.c app-common.h app-help.c $(card_apps) -scdaemon_LDADD = $(libcommonpth) ../jnlib/libjnlib.a ../gl/libgnu.a \ +scdaemon_LDADD = $(libcommonpth) ../gl/libgnu.a \ $(LIBGCRYPT_LIBS) $(KSBA_LIBS) $(LIBASSUAN_LIBS) $(PTH_LIBS) \ $(LIBUSB_LIBS) $(GPG_ERROR_LIBS) \ $(LIBINTL) $(DL_LIBS) $(NETLIBS) $(LIBICONV) # Removed for now: We need to decide whether it makes sense to # continue it at all, given that gpg has now all required # functionality. #sc_copykeys_SOURCES = \ # sc-copykeys.c scdaemon.h \ # apdu.c apdu.h \ # ccid-driver.c ccid-driver.h \ # iso7816.c iso7816.h \ # atr.c atr.h \ # app.c app-common.h app-help.c $(card_apps) # #sc_copykeys_LDADD = \ # ../jnlib/libjnlib.a ../common/libcommon.a \ # ../common/libsimple-pwquery.a \ # $(LIBGCRYPT_LIBS) $(KSBA_LIBS) $(LIBASSUAN_LIBS) $(PTH_LIBS) \ # $(LIBUSB_LIBS) \ # -lgpg-error @LIBINTL@ @DL_LIBS@ # gnupg_pcsc_wrapper_SOURCES = pcsc-wrapper.c gnupg_pcsc_wrapper_LDADD = $(DL_LIBS) gnupg_pcsc_wrapper_CFLAGS = diff --git a/sm/ChangeLog b/sm/ChangeLog index ba5047a82..104f6caaf 100644 --- a/sm/ChangeLog +++ b/sm/ChangeLog @@ -1,2748 +1,2754 @@ +2010-03-10 Werner Koch + + * Makefile.am (common_libs): Remove libjnlib.a. Change order. + + * gpgsm.h: Remove "estream.h". + 2010-03-08 Werner Koch * certreqgen.c (gpgsm_genkey): Change OUT_FP to an estream_t OUT_STREAM. * certreqgen-ui.c (gpgsm_gencertreq_tty): ditto. * server.c (cmd_genkey): Close IN_STREAM. * server.c (cmd_encrypt, cmd_decrypt, cmd_verify, cmd_sign): Avoid dup call by using es_fdopen_nc. (do_listkeys): Use es_fdopen_nc instead of dup and es_fdopen. (cmd_export): Ditto. (cmd_genkey): Ditto. * export.c (popen_protect_tool): Change OUTFILE to an estream_t. (export_p12): Change OUTFP and arg RETFP to an estream_t. (gpgsm_p12_export): Change DATAFP to an estream_t. (gpgsm_export): Remove arg FP. * import.c (import_one): Change CERTFP and arg FP to an estream_t. (popen_protect_tool): Ditto for OUTFILE. (parse_p12): Change CERTFP to an estream_t. * sign.c (hash_data, hash_and_copy_data): Use estream. (gpgsm_sign): Change arg OUT_FP to an estream_t. * verify.c (gpgsm_verify): Rename FP to IN_FP. Change FP and arg OUT_FP to an estream_t. (hash_data): Use estream. * base64.c (struct reader_cb_parm_s): Change FP to an estream_t. (gpgsm_create_reader): Ditto. (simple_reader_cb, base64_reader_cb): Adjust accordingly. * decrypt.c (gpgsm_decrypt): Change OUT_FP and IN_FP to an estream_t. * encrypt.c (gpgsm_encrypt): Change OUT_FP to an estream_t. Ditto for DATA_FD. (encrypt_cb): Use estream. * gpgsm.c (main) : Use estream functions. (main) : Use open_es_fwrite. 2009-12-14 Werner Koch * server.c (cmd_passwd): New. (register_commands): Register new command. 2009-12-10 Werner Koch * gpgsm.c: Add option --ignore-cert-extension. * gpgsm.h (opt): Add field IGNORED_CERT_EXTENSIONS. * certchain.c (unknown_criticals): Handle ignored extensions, 2009-12-08 Werner Koch * keydb.c (keydb_search_kid): Fix code even that it is not used. (classify_user_id): Adjust for change of u.kid type. (keydb_classify_name): Replace GPG_ERR_INV_NAME by GPG_ERR_INV_USER_ID. (keydb_classify_name): Remove. Replace all callers by classify_user_id. 2009-12-08 Marcus Brinkmann * call-dirmngr.c (start_dirmngr_ext): Convert posix fd to assuan fd. 2009-12-03 Werner Koch * gpgsm.c (set_debug): Allow for numerical debug leveles. Print active debug flags. 2009-12-02 Werner Koch * verify.c (gpgsm_verify): Add audit info on hash algorithms. * sign.c (gpgsm_sign): Add audit log calls. (hash_data): Return an error indicator. 2009-12-01 Werner Koch * decrypt.c (gpgsm_decrypt): Add audit log calls. * gpgsm.c: New option --html-audit-log. 2009-11-25 Marcus Brinkmann * server.c (gpgsm_server): Use assuan_fd_t and assuan_fdopen on fds. 2009-11-23 Werner Koch * gpgsm.c (main) : Add key "default_pubkey_algo". 2009-11-10 Marcus Brinkmann * server.c (cmd_getauditlog): Don't dup FD for es_fdopen_nc as this leaks the FD here. 2009-11-05 Marcus Brinkmann * call-dirmngr.c (start_dirmngr_ext): Update use of assuan_pipe_connect and assuan_socket_connect. 2009-11-04 Werner Koch * certreqgen.c (proc_parameters): Change fallback key length to 2048. * server.c (register_commands): Add help arg to assuan_register_command. Provide help strings for all commands. 2009-11-02 Marcus Brinkmann * server.c (reset_notify, input_notify, output_notify): Update to new assuan interface. (register_commands): Use assuan_handler_t. * call-agent.c (membuf_data_cb, default_inq_cb) (inq_ciphertext_cb, scd_serialno_status_cb) (scd_keypairinfo_status_cb, istrusted_status_cb) (learn_status_cb, learn_cb, keyinfo_status_cb): Return gpg_error_t. 2009-10-16 Werner Koch * gpgsm.c (default_include_certs): Change to -2. (DEFAULT_INCLUDE_CERTS): New. (DEFAULT_CIPHER_ALGO): New. Use instead of hardcoded "3DES". 2009-09-30 Werner Koch * gpgsm.c (main): Remove obsolete GCRYCTL_DISABLE_INTERNAL_LOCKING. 2009-09-23 Marcus Brinkmann * gpgsm.c (main): Update to new assuan API. * server.c: Include "gpgsm.h" before due to check for GPG_ERR_SOURCE_DEFAULT and assuan.h now including gpg-error.h. (option_handler, cmd_recipient, cmd_signer, cmd_encrypt) (cmd_decrypt, cmd_verify, cmd_sign, cmd_import, cmd_export) (cmd_delkeys, cmd_message, cmd_listkeys, cmd_dumpkeys) (cmd_listsecretkeys, cmd_dumpsecretkeys, cmd_genkey) (cmd_getauditlog, cmd_getinfo): Return gpg_error_t instead of int. (register_commands): Same for member HANDLER in table. (gpgsm_server): Allocate assuan context before starting server. * sm/call-dirmngr.c: * call-dirmngr.c (prepare_dirmngr): Check for CTX and error before setting LDAPSERVER. (start_dirmngr_ext): Allocate assuan context before starting server. (inq_certificate, isvalid_status_cb, lookup_cb, lookup_status_cb) (run_command_cb, run_command_inq_cb, run_command_status_cb): Return gpg_error_t instead of int. 2009-08-06 Werner Koch * sign.c (gpgsm_sign): Print INV_SNDR for a bad default key. * server.c (cmd_signer): Remove unneeded case for -1. Send INV_SGNR. Use new map function. (cmd_recipient): Use new map function. * gpgsm.c (do_add_recipient): Use new map function for INV_RECP. (main): Ditto. Also send INV_SGNR. 2009-07-30 Werner Koch * call-agent.c (learn_cb): Do not store as ephemeral. 2009-07-29 Marcus Brinkmann * keylist.c (print_capabilities): Print a trailing colon. 2009-07-23 Werner Koch * certchain.c (is_cert_still_valid): Emit AUDIT_CRL_CHECK. 2009-07-07 Werner Koch * server.c (command_has_option): New. (cmd_getinfo): Add subcommand "cmd_has_option". (cmd_import): Implement option --re-import. * import.c (gpgsm_import): Add arg reimport_mode. (reimport_one): New. * gpgsm.h: Include session-env.h. (opt): Add field SESSION_ENV. Remove obsolete fields. * server.c (option_handler): Rewrite setting of option fields. Replace strdup by xtrystrdup. * gpgsm.c (set_opt_session_env): New. (main): Use it for oDisplay, oTTYname, oTTYtype and oXauthority. * call-agent.c (start_agent): Adjust start_new_gpg_agent for changed args. * misc.c (setup_pinentry_env): Use new session_env stuff. 2009-07-02 Werner Koch * certreqgen-ui.c (gpgsm_gencertreq_tty): Allow using a key from a card. * call-agent.c (gpgsm_agent_scd_serialno) (scd_serialno_status_cb, store_serialno): New. (scd_keypairinfo_status_cb, gpgsm_agent_scd_keypairinfo): New. 2009-07-01 Werner Koch * certreqgen-ui.c (check_keygrip): New. (gpgsm_gencertreq_tty): Allow using an existing key. * gpgsm.c (open_es_fread): New. (main) : Implement --batch mode. 2009-06-24 Werner Koch * call-dirmngr.c (pattern_from_strlist): Remove dead assignment of N. * sign.c (gpgsm_sign): Remove dead assignment. * certreqgen.c (create_request): Assign GPG_ERR_BUG to RC. Reported by Fabian Keil. 2009-05-27 Werner Koch * encrypt.c (encrypt_dek): Make use of make_canon_sexp. 2009-05-18 Werner Koch * server.c (option_handler): New option "no-encrypt-to". (cmd_encrypt): Make use of it. * gpgsm.c: Remove not implemented --verify-files. 2009-04-02 Werner Koch * keylist.c (list_cert_std): Print card serial number. 2009-04-01 Werner Koch * export.c (popen_protect_tool): Add command line option --agent-program and pass flag bit 6. * import.c (popen_protect_tool): Ditto. 2009-03-26 Werner Koch * gpgsm.c (main): s/def_digest_string/forced_digest_algo/ and activate the --digest-algo option. * gpgsm.h (struct opt): s/def_digest_algo/forced_digest_algo/. * sign.c (gpgsm_sign): Implement --digest-algo. * sign.c (MAX_DIGEST_LEN): Change to 64. * call-agent.c (gpgsm_agent_marktrusted): Format the issuer name. 2009-03-25 Werner Koch * decrypt.c (gpgsm_decrypt): Print ENC_TO and NO_SECKEY stati. Fixes bug#1020. * fingerprint.c (gpgsm_get_short_fingerprint): Add arg R_HIGH and change all callers. 2009-03-23 Werner Koch * delete.c (delete_one): Also delete ephemeral certificates if specified uniquely. 2009-03-20 Werner Koch * keylist.c (list_internal_keys): Set released cert to NULL. * call-agent.c (learn_status_cb): New. (gpgsm_agent_learn): Use it. (learn_cb): Send a progress for every certificate. 2009-03-18 Werner Koch * gpgsm.h (struct opt): Move field WITH_EPHEMERAL_KEYS to struct server_control_s. * gpgsm.c (main): Change accordingly. * keylist.c (list_internal_keys): Ditto. * server.c (option_handler): Add "with-ephemeral-keys". 2009-03-12 Werner Koch * certdump.c (gpgsm_dump_time): Remove. * certdump.c, verify.c, certchain.c * gpgsm.c: s/gpgsm_dump_time/dump_isotime/. 2009-03-06 Werner Koch * call-agent.c (gpgsm_agent_keyinfo, keyinfo_status_cb): New. * keylist.c (list_cert_colon): Print card S/N. * keylist.c (list_internal_keys): Always list ephemeral keys if specified by keygrip or fingerprint. (list_cert_raw): Always show ephemeral flag. * export.c (gpgsm_export): Export ephemeral keys if specified by keygrip. 2009-02-09 Werner Koch * gpgsm.c (main): Change default cipher back to 3DES. 2009-01-12 Werner Koch * keylist.c (print_utf8_extn_raw): Cast printf precision argument. 2009-01-08 Werner Koch * fingerprint.c (gpgsm_get_keygrip_hexstring): Add error detection. 2008-12-10 Werner Koch * gpgsm.c (our_cipher_test_algo): Use the GCRY constants as we now require 1.4. (our_md_test_algo): Ditto. Add SHA224. (main) : Update default cipher algo. 2008-12-09 Werner Koch * gpgsm.c (main): Call i18n_init before init_common_subsystems. 2008-12-05 Werner Koch * certreqgen.c (create_request): Provide a custom prompt for the signing. * certdump.c (gpgsm_format_keydesc): Remove debug output. (gpgsm_format_keydesc): Remove saving of errno as xfree is supposed not to change it. Use the new percent_plus_escape function which also fixes the issue that we did not escaped a percent in the past. 2008-11-18 Werner Koch * gpgsm.c (make_libversion): New. (my_strusage): Use new function. (build_lib_list): Remove. 2008-11-13 Werner Koch * gpgsm.c: Remove all unused options. Use ARGPARSE macros. 2008-10-28 Werner Koch * certdump.c (gpgsm_format_keydesc): Use xtryasprintf and xfree. (gpgsm_es_print_name): Factor code out to ... (gpgsm_es_print_name2): New function. (gpgsm_format_name2, format_name_writer): Use estream so that it works on all platforms. (format_name_writer): Fix reallocation bug. 2008-10-23 Werner Koch * import.c (popen_protect_tool): Add arg CTRL and assure that the agent is running. Pass a value for CTRL from all caller. * export.c (popen_protect_tool): Ditto. 2008-10-21 Werner Koch * call-dirmngr.c (inq_certificate_parm_s): Add field CTRL. (gpgsm_dirmngr_isvalid): Supply a value for that field. (inq_certificate): Add inquiry ISTRUSTED. * call-agent.c (gpgsm_agent_istrusted): Add new optional arg HEXFPR. Changed all callers. 2008-10-20 Werner Koch * keydb.c (keydb_locate_writable): Mark unused arg. (keydb_search_kid): Ditto. (keydb_clear_some_cert_flags): Ditto. * server.c (cmd_encrypt): Ditto. (cmd_decrypt, cmd_verify, cmd_import, cmd_genkey): Ditto. * call-agent.c (gpgsm_scd_pksign): Ditto. * call-dirmngr.c (release_dirmngr, release_dirmngr2) (run_command_cb): Ditto. * certlist.c (gpgsm_add_cert_to_certlist): Ditto. * certchain.c (find_up_dirmngr): Ditto. * keylist.c (print_key_data): Ditto. (list_cert_raw, list_cert_std): Ditto. * qualified.c (gpgsm_is_in_qualified_list): Ditto. * gpgsm.c (set_binary) [!W32]: Mark unused arg. 2008-10-17 Werner Koch * call-dirmngr.c (start_dirmngr, start_dirmngr2): Reset the lock flag on error. (release_dirmngr, release_dirmngr2): Replace asserts by error messages. (gpgsm_dirmngr_lookup): Replace assert by fatal error message. 2008-10-13 Werner Koch * gpgsm.c: Add alias --delete-keys. 2008-09-30 Werner Koch * server.c (cmd_getinfo): New subcommand agent-check. * call-agent.c (gpgsm_agent_send_nop): New. 2008-09-29 Werner Koch * certcheck.c (MY_GCRY_PK_ECDSA): Remove. Change users to GCRY_PK_ECDSA. * gpgsm.c (MY_GCRY_PK_ECDSA): Ditto. * sign.c (MY_GCRY_MD_SHA224): Remove change users to GCRY_MD_SHA224. 2008-09-04 Werner Koch * certdump.c (gpgsm_format_keydesc): Work around a mingw32 bug. 2008-09-03 Werner Koch * sign.c (MY_GCRY_MD_SHA224): New, so that we don't need libgcrypt 1.2. 2008-08-13 Werner Koch * keylist.c (list_cert_colon): Print 'f' for validated certs. 2008-08-08 Marcus Brinkmann * gpgsm.h (struct server_control_s): Remove member dirmngr_seen. * call-dirmngr.c (dirmngr2_ctx, dirmngr_ctx_locked) (dirmngr2_ctx_locked): New global variables. (prepare_dirmngr): Don't check dirmngr_seen anymore. (start_dirmngr): Move bunch of code to ... (start_dirmngr_ext): ... this new function. (release_dirmngr, start_dirmngr2, release_dirmngr2): New functions. (gpgsm_dirmngr_isvalid): Call release_dirmngr. (gpgsm_dirmngr_lookup): Call release_dirmngr. If dirmngr_ctx is locked, use dirmngr2_locked. (gpgsm_dirmngr_run_command): Call release_dirmngr. 2008-06-25 Werner Koch * sign.c (gpgsm_sign): Revamp the hash algorithm selection. * gpgsm.h (struct certlist_s): Add field HASH_ALGO and HASH_ALGO_OID. * qualified.c (gpgsm_qualified_consent): Fix double free. * gpgsm.c (main): Change default cipher algo to AES. * keylist.c (print_utf8_extn_raw, print_utf8_extn): New. (list_cert_raw, list_cert_std): Print the TeleSec restriction extension. 2008-06-23 Werner Koch * encrypt.c (encode_session_key): Replace xmalloc by xtrymalloc. Use bin2hex instead of open coding the conversion. (encrypt_dek): Init S_DATA. 2008-06-13 Marcus Brinkmann * call-dirmngr.c (prepare_dirmngr): Fix error code to ignore. 2008-06-12 Marcus Brinkmann * gpgsm.h (struct keyserver_spec): New struct. (opt): Add member keyserver. * gpgsm.c (keyserver_list_free, parse_keyserver_line): New functions. (main): Implement --keyserver option. * call-dirmngr.c (prepare_dirmngr): Send LDAPSERVER commands. 2008-05-20 Werner Koch * gpgsm.c (main) : Pass FP and not stdout to the export function. Reported by Marc Mutz. 2008-05-06 Werner Koch * keylist.c (list_external_keys): Ignore NOT FOUND error code. This is bug#907. 2008-04-23 Werner Koch * certchain.c (find_up): Make correct C89 code. Declare variable at the top of the block. Reported by Alain Guibert. 2008-04-09 Werner Koch * verify.c (gpgsm_verify): Print the message hash values on error. 2008-03-31 Werner Koch * call-dirmngr.c (start_dirmngr): Use log_info instead of log_error when falling back to start dirmngr. 2008-03-20 Werner Koch * certlist.c (gpgsm_add_to_certlist): Always save the first subject and issuer. Initialize issuer with issuer and not with subject. (same_subject_issuer): Set issuer2 to issuer and not to subject. 2008-03-17 Werner Koch * certdump.c (my_funopen_hook_size_t): New. (format_name_writer): Use it. 2008-03-13 Werner Koch * certdump.c (gpgsm_fpr_and_name_for_status): Fix signed/unsigned char issue. (gpgsm_format_keydesc): Remove superfluous test. Add expire date to the prompt. 2008-02-18 Werner Koch * certchain.c (gpgsm_is_root_cert): Factor code out to ... (is_root_cert): New. Extend test for self-issued certificates signed by other CAs. (do_validate_chain, gpgsm_basic_cert_check) (gpgsm_walk_cert_chain): Use it here. * gpgsm.c: Add option --no-common-certs-import. * certchain.c (find_up_dirmngr, find_up, do_validate_chain) (check_cert_policy): Be more silent with --quiet. * gpgsm.c: Add option --disable-dirmngr. * gpgsm.h (opt): Add field DISABLE_DIRMNGR. * call-dirmngr.c (start_dirmngr): Implement option. 2008-02-14 Werner Koch * server.c (option_handler): Add option allow-pinentry-notify. (gpgsm_proxy_pinentry_notify): New. * call-agent.c (default_inq_cb): New. (gpgsm_agent_pksign, gpgsm_scd_pksign, gpgsm_agent_readkey) (gpgsm_agent_istrusted, gpgsm_agent_marktrusted) (gpgsm_agent_passwd, gpgsm_agent_get_confirmation): Call it. (struct cipher_parm_s, struct genkey_parm_s): Add field CTRL. (inq_ciphertext_cb): Test keyword and fallback to default_inq_cb. (inq_genkey_parms): Ditto. (start_agent): Tell agent to send us the pinentry notifications. 2008-02-13 Werner Koch * call-dirmngr.c (gpgsm_dirmngr_lookup): Add arg CACHE_ONLY. * keylist.c (list_external_keys): Pass false for new arg. * certchain.c (find_up_dirmngr): New. (find_up): Also try to read from the dirmngr cache. (find_up, find_up_external, gpgsm_walk_cert_chain) (gpgsm_basic_cert_check, allowed_ca): Add arg CTRL and changed all callers. * call-agent.c (struct learn_parm_s): Add field CTRL. (gpgsm_agent_learn): Set it. 2008-02-11 Werner Koch * server.c (cmd_getinfo): New. (gpgsm_server): Register GETINFO. 2008-01-29 Marcus Brinkmann * keylist.c (list_internal_keys): New variable lastcert. Use it to suppress duplicates which immediately follow each other. 2008-01-27 Werner Koch * import.c (popen_protect_tool): Set bit 7 in the flags for gnupg_spawn_process so that under W32 no window appears. * export.c (popen_protect_tool): Ditto. 2007-12-13 Werner Koch * gpgsm.c (main): Add option --extra-digest-algo. * gpgsm.h (struct): Add EXTRA_DIGEST_ALGO. * verify.c (gpgsm_verify): Use it. Use the hash algorithm from the signature value. 2007-12-11 Werner Koch * certchain.c (do_validate_chain): Log AUDIT_ROOT_TRUSTED. * server.c (cmd_sign, cmd_decrypt, cmd_encrypt): Start audit log. (cmd_recipient): Start audit session. * gpgsm.c (main): Revamp creation of the audit log. * gpgsm.h (struct server_control_s): Add AGENT_SEEN and DIRMNGR_SEEN. * call-agent.c (start_agent): Record an audit event. * call-dirmngr.c (start_dirmngr): Ditto. Add new arg CTRL and pass it from all callers. (prepare_dirmngr): New helper for start_dirmngr. * encrypt.c (gpgsm_encrypt): Add calls to audit_log. 2007-12-03 Werner Koch * gpgsm.c (main): Call gnupg_reopen_std. h2007-11-22 Werner Koch * server.c (cmd_getauditlog): New. (register_commands): Register GETAUDITLOG. 2007-11-19 Werner Koch * server.c (cmd_recipient, cmd_signer): Add error reason 11. * gpgsm.c (main): Print a warning if --audit-log is used. 2007-11-15 Werner Koch * gpgsm.h (struct): Add XAUTHORITY and PINENTRY_USER_DATA. * misc.c (setup_pinentry_env): Add XAUTHORITY and PINENTRY_USER_DATA. * gpgsm.c (main): New option --xauthority. * call-agent.c (start_agent): Adjust for changed start_new_gpg_agent. * server.c (option_handler): Ad the new options. 2007-11-07 Werner Koch * gpgsm.c (main): New option --audit-log. * server.c (option_handler): New option enable-audit-log. (start_audit_session): New. (cmd_verify): Create audit context. (gpgsm_server): Release the context. * gpgsm.h (struct server_control_s): Add member AUDIT, include audit.h. * certdump.c (gpgsm_format_sn_issuer): New. * verify.c (hash_data): Return an error code. (gpgsm_verify): Add calls to audit_log. * gpgsm.c (get_status_string): Remove. * gpgsm.h: Include status.h instead of errors.h. 2007-10-19 Werner Koch * qualified.c (gpgsm_qualified_consent): Use i18N-swicth functions. (gpgsm_not_qualified_warning): Ditto. * certdump.c (gpgsm_format_keydesc): Ditto. 2007-09-14 Werner Koch * gpgsm.c (build_lib_list): New. (my_strusage): Print lib info. 2007-08-24 Werner Koch * Makefile.am (common_libs): Swap libkeybox and jnlib. 2007-08-23 Werner Koch * certlist.c (gpgsm_certs_identical_p): New. (gpgsm_add_to_certlist): Ignore duplicate certificates in ambigious name detection. (gpgsm_find_cert): Ditto. * export.c (gpgsm_p12_export): Ditto. 2007-08-22 Werner Koch * certreqgen.c (create_request): Replace open coding by bin2hex. * certreqgen-ui.c (gpgsm_gencertreq_tty): Use es_fopenmem. 2007-08-21 Werner Koch * import.c (parse_p12): Use gnupg_tmpfile. * export.c (export_p12): Ditto. 2007-08-20 Werner Koch * certreqgen.c (read_parameters): Change FP to an estream_t. (gpgsm_genkey): Replace in_fd and in_stream by a estream_t. * server.c (cmd_genkey): Adjust for that. * certreqgen-ui.c (gpgsm_gencertreq_tty): Use es_open_memstream instead of a temporary file. 2007-08-14 Werner Koch * call-dirmngr.c (start_dirmngr): Use dirmngr_socket_name. change the way infostr is xstrdupped. * gpgsm.c (main) [W32]: Make --prefer-system-dirmngr a dummy under Windows. 2007-08-13 Werner Koch * gpgsm.c (do_add_recipient): Add RECP_REQUIRED and make error message depend on that. (main): Add avriable RECP_REQUIRED, set ift for encryption commands and pass it to do_add_recipient. (our_pk_test_algo, our_cipher_test_algo, our_md_test_algo): Implement. 2007-08-09 Werner Koch * gpgsm.c (main) [W32]: Enable CRL check by default. (main): Update the default control structure after reading the options. (gpgsm_parse_validation_model, parse_validation_model): New. (main): New option --validation-model. * certchain.c (gpgsm_validate_chain): Implement this option. * server.c (option_handler): Ditto. * certchain.c (is_cert_still_valid): Reformatted. Add arg FORCE_OCSP. Changed callers to set this flag when using the chain model. 2007-08-08 Werner Koch * certdump.c (gpgsm_print_serial): Fixed brown paper bag style bugs which prefixed the output with a 3A and cut it off at a 00. * keylist.c (list_cert_raw): Print the certificate ID first and rename "Serial number" to "S/N". (list_cert_std): Ditto. 2007-08-07 Werner Koch * gpgsm.c (main): Allow a string for --faked-system-time. 2007-08-06 Werner Koch Implementation of the chain model. * gpgsm.h (struct rootca_flags_s): Define new members VALID and CHAIN_MODEL. * call-agent.c (gpgsm_agent_istrusted): Mark ROOTCA_FLAGS valid. (istrusted_status_cb): Set CHAIN_MODEL. * certchain.c (gpgsm_validate_chain): Replace LM alias by LISTMODE and FP by LISTFP. (gpgsm_validate_chain): Factor some code out to ... (check_validity_period, ask_marktrusted): .. new. (check_validity_cm_basic, check_validity_cm_main): New. (do_validate_chain): New with all code from gpgsm_validate_chain. New arg ROOTCA_FLAGS. (gpgsm_validate_chain): Provide ROOTCA_FLAGS and fallback to chain model. Add RETFLAGS arg and changed all callers to pass NULL. Add CHECKTIME arg and changed all callers to pass a nil value. (has_validity_model_chain): New. * verify.c (gpgsm_verify): Check for chain model and return as part of the trust status. * gpgsm.h (VALIDATE_FLAG_NO_DIRMNGR): New. (VALIDATE_FLAG_NO_DIRMNGR): New. * call-dirmngr.c (gpgsm_dirmngr_isvalid): Use constant here. 2007-08-03 Werner Koch * keylist.c (list_cert_colon): Avoid duplicate listing of kludge uids. * verify.c (gpgsm_verify): Make STATUS_VERIFY return the hash and pk algo. * certcheck.c (gpgsm_check_cms_signature): Add arg R_PKALGO. 2007-08-02 Werner Koch * gpgsm.c (main): Factored GC_OPT_FLAGS out to gc-opt-flags.h. 2007-07-17 Werner Koch * gpgsm.c (main): Implement --default-key. (main) : Declare --default-key and --encrypt-to. 2007-07-16 Werner Koch * server.c (cmd_message): Use gnupg_fd_t to avoid dependecy on newer assuan versions. 2007-07-12 Werner Koch * gpgsm.c (check_special_filename): Use translate_sys2libc_fd_int when passing an int value. * server.c (cmd_encrypt, cmd_decrypt, cmd_verify, cmd_import) (cmd_export, cmd_message, cmd_genkey): Translate file descriptors. 2007-07-05 Werner Koch * Makefile.am (common_libs): Changed order of libs. 2007-07-04 Werner Koch * certchain.c (check_cert_policy): Remove extra checks for GPG_ERR_NO_VALUE. They are not needed since libksba 1.0.1. * keylist.c (print_capabilities, list_cert_raw, list_cert_std): Ditto. * certlist.c (cert_usage_p, cert_usage_p): Ditto. 2007-06-26 Werner Koch * gpgsm.c (main): Call gnupg_rl_initialize. * Makefile.am (gpgsm_LDADD): Add LIBREADLINE and libgpgrl.a. 2007-06-25 Werner Koch * gpgsm.c (check_special_filename): Use translate_sys2libc_fd and add new arg FOR_WRITE. Change callers to pass new arg. 2007-06-24 Werner Koch * gpgsm.c (open_es_fwrite): Avoid the dup by using the new es_fdopen_nc(). 2007-06-21 Werner Koch * certreqgen-ui.c: New. * gpgsm.c (main): Let --gen-key call it. * certreqgen.c (gpgsm_genkey): Add optional IN_STREAM arg and adjusted caller. * gpgsm.h (ctrl_t): Remove. It is now declared in ../common/util.h. * call-agent.c (start_agent): Factored almost all code out to ../common/asshelp.c. 2007-06-20 Werner Koch * call-agent.c (start_agent) [W32]: Start the agent on the fly. 2007-06-18 Marcus Brinkmann * gpgsm.c (main): Percent escape output of --gpgconf-list. 2007-06-14 Werner Koch * call-agent.c (start_agent): Use gnupg_module_name. * call-dirmngr.c (start_dirmngr): Ditto. * export.c (export_p12): Ditto. * import.c (parse_p12): Ditto. * gpgsm.c (run_protect_tool): Ditto. 2007-06-12 Werner Koch * gpgsm.c (main): Replace some calls by init_common_subsystems. (main): Use gnupg_datadir. * qualified.c (read_list): Use gnupg-datadir. 2007-06-11 Werner Koch * Makefile.am (common_libs): Use libcommaonstd macr. * gpgsm.c (main) [W32]: Call pth_init. 2007-06-06 Werner Koch * qualified.c (gpgsm_not_qualified_warning) [!ENABLE_NLS]: Do not define orig_codeset. * certdump.c (gpgsm_format_keydesc) [!ENABLE_NLS]: Do not define orig_codeset. (format_name_writer): Define only if funopen et al is available. * gpgsm.c (i18n_init): Remove. 2007-05-29 Werner Koch * export.c (gpgsm_p12_export): Print passphrase encoding info only in PEM mode. 2007-05-18 Marcus Brinkmann * qualified.c (gpgsm_qualified_consent, gpgsm_not_qualified_warning): Free ORIG_CODESET on error. * certdump.c (gpgsm_format_keydesc): Likewise. 2007-05-07 Werner Koch * certcheck.c (MY_GCRY_PK_ECDSA): New. 2007-04-20 Werner Koch * gpgsm.c (main): Parameterize failed versions check messages. 2007-04-19 Werner Koch * certcheck.c (do_encode_md): Add arg PKEY. Add support for DSA2 and all ECDSA sizes. (get_dsa_qbits): New. (pk_algo_from_sexp): A key will never contain ecdsa as algorithm, so remove that. 2007-04-18 Werner Koch * certcheck.c (do_encode_md): Support 160 bit ECDSA. 2007-04-13 Werner Koch * call-agent.c (start_agent): Don't use log_error when using the fallback hack to start the agent. This is bug 782. 2007-03-20 Werner Koch * fingerprint.c (gpgsm_get_fingerprint): Add caching. (gpgsm_get_fingerprint_string): Use bin2hexcolon(). (gpgsm_get_fingerprint_hexstring): Use bin2hex and allocate only as much memory as required. (gpgsm_get_keygrip_hexstring): Use bin2hex. * certchain.c (gpgsm_validate_chain): Keep track of the certificate chain and reset the ephemeral flags. * keydb.c (keydb_set_cert_flags): New args EPHEMERAL and MASK. Changed caller to use a mask of ~0. Return a proper error code if the certificate is not available. * gpgsm.c: Add option --p12-charset. * gpgsm.h (struct opt): Add p12_charset. * export.c (popen_protect_tool): Use new option. 2007-03-19 Werner Koch Changes to let export and key listing use estream to help systems without funopen. * keylist.c: Use estream in place of stdio functions. * gpgsm.c (open_es_fwrite): New. (main): Use it for the list commands. * server.c (data_line_cookie_functions): New. (data_line_cookie_write, data_line_cookie_close): New. (do_listkeys): Use estream. * certdump.c (gpgsm_print_serial): Changed to use estream. (gpgsm_print_time): Ditto. (pretty_es_print_sexp): New. (gpgsm_es_print_name): New. (print_dn_part): New arg STREAM. Changed all callers. (print_dn_parts): Ditto. * certchain.c (gpgsm_validate_chain): Changed FP to type estream_t. (do_list, unknown_criticals, allowed_ca, check_cert_policy) (is_cert_still_valid): Ditto. * export.c (gpgsm_export): New arg STREAM. (do_putc, do_fputs): New. (print_short_info): Allow printing to optional STREAM. * server.c (cmd_export): Use stream. * base64.c (do_putc, do_fputs): New. (base64_writer_cb, base64_finish_write): Let them cope with an alternate output function. (plain_writer_cb): New. (gpgsm_create_writer): New arg STREAM and call plain_writer_cb for binary output to an estream. Changed call callers. 2007-01-31 Werner Koch * gpgsm.c (main): Let --gen-key print a more informative error message. 2007-01-25 Werner Koch * Makefile.am (gpgsm_LDADD): Add LIBICONV. Noted by Billy Halsey. 2007-01-05 Werner Koch * certchain.c (unknown_criticals): Add subjectAltName. 2006-12-21 Werner Koch * gpgsm.c: Comment mtrace feature. 2006-12-21 Marcus Brinkmann * certchain.c (gpgsm_basic_cert_check): Release SUBJECT. * encrypt.c (encrypt_dek): Release S_CIPH. 2006-12-20 Marcus Brinkmann * server.c (gpgsm_server): Release CTRL->server_local. * base64.c: Add new members READER and WRITER in union U2. (gpgsm_create_reader): Initialise CTX->u2.reader. (gpgsm_destroy_reader): Invoke ksba_reader_release. Return early if CTX is NULL. (gpgsm_create_writer): Initialise CTX->u2.writer. (gpgsm_destroy_writer): Invoke ksba_writer_release. Return early if CTX is NULL. 2006-12-18 Marcus Brinkmann * fingerprint.c (gpgsm_get_fingerprint): Close MD. 2006-11-24 Werner Koch * certdump.c (parse_dn_part): Take '#' as a special character only at the beginning of a string. 2006-11-21 Werner Koch * certdump.c (my_funopen_hook_ret_t): New. (format_name_writer): Use it for the return value. 2006-11-14 Werner Koch * server.c (skip_options): Skip leading spaces. (has_option): Honor "--". (cmd_export): Add option --data to do an inline export. Skip all options. * certdump.c (gpgsm_fpr_and_name_for_status): New. * verify.c (gpgsm_verify): Use it to print correct status messages. 2006-11-11 Werner Koch * server.c (skip_options): New. 2006-10-24 Marcus Brinkmann * Makefile.am (AM_CFLAGS): Add $(LIBASSUAN_CFLAGS). 2006-10-23 Werner Koch * gpgsm.c (main): Remap common cipher algo names to their OIDs. (main): New command --gpgconf-test. 2006-10-20 Werner Koch * keydb.c (classify_user_id): Parse keygrip for the '&' identifier. 2006-10-18 Werner Koch * keylist.c (list_cert_raw): Also test for GPG_ERR_NO_VALUE when testing for GPG_ERR_NO_DATA. * certlist.c (cert_usage_p, gpgsm_find_cert): Ditto. * certchain.c (check_cert_policy): Ditto. * keylist.c (list_cert_std, list_cert_raw): Print "none" for no chain length available. 2006-10-17 Werner Koch * gpgsm.c: No need for pth.h. (main): or to init it. It used to be hack for W32. * sign.c (gpgsm_get_default_cert): Changed to return only certificates usable for signing. 2006-10-16 Werner Koch * certchain.c (already_asked_marktrusted) (set_already_asked_marktrusted): New. (gpgsm_validate_chain) : Keep track of certificates we already asked for. 2006-10-11 Werner Koch * certreqgen.c (proc_parameters, create_request): Allow for creation directly from a card. * call-agent.c (gpgsm_agent_readkey): New arg FROMCARD. (gpgsm_scd_pksign): New. 2006-10-06 Werner Koch * Makefile.am (AM_CFLAGS): Use PTH version of libassuan. (gpgsm_LDADD): Ditto. 2006-10-05 Werner Koch * certcheck.c (do_encode_md): Check that the has algo is valid. 2006-10-02 Marcus Brinkmann * server.c (register_commands): New commands DUMPKEYS and DUMPSECRETKEYS. (cmd_dumpkeys, cmd_dumpsecretkeys): New functions. (option_handler): Support with-key-data option. 2006-09-26 Werner Koch * certchain.c (gpgsm_validate_chain): More changes for the relax feature. Use certificate reference counting instead of the old explicit tests. Added a missing free. 2006-09-25 Werner Koch * gpgsm.h (struct rootca_flags_s): New. * call-agent.c (istrusted_status_cb): New. (gpgsm_agent_istrusted): New arg ROOTCA_FLAGS. * keylist.c (list_cert_colon): Use dummy for new arg. * certchain.c (gpgsm_validate_chain): Make use of the relax flag for root certificates. (unknown_criticals): Ignore a GPG_ERR_NO_VALUE. 2006-09-20 Werner Koch * gpgsm.c: Add alias command --dump-cert. * Makefile.am: Changes to allow parallel make runs. 2006-09-18 Werner Koch * gpgsm.c (main): Use this to import standard certificates. * keydb.c (keydb_add_resource): New arg AUTO_CREATED. 2006-09-14 Werner Koch Replaced all call gpg_error_from_errno(errno) by gpg_error_from_syserror(). 2006-09-13 Werner Koch * keylist.c (list_internal_keys): Print marker line to FP and not to stdout. * gpgsm.c (main): All list key list commands now make ose of --output. Cleaned up calls to list modes. New command --dump-chain. Renamed --list-sigs to --list-chain and added an alias for the old one. * server.c (cmd_message): Changed to use assuan_command_parse_fd. (option_handler): New option list-to-output. (do_listkeys): Use it. 2006-09-06 Werner Koch * gpgsm.h (OUT_OF_CORE): Removed and changed all callers to out_of_core. (CTRL): Removed and changed everywhere to ctrl_t. (CERTLIST): Ditto. Replaced all Assuan error codes by libgpg-error codes. Removed all map_to_assuan_status and map_assuan_err. * gpgsm.c (main): Call assuan_set_assuan_err_source to have Assuan switch to gpg-error codes. * server.c (set_error): Adjusted. 2006-08-29 Werner Koch * call-agent.c (gpgsm_agent_pkdecrypt): Allow decryption using complete S-expressions as implemented by the current gpg-agent. * gpgsm.c (main): Implement --output for encrypt, decrypt, sign and export. 2006-07-03 Werner Koch * certreqgen.c (proc_parameters): Print the component label of a faulty DN. 2006-06-26 Werner Koch * certdump.c (gpgsm_cert_log_name): New. * certchain.c (is_cert_still_valid): Log the name of the certificate. 2006-06-20 Werner Koch * gpgsm.c (gpgsm_init_default_ctrl): Take care of the command line option --include-certs. * keylist.c (list_cert_raw): Print the certid. 2006-05-23 Werner Koch * keydb.c (hextobyte): Deleted as it is now defined in jnlib. * Makefile.am (gpgsm_LDADD): Include ZLIBS. 2006-05-19 Marcus Brinkmann * keydb.c (keydb_insert_cert): Do not lock here, but only check if it is locked. (keydb_store_cert): Lock here. * keydb.h (keydb_delete): Accept new argument UNLOCK. * keydb.c (keydb_delete): Likewise. Only unlock if this is set. * delete.c (delete_one): Add new argument to invocation of keydb_delete. 2006-05-15 Werner Koch * keylist.c (print_names_raw): Sanitize URI. 2006-03-21 Werner Koch * certchain.c (get_regtp_ca_info): New. (allowed_ca): Use it. 2006-03-20 Werner Koch * qualified.c (gpgsm_is_in_qualified_list): New optional arg COUNTRY. 2006-02-17 Werner Koch * call-dirmngr.c (start_dirmngr): Print name of dirmngr to be started. 2005-11-23 Werner Koch * gpgsm.h: New member QUALSIG_APPROVAL. * sign.c (gpgsm_sign): Print a warning if a certificate is not qualified. * qualified.c (gpgsm_qualified_consent): Include a note that this is not approved software. (gpgsm_not_qualified_warning): New. * gpgsm.c (main): Prepared to print a note whether the software has been approved. 2005-11-13 Werner Koch * call-agent.c (gpgsm_agent_get_confirmation): New. * keylist.c (list_cert_std): Print qualified status. * qualified.c: New. * certchain.c (gpgsm_validate_chain): Check for qualified certificates. * certchain.c (gpgsm_basic_cert_check): Release keydb handle when no-chain-validation is used. 2005-11-11 Werner Koch * keylist.c (print_capabilities): Print is_qualified status. 2005-10-28 Werner Koch * certdump.c (pretty_print_sexp): New. (gpgsm_print_name2): Use it here. This allows proper printing of DNS names as used with server certificates. 2005-10-10 Werner Koch * keylist.c: Add pkaAdress OID as reference. 2005-10-08 Marcus Brinkmann * Makefile.am (gpgsm_LDADD): Add ../gl/libgnu.a after ../common/libcommon.a. 2005-09-13 Werner Koch * verify.c (gpgsm_verify): Print a note if the unknown algorithm is MD2. * sign.c (gpgsm_sign): Ditto. * certcheck.c (gpgsm_check_cert_sig): Ditto. 2005-09-08 Werner Koch * export.c (popen_protect_tool): Add option --have-cert. We probably lost this option with 1.9.14 due to restructuring of export.c. 2005-07-21 Werner Koch * gpgsm.c (main): New options --no-log-file and --debug-none. * certreqgen.c (get_parameter, get_parameter_value): Add SEQ arg to allow enumeration. Changed all callers. (create_request): Process DNS and URI parameters. 2005-07-20 Werner Koch * keylist.c (email_kludge): Reworked. * certdump.c (gpgsm_print_serial, gpgsm_dump_serial): Cast printf arg to unsigned. * call-dirmngr.c (gpgsm_dirmngr_run_command): Ditto 2005-07-19 Werner Koch * fingerprint.c (gpgsm_get_certid): Cast printf arg to unsigned. Bug accidently introduced while solving the #$%^& gcc signed/unsigned char* warnings. 2005-06-15 Werner Koch * delete.c (delete_one): Changed FPR to unsigned. * encrypt.c (encrypt_dek): Made ENCVAL unsigned. (gpgsm_encrypt): Ditto. * sign.c (gpgsm_sign): Made SIGVAL unsigned. * base64.c (base64_reader_cb): Need to use some casting to get around signed/unsigned char* warnings. * certcheck.c (gpgsm_check_cms_signature): Ditto. (gpgsm_create_cms_signature): Changed arg R_SIGVAL to unsigned char*. (do_encode_md): Made NFRAME a size_t. * certdump.c (gpgsm_print_serial): Fixed signed/unsigned warning. (gpgsm_dump_serial): Ditto. (gpgsm_format_serial): Ditto. (gpgsm_dump_string): Ditto. (gpgsm_dump_cert): Ditto. (parse_dn_part): Ditto. (gpgsm_print_name2): Ditto. * keylist.c (email_kludge): Ditto. * certreqgen.c (proc_parameters, create_request): Ditto. (create_request): Ditto. * call-agent.c (gpgsm_agent_pksign): Made arg R_BUF unsigned. (struct cipher_parm_s): Made CIPHERTEXT unsigned. (struct genkey_parm_s): Ditto. * server.c (strcpy_escaped_plus): Made arg S signed char*. * fingerprint.c (gpgsm_get_fingerprint): Made ARRAY unsigned. (gpgsm_get_keygrip): Ditto. * keydb.c (keydb_insert_cert): Made DIGEST unsigned. (keydb_update_cert): Ditto. (classify_user_id): Apply cast to signed/unsigned assignment. (hextobyte): Ditto. 2005-06-01 Werner Koch * misc.c: Include setenv.h. 2005-04-21 Werner Koch * gpgsm.c: New options --{enable,disable}-trusted-cert-crl-check. * certchain.c (gpgsm_validate_chain): Make use of it. * certchain.c (gpgsm_validate_chain): Check revocations even for expired certificates. This is required because on signature verification an expired key is fine whereas a revoked one is not. 2005-04-20 Werner Koch * Makefile.am (AM_CFLAGS): Add PTH_CFLAGS as noted by several folks. 2005-04-19 Werner Koch * certchain.c (check_cert_policy): Print the diagnostic for a open failure of policies.txt only in verbose mode or when it is not ENOENT. 2005-04-17 Werner Koch * call-dirmngr.c (inq_certificate): Add new inquire SENDCERT_SKI. * certlist.c (gpgsm_find_cert): Add new arg KEYID and implement this filter. Changed all callers. * certchain.c (find_up_search_by_keyid): New helper. (find_up): Also try using the AKI.keyIdentifier. (find_up_external): Ditto. 2005-04-15 Werner Koch * keylist.c (list_cert_raw): Print the subjectKeyIdentifier as well as the keyIdentifier part of the authorityKeyIdentifier. 2005-03-31 Werner Koch * call-dirmngr.c (start_dirmngr): Use PATHSEP_C instead of ':'. * call-agent.c (start_agent): Ditto. 2005-03-17 Werner Koch * certcheck.c: Fixed use of DBG_CRYPTO and DBG_X509. * certchain.c (gpgsm_basic_cert_check): Dump certificates after a failed gcry_pk_verify. (find_up): Do an external lookup also for an authorityKeyIdentifier lookup. Factored external lookup code out to .. (find_up_external): .. new. 2005-03-03 Werner Koch * Makefile.am (gpgsm_LDADD): Added PTH_LIBS. Noted by Kazu Yamamoto. 2005-01-13 Werner Koch * certreqgen.c (proc_parameters): Cast printf arg. 2004-12-22 Werner Koch * gpgsm.c (set_binary): New. (main, open_read, open_fwrite): Use it. 2004-12-21 Werner Koch * gpgsm.c (main): Use default_homedir(). (main) [W32]: Default to disabled CRL checks. 2004-12-20 Werner Koch * call-agent.c (start_agent): Before starting a pipe server start to connect to a server on the standard socket. Use PATHSEP * call-dirmngr.c (start_dirmngr): Use PATHSEP. * import.c: Include unistd.h for dup and close. 2004-12-18 Werner Koch * gpgsm.h (map_assuan_err): Define in terms of map_assuan_err_with_source. * call-agent.c (start_agent): Pass error source to send_pinentry_environment. 2004-12-17 Werner Koch * call-dirmngr.c (isvalid_status_cb, lookup_status_cb) (run_command_status_cb): Return cancel status if gpgsm_status returned an error. * server.c (gpgsm_status, gpgsm_status2) (gpgsm_status_with_err_code): Return an error code. (gpgsm_status2): Always call va_end(). 2004-12-15 Werner Koch * call-dirmngr.c (lookup_status_cb): Send progress messages upstream. (isvalid_status_cb): Ditto. (gpgsm_dirmngr_isvalid): Put CTRL into status CB parameters. (gpgsm_dirmngr_run_command, run_command_status_cb): Pass CTRL to status callback and handle PROGRESS. * misc.c (setup_pinentry_env) [W32]: Don't use it. * gpgsm.c (main) [W32]: Init Pth because we need it for the socket operations and to resolve libassuan symbols. (run_protect_tool) [W32]: Disable it. * Makefile.am (gpgsm_LDADD): Move LIBASSUAN_LIBS more to the end. 2004-12-07 Werner Koch * Makefile.am (gpgsm_LDADD): Put libassuan before jnlib because under W32 we need the w32 pth code from jnlib. * misc.c (setup_pinentry_env) [W32]: Disabled. 2004-12-06 Werner Koch * gpgsm.c (run_protect_tool) [_WIN32]: Disabled. * import.c (popen_protect_tool): Simplified by making use of gnupg_spawn_process. (parse_p12): Likewise, using gnupg_wait_process. * export.c (popen_protect_tool): Ditto. (export_p12): Ditto. * keydb.c: Don't define DIRSEP_S here. 2004-12-02 Werner Koch * certchain.c (gpgsm_basic_cert_check): Dump certs with bad signature for debugging. (gpgsm_validate_chain): Ditto. 2004-11-29 Werner Koch * gpgsm.c (set_debug): Changed to use a globals DEBUG_LEVEL and DEBUG_VALUE. (main): Made DEBUG_LEVEL global and introduced DEBUG_VALUE. This now allows to add debug flags on top of a debug-level setting. 2004-11-23 Werner Koch * gpgsm.c: New option --prefer-system-dirmngr. * call-dirmngr.c (start_dirmngr): Implement this option. 2004-10-22 Werner Koch * certreqgen.c (gpgsm_genkey): Remove the NEW from the certificate request PEM header. This is according to the Sphinx standard. 2004-10-08 Moritz Schulte * certchain.c (gpgsm_validate_chain): Do not use keydb_new() in case the no_chain_validation-return-short-cut is used (fixes memory leak). 2004-10-04 Werner Koch * misc.c (setup_pinentry_env): Try hard to set a default for GPG_TTY. 2004-09-30 Werner Koch * gpgsm.c (i18n_init): Always use LC_ALL. * certdump.c (gpgsm_format_name): Factored code out to .. (gpgsm_format_name2): .. new. (gpgsm_print_name): Factored code out to .. (gpgsm_print_name2): .. new. (print_dn_part): New arg TRANSLATE. Changed all callers. (print_dn_parts): Ditto. (gpgsm_format_keydesc): Do not translate the SUBJECT; we require it to stay UTF-8 but we still want to filter out bad control characters. * Makefile.am: Adjusted for gettext 0.14. * keylist.c (list_cert_colon): Make sure that the expired flag has a higher precedence than the invalid flag. 2004-09-29 Werner Koch * import.c (parse_p12): Write an error status line for bad passphrases. Add new arg CTRL and changed caller. * export.c (export_p12): Likewise. 2004-09-14 Werner Koch * certchain.c (gpgsm_validate_chain): Give expired certificates a higher error precedence and don't bother to check any CRL in that case. 2004-08-24 Werner Koch * certlist.c: Fixed typo in ocsp OID. 2004-08-18 Werner Koch * certlist.c (gpgsm_cert_use_ocsp_p): New. (cert_usage_p): Support it here. * call-dirmngr.c (gpgsm_dirmngr_isvalid): Use it here. 2004-08-17 Marcus Brinkmann * import.c: Fix typo in last change. 2004-08-17 Werner Koch * import.c (check_and_store): Do a full validation if --with-validation is set. * certchain.c (gpgsm_basic_cert_check): Print more detailed error messages. * certcheck.c (do_encode_md): Partly support DSA. Add new arg PKALGO. Changed all callers to pass it. (pk_algo_from_sexp): New. 2004-08-16 Werner Koch * gpgsm.c: New option --fixed-passphrase. * import.c (popen_protect_tool): Pass it to the protect-tool. * server.c (cmd_encrypt): Use DEFAULT_RECPLIST and not recplist for encrypt-to keys. 2004-08-06 Werner Koch * gpgsm.c: New option --with-ephemeral-keys. * keylist.c (list_internal_keys): Set it here. (list_cert_raw): And indicate those keys. Changed all our callers to pass the new arg HD through. 2004-07-23 Werner Koch * certreqgen.c (proc_parameters): Do not allow key length below 1024. 2004-07-22 Werner Koch * keylist.c (list_cert_raw): Print the keygrip. 2004-07-20 Werner Koch * certchain.c (gpgsm_validate_chain): The trust check didn't worked anymore, probably due to the changes at 2003-03-04. Fixed. 2004-06-06 Werner Koch * certreqgen.c (get_parameter_uint, create_request): Create an extension for key usage when requested. 2004-05-12 Werner Koch * gpgsm.c (main): Install emergency_cleanup also as an atexit handler. * verify.c (gpgsm_verify): Removed the separate error code handling for KSBA. We use shared error codes anyway. * export.c (export_p12): Removed debugging code. * encrypt.c (gpgsm_encrypt): Put the session key in to secure memory. 2004-05-11 Werner Koch * sign.c (gpgsm_sign): Include the error source in the final error message. * decrypt.c (gpgsm_decrypt): Ditto. * fingerprint.c (gpgsm_get_key_algo_info): New. * sign.c (gpgsm_sign): Don't assume RSA in the status line. * keylist.c (list_cert_colon): Really print the algorithm and key length. (list_cert_raw, list_cert_std): Ditto. (list_cert_colon): Reorganized to be able to tell whether a root certificate is trusted. * gpgsm.c: New option --debug-allow-core-dump. * gpgsm.h (opt): Add member CONFIG_FILENAME. * gpgsm.c (main): Use it here instead of the local var. * server.c (gpgsm_server): Print some additional information with the hello in verbose mode. 2004-04-30 Werner Koch * import.c (check_and_store): Do not update the stats for hidden imports of issuer certs. (popen_protect_tool): Request statusmessages from the protect-tool. (parse_p12): Detect status messages. Add new arg STATS and update them. (print_imported_summary): Include secret key stats. 2004-04-28 Werner Koch * gpgsm.c: New command --keydb-clear-some-cert-flags. * keydb.c (keydb_clear_some_cert_flags): New. (keydb_update_keyblock, keydb_set_flags): Change error code CONFLICT to NOT_LOCKED. 2004-04-26 Werner Koch * gpgsm.c (main) : Do not use /dev/null as default config filename. * call-agent.c (gpgsm_agent_pksign, gpgsm_agent_pkdecrypt) (gpgsm_agent_genkey, gpgsm_agent_istrusted) (gpgsm_agent_marktrusted, gpgsm_agent_havekey) (gpgsm_agent_passwd): Add new arg CTRL and changed all callers. (start_agent): New arg CTRL. Send progress item when starting a new agent. * sign.c (gpgsm_get_default_cert, get_default_signer): New arg CTRL to be passed down to the agent function. * decrypt.c (prepare_decryption): Ditto. * certreqgen.c (proc_parameters, read_parameters): Ditto. * certcheck.c (gpgsm_create_cms_signature): Ditto. 2004-04-23 Werner Koch * keydb.c (keydb_add_resource): Try to compress the file on init. * keylist.c (oidtranstbl): New. OIDs collected from several sources. (print_name_raw, print_names_raw, list_cert_raw): New. (gpgsm_list_keys): Check the dump mode and pass it down as necessary. 2004-04-22 Werner Koch * gpgsm.c (main): New commands --dump-keys, --dump-external-keys, --dump-secret-keys. 2004-04-13 Werner Koch * misc.c (setup_pinentry_env): New. * import.c (popen_protect_tool): Call it. * export.c (popen_protect_tool): Call it. 2004-04-08 Werner Koch * decrypt.c (gpgsm_decrypt): Return GPG_ERR_NO_DATA if it is not a encrypted message. 2004-04-07 Werner Koch * gpgsm.c: New option --force-crl-refresh. * call-dirmngr.c (gpgsm_dirmngr_isvalid): Pass option to dirmngr. 2004-04-05 Werner Koch * server.c (get_status_string): Add STATUS_NEWSIG. * verify.c (gpgsm_verify): Print STATUS_NEWSIG for each signature. * certchain.c (gpgsm_validate_chain) : Do not just warn if a cert is not suitable; bail out immediately. 2004-04-01 Werner Koch * call-dirmngr.c (isvalid_status_cb): New. (unhexify_fpr): New. Taken from ../g10/call-agent.c (gpgsm_dirmngr_isvalid): Add new arg CTRL, changed caller to pass it thru. Detect need to check the respondert cert and do that. * certchain.c (gpgsm_validate_chain): Add new arg FLAGS. Changed all callers. 2004-03-24 Werner Koch * sign.c (gpgsm_sign): Include a short list of capabilities. 2004-03-17 Werner Koch * gpgsm.c (main) : Fixed default value quoting. 2004-03-16 Werner Koch * gpgsm.c (main): Implemented --gpgconf-list. 2004-03-15 Werner Koch * keylist.c (list_cert_colon): Hack to set the expired flag. 2004-03-09 Werner Koch * gpgsm.c (main): Correctly intitialze USE_OCSP flag. * keydb.c (keydb_delete): s/GPG_ERR_CONFLICT/GPG_ERR_NOT_LOCKED/ 2004-03-04 Werner Koch * call-dirmngr.c (gpgsm_dirmngr_isvalid): New arg ISSUER_CERT. * certchain.c (is_cert_still_valid): New. Code moved from ... (gpgsm_validate_chain): ... here because we now need to check at two places and at a later stage, so that we can pass the issuer cert down to the dirmngr. 2004-03-03 Werner Koch * call-agent.c (start_agent): Replaced pinentry setup code by a call to a new common function. * certdump.c (gpgsm_format_keydesc): Make sure the string is returned as utf-8. * export.c (gpgsm_export): Make sure that we don't export more than one certificate. 2004-03-02 Werner Koch * export.c (create_duptable, destroy_duptable) (insert_duptable): New. (gpgsm_export): Avoid duplicates. 2004-02-26 Werner Koch * certchain.c (compare_certs): New. (gpgsm_validate_chain): Fixed infinite certificate checks after bad signatures. 2004-02-24 Werner Koch * keylist.c (list_cert_colon): Print the fingerprint as the cert-id for root certificates. 2004-02-21 Werner Koch * keylist.c (list_internal_keys): Return error codes. (list_external_keys, gpgsm_list_keys): Ditto. * server.c (do_listkeys): Ditto. * gpgsm.c (main): Display a key description for --passwd. * call-agent.c (gpgsm_agent_passwd): New arg DESC. 2004-02-20 Werner Koch * gpgsm.c (main): New option --debug-ignore-expiration. * certchain.c (gpgsm_validate_chain): Use it here. * certlist.c (cert_usage_p): Apply extKeyUsage. 2004-02-19 Werner Koch * export.c (export_p12, popen_protect_tool) (gpgsm_p12_export): New. * gpgsm.c (main): New command --export-secret-key-p12. 2004-02-18 Werner Koch * gpgsm.c (set_debug): Set the new --debug-level flags. (main): New option --gpgconf-list. (main): Do not setup -u and -r keys when not required. (main): Setup the used character set. * keydb.c (keydb_add_resource): Print a hint to start the gpg-agent. 2004-02-17 Werner Koch * gpgsm.c: Fixed value parsing for --with-validation. * call-agent.c (start_agent): Ignore an empty GPG_AGENT_INFO. * call-dirmngr.c (start_dirmngr): Likewise for DIRMNGR_INFO. * gpgsm.c: New option --with-md5-fingerprint. * keylist.c (list_cert_std): Print MD5 fpr. * gpgsm.c: New options --with-validation. * server.c (option_handler): New option "with-validation". * keylist.c (list_cert_std, list_internal_keys): New args CTRL and WITH_VALIDATION. Changed callers to set it. (list_external_cb, list_external_keys): Pass CTRL to the callback. (list_cert_colon): Add arg CTRL. Check validation if requested. * certchain.c (unknown_criticals, allowed_ca, check_cert_policy) (gpgsm_validate_chain): New args LISTMODE and FP. (do_list): New helper for info output. (find_up): New arg FIND_NEXT. (gpgsm_validate_chain): After a bad signature try again with other CA certificates. * import.c (print_imported_status): New arg NEW_CERT. Print additional STATUS_IMPORT_OK becuase that is what gpgme expects. (check_and_store): Always call above function after import. * server.c (get_status_string): Added STATUS_IMPORT_OK. 2004-02-13 Werner Koch * certcheck.c (gpgsm_create_cms_signature): Format a description for use by the pinentry. * decrypt.c (gpgsm_decrypt): Ditto. Free HEXKEYGRIP. * certdump.c (format_name_cookie, format_name_writer) (gpgsm_format_name): New. (gpgsm_format_serial): New. (gpgsm_format_keydesc): New. * call-agent.c (gpgsm_agent_pksign): New arg DESC. (gpgsm_agent_pkdecrypt): Ditto. * encrypt.c (init_dek): Check for too weak algorithms. * import.c (parse_p12, popen_protect_tool): New. * base64.c (gpgsm_create_reader): New arg ALLOW_MULTI_PEM. Changed all callers. (base64_reader_cb): Handle it here. (gpgsm_reader_eof_seen): New. (base64_reader_cb): Set a flag for EOF. (simple_reader_cb): Ditto. 2004-02-12 Werner Koch * gpgsm.h, gpgsm.c: New option --protect-tool-program. * gpgsm.c (run_protect_tool): Use it. 2004-02-11 Werner Koch * Makefile.am (AM_CPPFLAGS): Pass directory constants via -D; this will allow to override directory names at make time. 2004-02-02 Werner Koch * import.c (check_and_store): Import certificates even with missing issuer's cert. Fixed an "depending on the verbose setting" bug. * certchain.c (gpgsm_validate_chain): Mark revoked certs in the keybox. * keylist.c (list_cert_colon): New arg VALIDITY; use it to print a revoked flag. (list_internal_keys): Retrieve validity flag. (list_external_cb): Pass 0 as validity flag. * keydb.c (keydb_get_flags, keydb_set_flags): New. (keydb_set_cert_flags): New. (lock_all): Return a proper error code. (keydb_lock): New. (keydb_delete): Don't lock but check that it has been locked. (keydb_update_keyblock): Ditto. * delete.c (delete_one): Take a lock. 2004-01-30 Werner Koch * certchain.c (check_cert_policy): Fixed read error checking. (check_cert_policy): With no critical policies issue only a warning if the policy file does not exists. * sign.c (add_certificate_list): Decrement N for the first cert. 2004-01-29 Werner Koch * certdump.c (parse_dn_part): Map common OIDs to human readable labels. Make sure that a value won't get truncated if it includes a Nul. 2004-01-28 Werner Koch * certchain.c (gpgsm_validate_chain): Changed the message printed for an untrusted root certificate. 2004-01-27 Werner Koch * certdump.c (parse_dn_part): Pretty print the nameDistinguisher OID. (print_dn_part): Do not delimit multiple RDN by " + ". Handle multi-valued RDNs in a special way, i.e. in the order specified by the certificate. (print_dn_parts): Simplified. 2004-01-16 Werner Koch * sign.c (gpgsm_sign): Print an error message on all failures. * decrypt.c (gpgsm_decrypt): Ditto. 2003-12-17 Werner Koch * server.c (gpgsm_server): Add arg DEFAULT_RECPLIST. (cmd_encrypt): Add all enrypt-to marked certs to the list. * encrypt.c (gpgsm_encrypt): Check that real recipients are available. * gpgsm.c (main): Make the --encrypt-to and --no-encrypt-to options work. Pass the list of recients to gpgsm_server. * gpgsm.h (certlist_s): Add field IS_ENCRYPT_TO. (opt): Add NO_ENCRYPT_TO. * certlist.c (gpgsm_add_to_certlist): New arg IS_ENCRYPT_TO. Changed all callers and ignore duplicate entries. (is_cert_in_certlist): New. (gpgsm_add_cert_to_certlist): New. * certdump.c (gpgsm_print_serial): Cleaned up cast use in strtoul. (gpgsm_dump_serial): Ditto. * decrypt.c (gpgsm_decrypt): Replaced ERR by RC. 2003-12-16 Werner Koch * gpgsm.c (main): Set the prefixes for assuan logging. * sign.c (gpgsm_sign): Add validation checks for the default certificate. * gpgsm.c: Add -k as alias for --list-keys and -K for --list-secret-keys. 2003-12-15 Werner Koch * encrypt.c (init_dek): Use gry_create_nonce for the IV; there is not need for real strong random here and it even better protect the random bits used for the key. 2003-12-01 Werner Koch * gpgsm.c, gpgsm.h: New options --{enable,disable}-ocsp. (gpgsm_init_default_ctrl): Set USE_OCSP to the default value. * certchain.c (gpgsm_validate_chain): Handle USE_OCSP. * call-dirmngr.c (gpgsm_dirmngr_isvalid): Add arg USE_OCSP and proceed accordingly. 2003-11-19 Werner Koch * verify.c (gpgsm_verify): Use "0" instead of an empty string for the VALIDSIG status. 2003-11-18 Werner Koch * verify.c (gpgsm_verify): Fixed for changes API of gcry_md_info. * certchain.c (unknown_criticals): Fixed an error code test. 2003-11-12 Werner Koch Adjusted for API changes in Libksba. 2003-10-31 Werner Koch * certchain.c (gpgsm_validate_chain): Changed to use ksba_isotime_t. * verify.c (strtimestamp_r, gpgsm_verify): Ditto. * sign.c (gpgsm_sign): Ditto. * keylist.c (print_time, list_cert_std, list_cert_colon): Ditto. * certdump.c (gpgsm_print_time, gpgsm_dump_time, gpgsm_dump_cert): Ditto. 2003-10-25 Werner Koch * certreqgen.c (read_parameters): Fixed faulty of !spacep(). 2003-08-20 Marcus Brinkmann * encrypt.c (encode_session_key): Allocate enough space. Cast key byte to unsigned char to prevent sign extension. (encrypt_dek): Check return value before error. 2003-08-14 Timo Schulz * encrypt.c (encode_session_key): Use new Libgcrypt interface. 2003-07-31 Werner Koch * Makefile.am (gpgsm_LDADD): Added INTLLIBS. 2003-07-29 Werner Koch * gpgsm.c (main): Add secmem features and set the random seed file. (gpgsm_exit): Update the random seed file and enable debug output. 2003-07-27 Werner Koch Adjusted for gcry_mpi_print and gcry_mpi_scan API change. 2003-06-24 Werner Koch * server.c (gpgsm_status_with_err_code): New. * verify.c (gpgsm_verify): Use it here instead of the old tokenizing version. * verify.c (strtimestamp): Renamed to strtimestamp_r Adjusted for changes in the libgcrypt API. Some more fixes for the libgpg-error stuff. 2003-06-04 Werner Koch * call-agent.c (init_membuf,put_membuf,get_membuf): Removed. Include new membuf header and changed used type. Renamed error codes from INVALID to INV and removed _ERROR suffixes. 2003-06-03 Werner Koch Changed all error codes in all files to the new libgpg-error scheme. * gpgsm.h: Include gpg-error.h . * Makefile.am: Link with libgpg-error. 2003-04-29 Werner Koch * Makefile.am: Use libassuan. Don't override LDFLAGS anymore. * server.c (register_commands): Adjust for new Assuan semantics. 2002-12-03 Werner Koch * call-agent.c (gpgsm_agent_passwd): New. * gpgsm.c (main): New command --passwd and --call-protect-tool (run_protect_tool): New. 2002-11-25 Werner Koch * verify.c (gpgsm_verify): Handle content-type attribute. 2002-11-13 Werner Koch * call-agent.c (start_agent): Try to use $GPG_TTY instead of ttyname. Changed ttyname to test stdin becuase it can be assumed that output redirection is more common that input redirection. 2002-11-12 Werner Koch * gpgsm.c: New command --call-dirmngr. * call-dirmngr.c (gpgsm_dirmngr_run_command) (run_command_inq_cb,run_command_cb) (run_command_status_cb): New. 2002-11-11 Werner Koch * certcheck.c (gpgsm_check_cms_signature): Don't double free s_sig but free s_pkey at leave. 2002-11-10 Werner Koch * gpgsm.c: Removed duplicate --list-secret-key entry. 2002-09-19 Werner Koch * certcheck.c (gpgsm_check_cert_sig): Add cert hash debugging. * certchain.c (find_up): Print info when the cert was not found by the autorithyKeyIdentifier. 2002-09-03 Werner Koch * gpgsm.c (main): Disable the internal libgcrypt locking. 2002-08-21 Werner Koch * import.c (print_imported_summary): Cleaned up. Print new not_imported value. (check_and_store): Update non_imported counter. (print_import_problem): New. (check_and_store): Print error status message. * server.c (get_status_string): Added STATUS_IMPORT_PROBLEM. 2002-08-20 Werner Koch * gpgsm.c (main): Use the log file only in server mode. * import.c (print_imported_summary): New. (check_and_store): Update the counters, take new argument. (import_one): Factored out core of gpgsm_import. (gpgsm_import): Print counters. (gpgsm_import_files): New. * gpgsm.c (main): Use the new function for import. 2002-08-19 Werner Koch * decrypt.c (gpgsm_decrypt): Return a better error status token. * verify.c (gpgsm_verify): Don't error on messages with no signing time or no message digest. This is only the case for messages without any signed attributes. 2002-08-16 Werner Koch * certpath.c: Renamed to .. * certchain.c: this. Renamed all all other usages of "path" in the context of certificates to "chain". * call-agent.c (learn_cb): Special treatment when the issuer certificate is missing. 2002-08-10 Werner Koch * Makefile.am (INCLUDES): Add definition for localedir. * keylist.c (list_cert_colon): Print the short fingerprint in the key ID field. * fingerprint.c (gpgsm_get_short_fingerprint): New. * verify.c (gpgsm_verify): Print more verbose info for a good signature. 2002-08-09 Werner Koch * decrypt.c (prepare_decryption): Hack to detected already unpkcsedone keys. * gpgsm.c (emergency_cleanup): New. (main): Initialize the signal handler. * sign.c (gpgsm_sign): Reset the hash context for subsequent signers and release it at the end. 2002-08-05 Werner Koch * server.c (cmd_signer): New command "SIGNER" (register_commands): Register it. (cmd_sign): Pass the signer list to gpgsm_sign. * certlist.c (gpgsm_add_to_certlist): Add SECRET argument, check for secret key if set and changed all callers. * sign.c (gpgsm_sign): New argument SIGNERLIST and implemt multiple signers. * gpgsm.c (main): Support more than one -u. * server.c (cmd_recipient): Return reason code 1 for No_Public_Key which is actually what gets returned from add_to_certlist. 2002-07-26 Werner Koch * certcheck.c (gpgsm_check_cert_sig): Implement proper cleanup. (gpgsm_check_cms_signature): Ditto. 2002-07-22 Werner Koch * keydb.c (keydb_add_resource): Register a lock file. (lock_all, unlock_all): Implemented. * delete.c: New. * gpgsm.c: Made --delete-key work. * server.c (cmd_delkeys): New. (register_commands): New command DELKEYS. * decrypt.c (gpgsm_decrypt): Print a convenience note when RC2 is used and a STATUS_ERROR with the algorithm oid. 2002-07-03 Werner Koch * server.c (gpgsm_status2): Insert a blank between all optional arguments when using assuan. * server.c (cmd_recipient): No more need for extra blank in constants. * import.c (print_imported_status): Ditto. * gpgsm.c (main): Ditto. 2002-07-02 Werner Koch * verify.c (gpgsm_verify): Extend the STATUS_BADSIG line with the fingerprint. * certpath.c (check_cert_policy): Don't use log_error to print a warning. * keydb.c (keydb_store_cert): Add optional ar EXISTED and changed all callers. * call-agent.c (learn_cb): Print info message only for real imports. * import.c (gpgsm_import): Moved duplicated code to ... (check_and_store): new function. Added magic to import the entire chain. Print status only for real imports and moved printing code to .. (print_imported_status): New. * call-dirmngr.c (gpgsm_dirmngr_isvalid): print status of dirmngr call in very verbose mode. * gpgsm.c (main): Use the same error codes for STATUS_INV_RECP as with the server mode. 2002-06-29 Werner Koch * gpgsm.c: New option --auto-issuer-key-retrieve. * certpath.c (find_up): Try to retrieve an issuer key from an external source and from the ephemeral key DB. (find_up_store_certs_cb): New. * keydb.c (keydb_set_ephemeral): Does now return the old state. Call the backend only when required. * call-dirmngr.c (start_dirmngr): Use GNUPG_DEFAULT_DIRMNGR. (lookup_status_cb): Issue status only when CTRL is not NULL. (gpgsm_dirmngr_lookup): Document that CTRL is optional. * call-agent.c (start_agent): Use GNUPG_DEFAULT_AGENT. 2002-06-28 Werner Koch * server.c (cmd_recipient): Add more reason codes. 2002-06-27 Werner Koch * certpath.c (gpgsm_basic_cert_check): Use --debug-no-path-validation to also bypass this basic check. * gpgsm.c (main): Use GNUPG_DEFAULT_HOMEDIR constant. * call-agent.c (start_agent): Create and pass the list of FD to keep in the child to assuan. * call-dirmngr.c (start_dirmngr): Ditto. 2002-06-26 Werner Koch * import.c (gpgsm_import): Print an STATUS_IMPORTED. * gpgsm.c: --debug-no-path-validation does not take an argument. 2002-06-25 Werner Koch * certdump.c (print_dn_part): Always print a leading slash, removed NEED_DELIM arg and changed caller. * export.c (gpgsm_export): Print LFs to FP and not stdout. (print_short_info): Ditto. Make use of gpgsm_print_name. * server.c (cmd_export): Use output-fd instead of data lines; this was actually the specified way. 2002-06-24 Werner Koch * gpgsm.c: Removed duped help entry for --list-keys. * gpgsm.c, gpgsm.h: New option --debug-no-path-validation. * certpath.c (gpgsm_validate_path): Use it here instead of the debug flag hack. * certpath.c (check_cert_policy): Return No_Policy_Match if the policy file could not be opened. 2002-06-20 Werner Koch * certlist.c (gpgsm_add_to_certlist): Fixed locating of a certificate with the required key usage. * gpgsm.c (main): Fixed a segv when using --outfile without an argument. * keylist.c (print_capabilities): Also check for non-repudiation and data encipherment. * certlist.c (cert_usage_p): Test for signing and encryption was swapped. Add a case for certification usage, handle non-repudiation and data encipherment. (gpgsm_cert_use_cert_p): New. (gpgsm_add_to_certlist): Added a CTRL argument and changed all callers to pass it. * certpath.c (gpgsm_validate_path): Use it here to print a status message. Added a CTRL argument and changed all callers to pass it. * decrypt.c (gpgsm_decrypt): Print a status message for wrong key usage. * verify.c (gpgsm_verify): Ditto. * keydb.c (classify_user_id): Allow a colon delimited fingerprint. 2002-06-19 Werner Koch * call-agent.c (learn_cb): Use log_info instead of log_error on successful import. * keydb.c (keydb_set_ephemeral): New. (keydb_store_cert): New are ephemeral, changed all callers. * keylist.c (list_external_cb): Store cert as ephemeral. * export.c (gpgsm_export): Kludge to export epehmeral certificates. * gpgsm.c (main): New command --list-external-keys. 2002-06-17 Werner Koch * certreqgen.c (read_parameters): Improved error handling. (gpgsm_genkey): Print error message. 2002-06-13 Werner Koch * gpgsm.c (main): New option --log-file. 2002-06-12 Werner Koch * call-dirmngr.c (lookup_status_cb): New. (gpgsm_dirmngr_lookup): Use the status CB. Add new arg CTRL and changed caller to pass it. * gpgsm.c (open_fwrite): New. (main): Allow --output for --verify. * sign.c (hash_and_copy_data): New. (gpgsm_sign): Implemented normal (non-detached) signatures. * gpgsm.c (main): Ditto. * certpath.c (gpgsm_validate_path): Special error handling for no policy match. 2002-06-10 Werner Koch * server.c (get_status_string): Add STATUS_ERROR. * certpath.c (gpgsm_validate_path): Tweaked the error checking to return error codes in a more sensitive way. * verify.c (gpgsm_verify): Send status TRUST_NEVER also for a bad CA certificate and when the certificate has been revoked. Issue TRUST_FULLY even when the cert has expired. Append an error token to these status lines. Issue the new generic error status when a cert was not found and when leaving the function. 2002-06-04 Werner Koch * gpgsm.c (main): New command --list-sigs * keylist.c (list_cert_std): New. Use it whenever colon mode is not used. (list_cert_chain): New. 2002-05-31 Werner Koch * gpgsm.c (main): Don't print the "go ahead" message for an invalid command. 2002-05-23 Werner Koch * import.c (gpgsm_import): Add error messages. 2002-05-21 Werner Koch * keylist.c (list_internal_keys): Renamed from gpgsm_list_keys. (list_external_keys): New. (gpgsm_list_keys): Dispatcher for above. * call-dirmngr.c (lookup_cb,pattern_from_strlist) (gpgsm_dirmngr_lookup): New. * server.c (option_handler): Handle new option --list-mode. (do_listkeys): Handle options and actually use the mode argument. (get_status_string): New code TRUNCATED. * import.c (gpgsm_import): Try to identify the type of input and handle certs-only messages. 2002-05-14 Werner Koch * gpgsm.c: New option --faked-system-time * sign.c (gpgsm_sign): And use it here. * certpath.c (gpgsm_validate_path): Ditto. 2002-05-03 Werner Koch * certpath.c (gpgsm_validate_path): Added EXPTIME arg and changed all callers. * verify.c (gpgsm_verify): Tweaked usage of log_debug and log_error. Return EXPSIG status and add expiretime to VALIDSIG. 2002-04-26 Werner Koch * gpgsm.h (DBG_AGENT,DBG_AGENT_VALUE): Replaced by DBG_ASSUAN_*. Changed all users. * call-agent.c (start_agent): Be more silent without -v. * call-dirmngr.c (start_dirmngr): Ditto. 2002-04-25 Werner Koch * call-agent.c (start_agent): Make copies of old locales and check for setlocale. 2002-04-25 Marcus Brinkmann * call-agent.c (start_agent): Fix error handling logic so the locale is always correctly reset. 2002-04-25 Marcus Brinkmann * server.c (option_handler): Accept display, ttyname, ttytype, lc_ctype and lc_messages options. * gpgsm.c (main): Allocate memory for these options. * gpgsm.h (struct opt): Make corresponding members non-const. 2002-04-24 Marcus Brinkmann * gpgsm.h (struct opt): New members display, ttyname, ttytype, lc_ctype, lc_messages. * gpgsm.c (enum cmd_and_opt_values): New members oDisplay, oTTYname, oTTYtype, oLCctype, oLCmessages. (opts): New entries for these options. (main): Handle these new options. * call-agent.c (start_agent): Set the various display and tty parameter after resetting. 2002-04-18 Werner Koch * certreqgen.c (gpgsm_genkey): Write status output on success. 2002-04-15 Werner Koch * gpgsm.c (main): Check ksba version. * certpath.c (find_up): New to use the authorithKeyIdentifier. Use it in all other functions to locate the signing cert.. 2002-04-11 Werner Koch * certlist.c (cert_usable_p): New. (gpgsm_cert_use_sign_p,gpgsm_cert_use_encrypt_p): New. (gpgsm_cert_use_verify_p,gpgsm_cert_use_decrypt_p): New. (gpgsm_add_to_certlist): Check the key usage. * sign.c (gpgsm_sign): Ditto. * verify.c (gpgsm_verify): Print a message wehn an unsuitable certificate was used. * decrypt.c (gpgsm_decrypt): Ditto * keylist.c (print_capabilities): Determine values from the cert. 2002-03-28 Werner Koch * keylist.c (list_cert_colon): Fixed listing of crt record; the issuer is not at the right place. Print a chainingID. * certpath.c (gpgsm_walk_cert_chain): Be a bit more silent on common errors. 2002-03-21 Werner Koch * export.c: New. * gpgsm.c: Add command --export. * server.c (cmd_export): New. 2002-03-13 Werner Koch * decrypt.c (gpgsm_decrypt): Allow multiple recipients. 2002-03-12 Werner Koch * certpath.c (check_cert_policy): Print the policy list. * verify.c (gpgsm_verify): Detect certs-only message. 2002-03-11 Werner Koch * import.c (gpgsm_import): Print a notice about imported certificates when in verbose mode. * gpgsm.c (main): Print INV_RECP status. * server.c (cmd_recipient): Ditto. * server.c (gpgsm_status2): New. Allows for a list of strings. (gpgsm_status): Divert to gpgsm_status2. * encrypt.c (gpgsm_encrypt): Don't use a default key when no recipients are given. Print a NO_RECP status. 2002-03-06 Werner Koch * server.c (cmd_listkeys, cmd_listsecretkeys): Divert to (do_listkeys): new. Add pattern parsing. * keylist.c (gpgsm_list_keys): Handle selection pattern. * gpgsm.c: New command --learn-card * call-agent.c (learn_cb,gpgsm_agent_learn): New. * gpgsm.c (main): Print error messages for non-implemented commands. * base64.c (base64_reader_cb): Use case insensitive compare of the Content-Type string to detect plain base-64. 2002-03-05 Werner Koch * gpgsm.c, gpgsm.h: Add local_user. * sign.c (gpgsm_get_default_cert): New. (get_default_signer): Use the new function if local_user is not set otherwise used that value. * encrypt.c (get_default_recipient): Removed. (gpgsm_encrypt): Use gpgsm_get_default_cert. * verify.c (gpgsm_verify): Better error text for a bad signature found by comparing the hashs. 2002-02-27 Werner Koch * call-dirmngr.c, call-agent.c: Add 2 more arguments to all uses of assuan_transact. 2002-02-25 Werner Koch * server.c (option_handler): Allow to use -2 for "send all certs except the root cert". * sign.c (add_certificate_list): Implement it here. * certpath.c (gpgsm_is_root_cert): New. 2002-02-19 Werner Koch * certpath.c (check_cert_policy): New. (gpgsm_validate_path): And call it from here. * gpgsm.c (main): New options --policy-file, --disable-policy-checks and --enable-policy-checks. * gpgsm.h (opt): Added policy_file, no_policy_checks. 2002-02-18 Werner Koch * certpath.c (gpgsm_validate_path): Ask the agent to add the certificate into the trusted list. * call-agent.c (gpgsm_agent_marktrusted): New. 2002-02-07 Werner Koch * certlist.c (gpgsm_add_to_certlist): Check that the specified name identifies a certificate unambiguously. (gpgsm_find_cert): Ditto. * server.c (cmd_listkeys): Check that the data stream is available. (cmd_listsecretkeys): Ditto. (has_option): New. (cmd_sign): Fix ambiguousity in option recognition. * gpgsm.c (main): Enable --logger-fd. * encrypt.c (gpgsm_encrypt): Increased buffer size for better performance. * call-agent.c (gpgsm_agent_pksign): Check the S-Exp received from the agent. * keylist.c (list_cert_colon): Filter out control characters. 2002-02-06 Werner Koch * decrypt.c (gpgsm_decrypt): Bail out after an decryption error. * server.c (reset_notify): Close input and output FDs. (cmd_encrypt,cmd_decrypt,cmd_verify,cmd_sign.cmd_import) (cmd_genkey): Close the FDs and release the recipient list even in the error case. 2002-02-01 Marcus Brinkmann * sign.c (gpgsm_sign): Do not release certificate twice. 2002-01-29 Werner Koch * call-agent.c (gpgsm_agent_havekey): New. * keylist.c (list_cert_colon): New arg HAVE_SECRET, print "crs" when we know that the secret key is available. (gpgsm_list_keys): New arg MODE, check whether a secret key is available. Changed all callers. * gpgsm.c (main): New command --list-secret-keys. * server.c (cmd_listsecretkeys): New. (cmd_listkeys): Return secret keys with "crs" record. 2002-01-28 Werner Koch * certreqgen.c (create_request): Store the email address in the req. 2002-01-25 Werner Koch * gpgsm.c (main): Disable core dumps. * sign.c (add_certificate_list): New. (gpgsm_sign): Add the certificates to the CMS object. * certpath.c (gpgsm_walk_cert_chain): New. * gpgsm.h (server_control_s): Add included_certs. * gpgsm.c: Add option --include-certs. (gpgsm_init_default_ctrl): New. (main): Call it. * server.c (gpgsm_server): Ditto. (option_handler): Support --include-certs. 2002-01-23 Werner Koch * certpath.c (gpgsm_validate_path): Print the DN of a missing issuer. * certdump.c (gpgsm_dump_string): New. (print_dn): Replaced by above. 2002-01-22 Werner Koch * certpath.c (unknown_criticals): New. (allowed_ca): New. (gpgsm_validate_path): Check validity, CA attribute, path length and unknown critical extensions. 2002-01-21 Werner Koch * gpgsm.c: Add option --enable-crl-checks. * call-agent.c (start_agent): Implemented socket based access. * call-dirmngr.c (start_dirmngr): Ditto. 2002-01-20 Werner Koch * server.c (option_handler): New. (gpgsm_server): Register it with assuan. 2002-01-19 Werner Koch * server.c (gpgsm_server): Use assuan_deinit_server and setup assuan logging if enabled. * call-agent.c (inq_ciphertext_cb): Don't show the session key in an Assuan log file. * gpgsm.c (my_strusage): Take bugreport address from configure.ac 2002-01-15 Werner Koch * import.c (gpgsm_import): Just do a basic cert check before storing it. * certpath.c (gpgsm_basic_cert_check): New. * keydb.c (keydb_store_cert): New. * import.c (store_cert): Removed and change all caller to use the new function. * verify.c (store_cert): Ditto. * certlist.c (gpgsm_add_to_certlist): Validate the path * certpath.c (gpgsm_validate_path): Check the trust list. * call-agent.c (gpgsm_agent_istrusted): New. 2002-01-14 Werner Koch * call-dirmngr.c (inq_certificate): Changed for new interface semantic. * certlist.c (gpgsm_find_cert): New. 2002-01-13 Werner Koch * fingerprint.c (gpgsm_get_certid): Print the serial and not the hash after the dot. 2002-01-11 Werner Koch * call-dirmngr.c: New. * certpath.c (gpgsm_validate_path): Check the CRL here. * fingerprint.c (gpgsm_get_certid): New. * gpgsm.c: New options --dirmngr-program and --disable-crl-checks. 2002-01-10 Werner Koch * base64.c (gpgsm_create_writer): Allow to set the object name 2002-01-08 Werner Koch * keydb.c (spacep): Removed because it is now in util.c * server.c (cmd_genkey): New. * certreqgen.c: New. The parameter handling code has been taken from gnupg/g10/keygen.c version 1.0.6. * call-agent.c (gpgsm_agent_genkey): New. 2002-01-02 Werner Koch * server.c (rc_to_assuan_status): Removed and changed all callers to use map_to_assuan_status. 2001-12-20 Werner Koch * verify.c (gpgsm_verify): Implemented non-detached signature verification. Add OUT_FP arg, initialize a writer and changed all callers. * server.c (cmd_verify): Pass an out_fp if one has been set. * base64.c (base64_reader_cb): Try to detect an S/MIME body part. * certdump.c (print_sexp): Renamed to gpgsm_dump_serial, made global. (print_time): Renamed to gpgsm_dump_time, made global. (gpgsm_dump_serial): Take a real S-Expression as argument and print the first item. * keylist.c (list_cert_colon): Ditto. * keydb.c (keydb_search_issuer_sn): Ditto. * decrypt.c (print_integer_sexp): Removed and made callers use gpgsm_dump_serial. * verify.c (print_time): Removed, made callers use gpgsm_dump_time. 2001-12-19 Marcus Brinkmann * call-agent.c (start_agent): Add new argument to assuan_pipe_connect. 2001-12-18 Werner Koch * verify.c (print_integer_sexp): Renamed from print_integer and print the serial number according to the S-Exp rules. * decrypt.c (print_integer_sexp): Ditto. 2001-12-17 Werner Koch * keylist.c (list_cert_colon): Changed for new return value of get_serial. * keydb.c (keydb_search_issuer_sn): Ditto. * certcheck.c (gpgsm_check_cert_sig): Likewise for other S-Exp returingin functions. * fingerprint.c (gpgsm_get_keygrip): Ditto. * encrypt.c (encrypt_dek): Ditto * certcheck.c (gpgsm_check_cms_signature): Ditto * decrypt.c (prepare_decryption): Ditto. * call-agent.c (gpgsm_agent_pkdecrypt): Removed arg ciphertextlen, use KsbaSexp type and calculate the length. * certdump.c (print_sexp): Remaned from print_integer, changed caller. * Makefile.am: Use the LIBGCRYPT and LIBKSBA variables. * fingerprint.c (gpgsm_get_keygrip): Use the new gcry_pk_get_keygrip to calculate the grip - note the algorithm and therefore the grip values changed. 2001-12-15 Werner Koch * certcheck.c (gpgsm_check_cms_signature): Removed the faked-key kludge. (gpgsm_create_cms_signature): Removed the commented fake key code. This makes the function pretty simple. * gpgsm.c (main): Renamed the default key database to "keyring.kbx". * decrypt.c (gpgsm_decrypt): Write STATUS_DECRYPTION_*. * sign.c (gpgsm_sign): Write a STATUS_SIG_CREATED. 2001-12-14 Werner Koch * keylist.c (list_cert_colon): Kludge to show an email address encoded in the subject's DN. * verify.c (gpgsm_verify): Add hash debug helpers * sign.c (gpgsm_sign): Ditto. * base64.c (base64_reader_cb): Reset the linelen when we need to skip the line and adjusted test; I somehow forgot about DeMorgan. * server.c (cmd_encrypt,cmd_decrypt,cmd_sign,cmd_verify) (cmd_import): Close the FDs on success. (close_message_fd): New. (input_notify): Setting autodetect_encoding to 0 after initializing it to 0 is pretty pointless. Easy to fix. * gpgsm.c (main): New option --debug-wait n, so that it is possible to attach gdb when used in server mode. * sign.c (get_default_signer): Use keydb_classify_name here. 2001-12-14 Marcus Brinkmann * call-agent.c (LINELENGTH): Removed. (gpgsm_agent_pksign): Use ASSUAN_LINELENGTH, not LINELENGTH. (gpgsm_agent_pkdecrypt): Likewise. 2001-12-13 Werner Koch * keylist.c (list_cert_colon): Print alternative names of subject and a few other values. 2001-12-12 Werner Koch * gpgsm.c (main): New options --assume-{armor,base64,binary}. * base64.c (base64_reader_cb): Fixed non-autodetection mode. 2001-12-04 Werner Koch * call-agent.c (read_from_agent): Check for inquire responses. (request_reply): Handle them using a new callback arg, changed all callers. (gpgsm_agent_pkdecrypt): New. 2001-11-27 Werner Koch * base64.c: New. Changed all other functions to use this instead of direct creation of ksba_reader/writer. * gpgsm.c (main): Set ctrl.auto_encoding unless --no-armor is used. 2001-11-26 Werner Koch * gpgsm.c: New option --agent-program * call-agent.c (start_agent): Allow to override the default path to the agent. * keydb.c (keydb_add_resource): Create keybox * keylist.c (gpgsm_list_keys): Fixed non-server keylisting. * server.c (rc_to_assuan_status): New. Use it for all commands. Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 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/sm/Makefile.am b/sm/Makefile.am index 2bbdd1b59..ba194811d 100644 --- a/sm/Makefile.am +++ b/sm/Makefile.am @@ -1,69 +1,68 @@ # Copyright (C) 2001, 2002, 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 3 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, see . ## Process this file with automake to produce Makefile.in bin_PROGRAMS = gpgsm AM_CFLAGS = $(LIBGCRYPT_CFLAGS) $(KSBA_CFLAGS) $(LIBASSUAN_CFLAGS) AM_CPPFLAGS = -I$(top_srcdir)/gl -I$(top_srcdir)/common -I$(top_srcdir)/intl include $(top_srcdir)/am/cmacros.am gpgsm_SOURCES = \ gpgsm.c gpgsm.h \ misc.c \ keydb.c keydb.h \ server.c \ call-agent.c \ call-dirmngr.c \ fingerprint.c \ base64.c \ certlist.c \ certdump.c \ certcheck.c \ certchain.c \ keylist.c \ verify.c \ sign.c \ encrypt.c \ decrypt.c \ import.c \ export.c \ delete.c \ certreqgen.c \ certreqgen-ui.c \ qualified.c -common_libs = $(libcommon) ../kbx/libkeybox.a ../jnlib/libjnlib.a \ - ../gl/libgnu.a +common_libs = ../kbx/libkeybox.a $(libcommon) ../gl/libgnu.a gpgsm_LDADD = $(common_libs) ../common/libgpgrl.a \ $(LIBGCRYPT_LIBS) $(KSBA_LIBS) $(LIBASSUAN_LIBS) \ $(GPG_ERROR_LIBS) $(LIBREADLINE) $(LIBINTL) $(ZLIBS) $(LIBICONV) # Make sure that all libs are build before we use them. This is # important for things like make -j2. $(PROGRAMS): $(common_libs) diff --git a/sm/gpgsm.h b/sm/gpgsm.h index 7e0353060..542c292ac 100644 --- a/sm/gpgsm.h +++ b/sm/gpgsm.h @@ -1,425 +1,424 @@ /* gpgsm.h - Global definitions for GpgSM * Copyright (C) 2001, 2003, 2004, 2007, 2009, * 2010 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 3 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, see . */ #ifndef GPGSM_H #define GPGSM_H #ifdef GPG_ERR_SOURCE_DEFAULT #error GPG_ERR_SOURCE_DEFAULT already defined #endif #define GPG_ERR_SOURCE_DEFAULT GPG_ERR_SOURCE_GPGSM #include #include #include "../common/util.h" #include "../common/status.h" -#include "../common/estream.h" #include "../common/audit.h" #include "../common/session-env.h" #define MAX_DIGEST_LEN 64 struct keyserver_spec { struct keyserver_spec *next; char *host; int port; char *user; char *pass; char *base; }; /* A large struct named "opt" to keep global flags. */ struct { unsigned int debug; /* debug flags (DBG_foo_VALUE) */ int verbose; /* verbosity level */ int quiet; /* be as quiet as possible */ int batch; /* run in batch mode, i.e w/o any user interaction */ int answer_yes; /* assume yes on most questions */ int answer_no; /* assume no on most questions */ int dry_run; /* don't change any persistent data */ const char *homedir; /* Configuration directory name */ const char *config_filename; /* Name of the used config file. */ const char *agent_program; session_env_t session_env; char *lc_ctype; char *lc_messages; const char *dirmngr_program; int prefer_system_dirmngr; /* Prefer using a system wide drimngr. */ int disable_dirmngr; /* Do not do any dirmngr calls. */ const char *protect_tool_program; char *outfile; /* name of output file */ int with_key_data;/* include raw key in the column delimted output */ int fingerprint; /* list fingerprints in all key listings */ int with_md5_fingerprint; /* Also print an MD5 fingerprint for standard key listings. */ int armor; /* force base64 armoring (see also ctrl.with_base64) */ int no_armor; /* don't try to figure out whether data is base64 armored*/ const char *p12_charset; /* Use this charset for encoding the pkcs#12 passphrase. */ const char *def_cipher_algoid; /* cipher algorithm to use if nothing else is specified */ int def_compress_algo; /* Ditto for compress algorithm */ int forced_digest_algo; /* User forced hash algorithm. */ char *def_recipient; /* userID of the default recipient */ int def_recipient_self; /* The default recipient is the default key */ int no_encrypt_to; /* Ignore all as encrypt to marked recipients. */ char *local_user; /* NULL or argument to -u */ int extra_digest_algo; /* A digest algorithm also used for verification of signatures. */ int always_trust; /* Trust the given keys even if there is no valid certification chain */ int skip_verify; /* do not check signatures on data */ int lock_once; /* Keep lock once they are set */ int ignore_time_conflict; /* Ignore certain time conflicts */ int no_crl_check; /* Don't do a CRL check */ int no_trusted_cert_crl_check; /* Don't run a CRL check for trusted certs. */ int force_crl_refresh; /* Force refreshing the CRL. */ int enable_ocsp; /* Default to use OCSP checks. */ char *policy_file; /* full pathname of policy file */ int no_policy_check; /* ignore certificate policies */ int no_chain_validation; /* Bypass all cert chain validity tests */ int ignore_expiration; /* Ignore the notAfter validity checks. */ char *fixed_passphrase; /* Passphrase used by regression tests. */ int auto_issuer_key_retrieve; /* try to retrieve a missing issuer key. */ int qualsig_approval; /* Set to true if this software has officially been approved to create an verify qualified signatures. This is a runtime option in case we want to check the integrity of the software at runtime. */ struct keyserver_spec *keyserver; /* A list of certificate extension OIDs which are ignored so that one can claim that a critical extension has been handled. One OID per string. */ strlist_t ignored_cert_extensions; } opt; /* Debug values and macros. */ #define DBG_X509_VALUE 1 /* debug x.509 data reading/writing */ #define DBG_MPI_VALUE 2 /* debug mpi details */ #define DBG_CRYPTO_VALUE 4 /* debug low level crypto */ #define DBG_MEMORY_VALUE 32 /* debug memory allocation stuff */ #define DBG_CACHE_VALUE 64 /* debug the caching */ #define DBG_MEMSTAT_VALUE 128 /* show memory statistics */ #define DBG_HASHING_VALUE 512 /* debug hashing operations */ #define DBG_ASSUAN_VALUE 1024 /* debug assuan communication */ #define DBG_X509 (opt.debug & DBG_X509_VALUE) #define DBG_CRYPTO (opt.debug & DBG_CRYPTO_VALUE) #define DBG_MEMORY (opt.debug & DBG_MEMORY_VALUE) #define DBG_CACHE (opt.debug & DBG_CACHE_VALUE) #define DBG_HASHING (opt.debug & DBG_HASHING_VALUE) #define DBG_ASSUAN (opt.debug & DBG_ASSUAN_VALUE) /* Forward declaration for an object defined in server.c */ struct server_local_s; /* Session control object. This object is passed down to most functions. Note that the default values for it are set by gpgsm_init_default_ctrl(). */ struct server_control_s { int no_server; /* We are not running under server control */ int status_fd; /* Only for non-server mode */ struct server_local_s *server_local; audit_ctx_t audit; /* NULL or a context for the audit subsystem. */ int agent_seen; /* Flag indicating that the gpg-agent has been accessed. */ int with_colons; /* Use column delimited output format */ int with_chain; /* Include the certifying certs in a listing */ int with_validation;/* Validate each key while listing. */ int with_ephemeral_keys; /* Include ephemeral flagged keys in the keylisting. */ int autodetect_encoding; /* Try to detect the input encoding */ int is_pem; /* Is in PEM format */ int is_base64; /* is in plain base-64 format */ int create_base64; /* Create base64 encoded output */ int create_pem; /* create PEM output */ const char *pem_name; /* PEM name to use */ int include_certs; /* -1 to send all certificates in the chain along with a signature or the number of certificates up the chain (0 = none, 1 = only signer) */ int use_ocsp; /* Set to true if OCSP should be used. */ int validation_model; /* Set to 1 for the chain model. */ }; /* Data structure used in base64.c. */ typedef struct base64_context_s *Base64Context; /* An object to keep a list of certificates. */ struct certlist_s { struct certlist_s *next; ksba_cert_t cert; int is_encrypt_to; /* True if the certificate has been set through the --encrypto-to option. */ int hash_algo; /* Used to track the hash algorithm to use. */ const char *hash_algo_oid; /* And the corresponding OID. */ }; typedef struct certlist_s *certlist_t; /* A structure carrying information about trusted root certificates. */ struct rootca_flags_s { unsigned int valid:1; /* The rest of the structure has valid information. */ unsigned int relax:1; /* Relax checking of root certificates. */ unsigned int chain_model:1; /* Root requires the use of the chain model. */ }; /*-- gpgsm.c --*/ void gpgsm_exit (int rc); void gpgsm_init_default_ctrl (struct server_control_s *ctrl); int gpgsm_parse_validation_model (const char *model); /*-- server.c --*/ void gpgsm_server (certlist_t default_recplist); gpg_error_t gpgsm_status (ctrl_t ctrl, int no, const char *text); gpg_error_t gpgsm_status2 (ctrl_t ctrl, int no, ...) GNUPG_GCC_A_SENTINEL(0); gpg_error_t gpgsm_status_with_err_code (ctrl_t ctrl, int no, const char *text, gpg_err_code_t ec); gpg_error_t gpgsm_proxy_pinentry_notify (ctrl_t ctrl, const unsigned char *line); /*-- fingerprint --*/ unsigned char *gpgsm_get_fingerprint (ksba_cert_t cert, int algo, unsigned char *array, int *r_len); char *gpgsm_get_fingerprint_string (ksba_cert_t cert, int algo); char *gpgsm_get_fingerprint_hexstring (ksba_cert_t cert, int algo); unsigned long gpgsm_get_short_fingerprint (ksba_cert_t cert, unsigned long *r_high); unsigned char *gpgsm_get_keygrip (ksba_cert_t cert, unsigned char *array); char *gpgsm_get_keygrip_hexstring (ksba_cert_t cert); int gpgsm_get_key_algo_info (ksba_cert_t cert, unsigned int *nbits); char *gpgsm_get_certid (ksba_cert_t cert); /*-- base64.c --*/ int gpgsm_create_reader (Base64Context *ctx, ctrl_t ctrl, estream_t fp, int allow_multi_pem, ksba_reader_t *r_reader); int gpgsm_reader_eof_seen (Base64Context ctx); void gpgsm_destroy_reader (Base64Context ctx); int gpgsm_create_writer (Base64Context *ctx, ctrl_t ctrl, FILE *fp, estream_t stream, ksba_writer_t *r_writer); int gpgsm_finish_writer (Base64Context ctx); void gpgsm_destroy_writer (Base64Context ctx); /*-- certdump.c --*/ void gpgsm_print_serial (estream_t fp, ksba_const_sexp_t p); void gpgsm_print_time (estream_t fp, ksba_isotime_t t); void gpgsm_print_name2 (FILE *fp, const char *string, int translate); void gpgsm_print_name (FILE *fp, const char *string); void gpgsm_es_print_name (estream_t fp, const char *string); void gpgsm_es_print_name2 (estream_t fp, const char *string, int translate); void gpgsm_cert_log_name (const char *text, ksba_cert_t cert); void gpgsm_dump_cert (const char *text, ksba_cert_t cert); void gpgsm_dump_serial (ksba_const_sexp_t p); void gpgsm_dump_time (ksba_isotime_t t); void gpgsm_dump_string (const char *string); char *gpgsm_format_serial (ksba_const_sexp_t p); char *gpgsm_format_name2 (const char *name, int translate); char *gpgsm_format_name (const char *name); char *gpgsm_format_sn_issuer (ksba_sexp_t sn, const char *issuer); char *gpgsm_fpr_and_name_for_status (ksba_cert_t cert); char *gpgsm_format_keydesc (ksba_cert_t cert); /*-- certcheck.c --*/ int gpgsm_check_cert_sig (ksba_cert_t issuer_cert, ksba_cert_t cert); int gpgsm_check_cms_signature (ksba_cert_t cert, ksba_const_sexp_t sigval, gcry_md_hd_t md, int hash_algo, int *r_pkalgo); /* fixme: move create functions to another file */ int gpgsm_create_cms_signature (ctrl_t ctrl, ksba_cert_t cert, gcry_md_hd_t md, int mdalgo, unsigned char **r_sigval); /*-- certchain.c --*/ /* Flags used with gpgsm_validate_chain. */ #define VALIDATE_FLAG_NO_DIRMNGR 1 #define VALIDATE_FLAG_CHAIN_MODEL 2 int gpgsm_walk_cert_chain (ctrl_t ctrl, ksba_cert_t start, ksba_cert_t *r_next); int gpgsm_is_root_cert (ksba_cert_t cert); int gpgsm_validate_chain (ctrl_t ctrl, ksba_cert_t cert, ksba_isotime_t checktime, ksba_isotime_t r_exptime, int listmode, estream_t listfp, unsigned int flags, unsigned int *retflags); int gpgsm_basic_cert_check (ctrl_t ctrl, ksba_cert_t cert); /*-- certlist.c --*/ int gpgsm_cert_use_sign_p (ksba_cert_t cert); int gpgsm_cert_use_encrypt_p (ksba_cert_t cert); int gpgsm_cert_use_verify_p (ksba_cert_t cert); int gpgsm_cert_use_decrypt_p (ksba_cert_t cert); int gpgsm_cert_use_cert_p (ksba_cert_t cert); int gpgsm_cert_use_ocsp_p (ksba_cert_t cert); int gpgsm_certs_identical_p (ksba_cert_t cert_a, ksba_cert_t cert_b); int gpgsm_add_cert_to_certlist (ctrl_t ctrl, ksba_cert_t cert, certlist_t *listaddr, int is_encrypt_to); int gpgsm_add_to_certlist (ctrl_t ctrl, const char *name, int secret, certlist_t *listaddr, int is_encrypt_to); void gpgsm_release_certlist (certlist_t list); int gpgsm_find_cert (const char *name, ksba_sexp_t keyid, ksba_cert_t *r_cert); /*-- keylist.c --*/ gpg_error_t gpgsm_list_keys (ctrl_t ctrl, strlist_t names, estream_t fp, unsigned int mode); /*-- import.c --*/ int gpgsm_import (ctrl_t ctrl, int in_fd, int reimport_mode); int gpgsm_import_files (ctrl_t ctrl, int nfiles, char **files, int (*of)(const char *fname)); /*-- export.c --*/ void gpgsm_export (ctrl_t ctrl, strlist_t names, estream_t stream); void gpgsm_p12_export (ctrl_t ctrl, const char *name, FILE *fp); /*-- delete.c --*/ int gpgsm_delete (ctrl_t ctrl, strlist_t names); /*-- verify.c --*/ int gpgsm_verify (ctrl_t ctrl, int in_fd, int data_fd, estream_t out_fp); /*-- sign.c --*/ int gpgsm_get_default_cert (ctrl_t ctrl, ksba_cert_t *r_cert); int gpgsm_sign (ctrl_t ctrl, certlist_t signerlist, int data_fd, int detached, estream_t out_fp); /*-- encrypt.c --*/ int gpgsm_encrypt (ctrl_t ctrl, certlist_t recplist, int in_fd, estream_t out_fp); /*-- decrypt.c --*/ int gpgsm_decrypt (ctrl_t ctrl, int in_fd, estream_t out_fp); /*-- certreqgen.c --*/ int gpgsm_genkey (ctrl_t ctrl, estream_t in_stream, estream_t out_stream); /*-- certreqgen-ui.c --*/ void gpgsm_gencertreq_tty (ctrl_t ctrl, estream_t out_stream); /*-- qualified.c --*/ gpg_error_t gpgsm_is_in_qualified_list (ctrl_t ctrl, ksba_cert_t cert, char *country); gpg_error_t gpgsm_qualified_consent (ctrl_t ctrl, ksba_cert_t cert); gpg_error_t gpgsm_not_qualified_warning (ctrl_t ctrl, ksba_cert_t cert); /*-- call-agent.c --*/ int gpgsm_agent_pksign (ctrl_t ctrl, const char *keygrip, const char *desc, unsigned char *digest, size_t digestlen, int digestalgo, unsigned char **r_buf, size_t *r_buflen); int gpgsm_scd_pksign (ctrl_t ctrl, const char *keyid, const char *desc, unsigned char *digest, size_t digestlen, int digestalgo, unsigned char **r_buf, size_t *r_buflen); int gpgsm_agent_pkdecrypt (ctrl_t ctrl, const char *keygrip, const char *desc, ksba_const_sexp_t ciphertext, char **r_buf, size_t *r_buflen); int gpgsm_agent_genkey (ctrl_t ctrl, ksba_const_sexp_t keyparms, ksba_sexp_t *r_pubkey); int gpgsm_agent_readkey (ctrl_t ctrl, int fromcard, const char *hexkeygrip, ksba_sexp_t *r_pubkey); int gpgsm_agent_scd_serialno (ctrl_t ctrl, char **r_serialno); int gpgsm_agent_scd_keypairinfo (ctrl_t ctrl, strlist_t *r_list); int gpgsm_agent_istrusted (ctrl_t ctrl, ksba_cert_t cert, const char *hexfpr, struct rootca_flags_s *rootca_flags); int gpgsm_agent_havekey (ctrl_t ctrl, const char *hexkeygrip); int gpgsm_agent_marktrusted (ctrl_t ctrl, ksba_cert_t cert); int gpgsm_agent_learn (ctrl_t ctrl); int gpgsm_agent_passwd (ctrl_t ctrl, const char *hexkeygrip, const char *desc); gpg_error_t gpgsm_agent_get_confirmation (ctrl_t ctrl, const char *desc); gpg_error_t gpgsm_agent_send_nop (ctrl_t ctrl); gpg_error_t gpgsm_agent_keyinfo (ctrl_t ctrl, const char *hexkeygrip, char **r_serialno); /*-- call-dirmngr.c --*/ int gpgsm_dirmngr_isvalid (ctrl_t ctrl, ksba_cert_t cert, ksba_cert_t issuer_cert, int use_ocsp); int gpgsm_dirmngr_lookup (ctrl_t ctrl, strlist_t names, int cache_only, void (*cb)(void*, ksba_cert_t), void *cb_value); int gpgsm_dirmngr_run_command (ctrl_t ctrl, const char *command, int argc, char **argv); /*-- misc.c --*/ void setup_pinentry_env (void); #endif /*GPGSM_H*/ diff --git a/tools/ChangeLog b/tools/ChangeLog index 24196fa32..048c1685a 100644 --- a/tools/ChangeLog +++ b/tools/ChangeLog @@ -1,1086 +1,1090 @@ +2010-03-10 Werner Koch + + * Makefile.am (common_libs): Remove libjnlib.a. + 2010-03-08 Werner Koch * no-libgcrypt.c (gcry_create_nonce): New. 2010-02-26 Werner Koch * gpg-connect-agent.c (main): New option --tcp-socket. 2010-01-10 Werner Koch * symcryptrun.c (utmp.h): Remove header; it is not used. 2009-12-18 Werner Koch * applygnupgdefaults (errorfile): Use mktemp. Fixes bug#1146. 2009-12-08 Marcus Brinkmann * gpg-connect-agent.c (main): Convert posix fd to assuan fd. 2009-12-07 Werner Koch * no-libgcrypt.c (gcry_strdup): Actually copy the string. 2009-11-23 Werner Koch * gpgconf-comp.c (gc_options_gpg): Add default_pubkey_algo. 2009-11-05 Marcus Brinkmann * gpg-connect-agent.c (start_agent): Update use of assuan_socket_connect and assuan_pipe_connect. 2009-11-04 Werner Koch * gpg-connect-agent.c (read_and_print_response): Add arg WITHHASH. (main): Pass true for WITHHASH for the HELP command. 2009-09-23 Marcus Brinkmann * gpg-connect-agent.c (getinfo_pid_cb, read_and_print_response) (main): Update to new Assuan API. 2009-07-21 Werner Koch * gpgsplit.c (my_strusage): Remove i18n stuff. 2009-07-07 Werner Koch * gpg-connect-agent.c (start_agent): Adjust for changed args of send_pinentry_environment. 2009-06-30 Werner Koch * ccidmon.c (parse_line_sniffusb): Take also TAB as delimiter. 2009-06-29 Werner Koch * ccidmon.c (parse_line_sniffusb): New. (main): Add option --sniffusb. 2009-06-08 Werner Koch * gpgconf.c (main): Call gnupg_reopen_std. Should fix bug#1072. 2009-05-19 Werner Koch * watchgnupg.c: Include jnlib/mischelp.h if required. (main): Use SUN_LEN. 2009-04-17 Werner Koch * ccidmon.c: New. 2009-03-03 Werner Koch * gpgconf.c: New command --reload. * gpgconf-comp.c (gc_component_reload): New. 2009-03-02 Werner Koch * gpgconf-comp.c (scdaemon_runtime_change): Killsc d only if it is not running. 2009-02-27 Werner Koch * gpgconf-comp.c (gpg_agent_runtime_change): Declare static. (scdaemon_runtime_change): New. (gc_backend_scdaemon): Register new function. (gc_options_scdaemon): Make most options runtime changable. 2009-01-20 Werner Koch * gpgconf.c (main): Print more directories. 2008-12-09 Werner Koch * gpg-check-pattern.c (main): Call i18n_init before init_common_subsystems. * gpg-connect-agent.c (main): Ditto. * gpgconf.c (main): Ditto. * symcryptrun.c (main): Ditto. 2008-12-08 Werner Koch * gpgkey2ssh.c (main): Change order of output for RSA. Change name of DSA identifier. Reported by Daniel Kahn Gillmor. This is bug#901. 2008-12-05 Werner Koch * gpg-connect-agent.c (opts): Use ARGPARSE_ macros. (start_agent) [W32]: Start agent if not running. 2008-12-03 Werner Koch * gpgconf-comp.c : Add option --card-timeout. Remove unused option --disable-opensc. 2008-10-20 Werner Koch * gpgsplit.c (write_part): Remove unused arg FNAME. Change caller. (do_split): Ditto. * no-libgcrypt.c (gcry_control): Mark unused arg. * gpg-connect-agent.c (do_recvfd): Ditto. * gpgparsemail.c (mime_signed_begin, mime_encrypted_begin): Ditto. (pkcs7_begin): Ditto. 2008-10-01 Werner Koch * gpg-connect-agent.c (main): New command datafile. (read_and_print_response): Print to the defined datafile. 2008-09-30 Werner Koch * gpgconf.c (main) : Print the bindir. 2008-08-06 Marcus Brinkmann * gpgconf-comp.c (gc_options_gpgsm): Change type of keyserver option to GC_ARG_TYPE_LDAP_SERVER. * gpgconf-comp.c (retrieve_options_from_file): Transfer the NO_CHANGE flag from the file name option to the list option. 2008-06-19 Werner Koch * gpgconf-comp.c (GC_ARG_TYPE_ALIAS_LIST): New. (gc_arg_type): Add fallback type. (gc_options_gpg): Add option "group". 2008-06-12 Marcus Brinkmann * gpgconf-comp.c (gc_options_gpgsm): Add option keyserver. 2008-05-26 Marcus Brinkmann * gpgconf-comp.c: Replace pathname by filename everywhere. * gpgconf.c (enum cmd_and_opt_values): Add aListDirs. (opts): Add aListDirs option. (main): Handle aListDirs. * gpgconf.h (gc_percent_escape): New declaration. * gpgconf-comp.c (my_percent_escape): Make non-static and rename to ... (gc_percent_escape): ... this. Change all callers. 2008-05-26 Werner Koch * gpgconf-comp.c (gpg_agent_runtime_change) [W32]: Issue "reloadagent" command to gpg-agent. * gpg-connect-agent.c (main): Allow server command on the command line. 2008-05-20 Marcus Brinkmann * gpgconf.h (gc_component_check_programs): Rename to ... (gc_check_programs): ... this. (gc_component_change_options): Add argument OUT. (gc_component_check_options): New function. * gpgconf.c (enum cmd_and_opt_values): New option aCheckOptions. (opts): Add new option aCheckOptions (aka --check-options). (main): Handle new option aCheckOptions. * gpgconf-comp.c (gc_component_check_programs): Rename to ... (gc_check_programs): ... this. Refactor core of it to ... (gc_component_check_options): ... this new function. (gc_component_change_options): Add new argument OUT. Externally verify all changes. Implement option --dry-run. 2008-05-09 Werner Koch * gpgconf-comp.c (my_dgettext) [USE_SIMPLE_GETTEXT]: Hack to parly support translations. 2008-04-08 Werner Koch * gpgconf-comp.c (gc_options_gpg): Add --auto-key-locate. 2008-03-26 Werner Koch * make-dns-cert.c: Include unistd.h. Use config.h if requested. (cert_key): Protect read against EINTR. (main): Print SVN revision for standalone version. 2008-03-05 Werner Koch * gpg-connect-agent.c (arithmetic_op): Add logical not, or and and. (get_var_ext): Add functions errcode, errsource and errstring. (read_and_print_response): Store server reply in $? variable. (main): Implement IF command. 2008-02-27 Marcus Brinkmann * gpgconf-comp.c (option_check_validity): For now, error out on empty strings. (enum): Add GC_ARG_TYPE_PUB_KEY and GC_ARG_TYPE_SEC_KEY. 2008-02-01 Marcus Brinkmann * gpgconf-comp.c (gc_component_list_options): Fix memcpy. Reported by Marc Mutz. 2008-01-22 Werner Koch * gpgconf-comp.c: Use gnupg domain for honor-http-proxy. Make "LDAP server list" group title translatable. 2008-01-17 Marcus Brinkmann * gpgconf-comp.c (change_options_program): Strip duplicated utf8-strings entries for gnupg backend. Don't create them either. 2007-12-10 Marcus Brinkmann * gpgconf-comp.c (gc_component_list_options): Fix up expert level of group. 2007-12-04 Marcus Brinkmann * gpgconf-comp.c (gc_component_list_components): Do not print a trailing semi-colon to ensure forward compatibility, as this would indicate another empty field. (gc_process_gpgconf_conf): Likewise. 2007-11-15 Werner Koch * gpg-connect-agent.c (start_agent): Adjust changed send_pinentry_environment. 2007-10-24 Werner Koch * gpg-connect-agent.c (substitute_line): Restore temporary nul marker. (main): Add /while command. 2007-10-23 Werner Koch * gpgconf-comp.c (gc_process_gpgconf_conf): Add arg LISTFP. Changed all callers. * gpgconf.h: Add gc_error. * gpgconf.c: Add command --list-config. (get_outfp): New. (main): Make --output work. * gpgconf-comp.c (gc_options_gpg_agent): Replace accidently used GC_BACKEND_SCDAEMON. We should consider to create these tables from plain files. 2007-10-22 Werner Koch * gpgconf-comp.c (retrieve_options_from_program): Replace use of popen by our gnupg_spawn_process_fd. This is required because popen under Windows can't handle long filenames. 2007-10-19 Werner Koch * symcryptrun.c (confucius_get_pass): Use utf8 switching functions. * gpg-connect-agent.c (get_var_ext): New. (substitute_line): Use it. (assign_variable): Implement /slet in terms of get_var_ext. (main): New option -s/--subst. (add_definq): Add arg IS_VAR. Change all callers. (main): Add command /definq. (handle_inquire): Implement new command. (substitute_line_copy): New. (unescape_string, unpercent_string): New. * no-libgcrypt.c (gcry_set_outofcore_handler) (gcry_set_fatalerror_handler, gcry_set_log_handler): New. * Makefile.am (gpg_connect_agent_LDADD): Link to libreadline. * gpgconf-comp.c (retrieve_options_from_file): Don't call fclose with NULL. Fixes bug 842. 2007-10-12 Werner Koch * gpg-connect-agent.c (substitute_line): Allow ${foo} syntax. 2007-10-11 Werner Koch * gpg-connect-agent.c (get_var): Expand environment variables. Suggested by Marc Mutz. (set_var): Return the value. (assign_variable): Add arg syslet. (main): New command /slet. (gnu_getcwd): New. (assign_variable): Add tag cwd, and *dir. 2007-10-02 Werner Koch * no-libgcrypt.c (gcry_malloc_secure): New. * gpg-connect-agent.c (set_var, set_int_var, get_var) (substitute_line, show_variables, assign_variable) (do_open, do_close, do_showopen): New. (main): Add new commands /nosubst, /subst, /let, /showvar, /open, /close and /showopen. (main): New commands /run and /bye. 2007-10-01 Werner Koch * gpg-connect-agent.c (do_sendfd): Use INT2FD for assuan_sendfd. 2007-09-26 Werner Koch * gpg-connect-agent.c (main): Print the first response from the server. 2007-09-14 Werner Koch * gpgconf-comp.c: Make a string translatable. 2007-09-04 Moritz Schulte * gpgsm-gencert.sh: Use printf instead of echo. 2007-09-04 Moritz Schulte * gpgkey2ssh.c: Include sysutils.h so that gnupg_tmpfile() is declared. 2007-08-31 Werner Koch * gpgparsemail.c: Support PGP/MIME signed messages. * gpgconf-comp.c (gc_component_list_components): List the programs names. 2007-08-29 Werner Koch * gpgconf.c: New command --check-programs. * gpgconf-comp.c (gc_component_check_programs): New. (gc_backend): Add member MODULE_NAME and add these module names. (retrieve_options_from_program): Use module name so that we use an absolute file name and don't rely on $PATH. (collect_error_output): New. * no-libgcrypt.c (gcry_control): New. 2007-08-28 Werner Koch * gpgconf-comp.c : Add options --max-passphrase-days and --enable-passphrase-history. 2007-08-27 Werner Koch * gpg-check-pattern.c: New * Makefile.am (libexec_PROGRAMS): Add unless DISABLE_REGEX. 2007-08-24 Werner Koch * gpgconf-comp.c : Add options --check-passphrase-pattern, --min-passphrase-nonalpha and --enforce-passphrase-constraints and move them into a new "passphrase policy" group. (gc_component) [W32]: Enable dirmngr. 2007-08-21 Werner Koch * gpgkey2ssh.c (key_to_blob): Use gnupg_tmpfile(). 2007-08-02 Werner Koch * gpgconf-comp.c: Factor the public GC_OPT_FLAG constants out and include gc-opt-flags.h. 2007-07-17 Werner Koch * gpgconf-comp.c: Add --encrypt-to and --default-key to gpg and gpgsm. 2007-07-16 Marcus Brinkmann * gpg-connect-agent.c (main): Bail out if write fails. 2007-07-05 Marcus Brinkmann * symcryptrun.c (confucius_get_pass): Define orig_codeset if [ENABLE_NLS], not [HAVE_LANGINFO_CODESET]. 2007-06-26 Werner Koch * gpgconf-comp.c (key_matches_user_or_group) [W32]: Implement user name matching. (GPGNAME): New. Use it instead of "gpg". (gc_component) [W32]: Disable dirmngr for now. (gc_component_retrieve_options): Ignore components without options. (gc_component_change_options): Ditto. (gc_component_list_options): Ditto. (gc_component_find, gc_component_list_components): Ditto. 2007-06-19 Werner Koch * gpgconf-comp.c (percent_escape): Rename to my_percent_escape. Changed all callers. 2007-06-18 Marcus Brinkmann * gpgconf-comp.c (retrieve_options_from_file): Close LIST_FILE. (copy_file): In error case, save/restore errno. Close SRC and DST. (gc_component_change_options): Catch error from unlink(). Remove target backup file before rename(). 2007-06-15 Marcus Brinkmann * gpgconf-comp.c (copy_file) [HAVE_W32_SYSTEM]: New function. (change_options_file, change_options_program) [HAVE_W32_SYSTEM]: Copy backup file. (gc_component_change_options) [HAVE_W32_SYSTEM]: Non-atomic replace. (gc_process_gpgconf_conf): Rename fname to fname_arg and fname_buffer to fname, initialize fname with fname_arg, discarding const qualifier. 2007-06-15 Werner Koch * Makefile.am (symcryptrun_LDADD): It is LIBICONV and not LIBINCONV. (gpgconf_LDADD, symcryptrun_LDADD): Add W32SOCKLIBS. 2007-06-14 Werner Koch * symcryptrun.c (main): Setup default socket name for simple-pwquery. (MAP_SPWQ_ERROR_IMPL): New. Use it for all spwq error returns. 2007-06-12 Werner Koch * gpgconf-comp.c (gc_process_gpgconf_conf): Replace GNUPG_SYSCONFDIR by a function call. * gpg-connect-agent.c (main): Replace some calls by init_common_subsystems. * gpgconf.c (main): Ditto. * symcryptrun.c (main): Ditto. 2007-06-11 Werner Koch * symcryptrun.c (main) [W32]: Call pth_init. * gpgconf.c (main) [W32]: Call pth_init * gpg-connect-agent.c (main) [W32]: Call pth_init. 2007-06-06 Werner Koch * Makefile.am (bin_PROGRAMS) [W32]: Do not build gpgparsemail. * gpgconf-comp.c [W32]: Do not include pwd.h and grp.h. (key_matches_user_or_group) [W32]: For now always return false. * symcryptrun.c (i18n_init): Remove. * gpgconf.c (i18n_init): Remove. * gpg-connect-agent.c (i18n_init): Remove. 2007-05-19 Marcus Brinkmann * symcryptrun.c (confucius_get_pass): Free ORIG_CODESET on error. 2007-05-08 Werner Koch * sockprox.c: New. It needs to be build manually. By Moritz Schulte. 2007-04-20 Werner Koch * symcryptrun.c (my_gcry_logger): Removed. (main): Call setup_libgcrypt_logging. 2007-04-03 Werner Koch * gpgconf-comp.c: Allow changing of --allow-mark-trusted. * gpg-connect-agent.c (main): New option --decode and commands decode and undecode. (read_and_print_response): Implement option. 2007-03-20 Werner Koch * gpgconf-comp.c (gc_options_gpgsm): Add p12-charset. 2007-03-07 Werner Koch * applygnupgdefaults: New. * Makefile.am (sbin_SCRIPTS): Add it 2007-03-06 Werner Koch * gpgconf-comp.c: Include pwd.h and grp.h. (GC_OPT_FLAG_NO_CHANGE): New. (gc_component_change_options): Implement it. (gc_options_gpg_agent): Add options for all ttl values and min-passphrase-length. Apply new flag to some of them. (gc_process_gpgconf_conf, key_matches_user_or_group): New. (gc_component_change_options): Factor some code out to .. (change_one_value): .. new. (gc_component_retrieve_options): Allow -1 for COMPONENT to iterate over al components. * gpgconf.c (main): New commands --check-config and --apply-defaults. Call gc_process_gpgconf_conf. 2007-01-31 Werner Koch * Makefile.am (symcryptrun_LDADD): Add LIBICONV. (gpgkey2ssh_LDADD): Ditto. 2006-12-13 David Shaw * Makefile.am (gpgsplit_LDADD): Link to LIBINTL if we're using the built-in code. 2006-12-07 David Shaw * Makefile.am: Link to iconv for jnlib dependency. 2006-11-23 Werner Koch * Makefile.am (gpg_connect_agent_LDADD): Add NETLIBS. 2006-11-21 Werner Koch * gpgconf-comp.c (list_one_option): Cast print size_t arg. 2006-11-17 Werner Koch * gpgconf-comp.c: Made disable-keypad a basic option. 2006-11-03 Werner Koch * symcryptrun.c: Include signal.h and include pth.h only if test asserts that it exists. 2006-10-23 Werner Koch * gpgconf-comp.c : Add --cipher-algo. 2006-10-20 Werner Koch * gpgsm-gencert.sh: Enhanced the main menu. 2006-10-12 Werner Koch * Makefile.am (gpg-zip, gpgsplit): Do not install due to a conflict with gpg1. 2006-10-11 Werner Koch * gpgsm-gencert.sh: Allow generation of card keys. 2006-10-08 Werner Koch * Makefile.am (gpgkey2ssh_LDADD): Add LIBINTL. Suggested by Andreas Metzler. 2006-09-22 Werner Koch * no-libgcrypt.c: Changed license to a simple all permissive one. 2006-09-20 Werner Koch * Makefile.am: Changes to allow parallel make runs. 2006-09-12 Werner Koch Replaced all call gpg_error_from_errno(errno) by gpg_error_from_syserror(). * gpg-connect-agent.c (read_and_print_response): With verbosity level 2 also print comment lines. 2006-09-06 Werner Koch * gpg-connect-agent.c: Switch everything to new Assuan error code style. * no-libgcrypt.c (out_of_core): Reanmed to ... (out_of_memory): .. this to avoid name clash with util.h. 2006-08-21 Werner Koch * gpgsplit.c: New. Taken from 1.4. Adjusted to GnuPG2. * Makefile.am (noinst_PROGRAMS): New. 2006-06-09 Marcus Brinkmann * Makefile.am (gpgconf_LDADD): Add $(GPG_ERROR_LIBS). (gpgkey2ssh_LDADD): Add ../jnlib/libjnlib.a. 2006-05-23 Werner Koch * gpgparsemail.c: Include config.h if available (stpcpy): Conditional include it. * gpgconf-comp.c (hextobyte): Removed as it is now availble in jnlib. 2005-12-20 Werner Koch * gpgconf-comp.c (gc_options_gpg): Add allow-pka-lookup. 2005-12-14 Werner Koch * Makefile.am (bin_PROGRAMS): Build gpgparsemail. * gpgparsemail.c (pkcs7_begin): New. (parse_message, message_cb): Add support of direct pkcs signatures. 2005-10-19 Werner Koch * gpgconf-comp.c (gc_options_scdaemon): New option --disable-keypad. 2005-09-22 Werner Koch * rfc822parse.c (parse_field): Tread Content-Disposition special. 2005-10-08 Marcus Brinkmann * Makefile.am (watchgnupg_LDADD): New variable. * Makefile.am (gpgconf_LDADD): Add ../gl/libgnu.a after ../common/libcommon.a. (symcryptrun_LDADD, gpg_connect_agent_LDADD, gpgkey2ssh_LDADD): Likewise. 2005-09-29 Marcus Brinkmann * Makefile.am (AM_CFLAGS): Add $(LIBGCRYPT_CFLAGS). 2005-09-06 Werner Koch * rfc822parse.c, rfc822parse.h: Changed license to LGPL. 2005-08-01 Werner Koch * gpgsm-gencert.sh: Allow entering a keygrip to generate a CSR from an existing key. 2005-07-21 Werner Koch * gpgsm-gencert.sh: Reworked to allow for multiple email addresses as well as DNsanmes and URi. Present the parameter file before creating the certificate. 2005-07-04 Marcus Brinkmann * symcryptrun.c (SYMC_BAD_PASSPHRASE, SYMC_CANCELED): New symbols, use instead constants. (hash_string): New function copied from simple-gettext.c. (confucius_get_pass): Take new argument CACHEID. (confucius_process): Calculate cacheid and pass it to confucius_get_pass. Clear passphrase from cache if necessary. 2005-06-16 Werner Koch * gpg-connect-agent.c (read_and_print_response): Made LINELEN a size_t. 2005-06-04 Marcus Brinkmann * symcryptrun.c (main): Allow any number of arguments, don't use first argument as input file name. Pass extra arguments to confucius_main. (confucius_main): Accept new arguments argc and argv and pass them to confucius_process. (confucius_process): Accept new arguments argc and argv and pass them to the confucius process. 2005-06-01 Werner Koch * symcryptrun.c: Include mkdtemp.h. 2005-05-31 Werner Koch * watchgnupg.c: Make sure that PF_LCOAL and AF_LOCAL are defines. Noted by Ray Link. 2005-05-28 Moritz Schulte * gpgkey2ssh.c: New file. * Makefile.am (bin_PROGRAMS): Added gpgkey2ssh. 2005-05-20 Werner Koch * gpg-connect-agent.c (add_definq, show_definq, clear_definq) (handle_inquire): New. (read_and_print_response): Handle INQUIRE command. (main): Implement control commands. 2005-04-21 Werner Koch * symcryptrun.c (main): Optionally allow the input file as command line argument. * gpgconf-comp.c: Add gpgsm option disable-trusted-cert-crl-check. 2005-04-20 Werner Koch * gpgconf-comp.c: Add gpg-agent:disable-scdaemon. 2005-04-19 Marcus Brinkmann * symcryptrun.c: Add --input option. 2005-04-15 Marcus Brinkmann * symcryptrun.c (TEMP_FAILURE_RETRY): Define if not defined. * symcryptrun.c (remove_file): New function. (confucius_copy_file): Accept new argument PLAIN and shred the file if it is set on error. * Makefile.am: Define symcryptrun make variable depending on BUILD_SYMCRYPTUN. (bin_PROGRAMS): Add ${symcryptrun} instead symcryptrun. (symcryptrun_LDADD): Use $(LIBUTIL_LIBS) instead of -lutil. 2005-04-11 Werner Koch * symcryptrun.c (confucius_mktmpdir): Changed to use mkdtmp(3). 2005-04-11 Marcus Brinkmann * symcryptrun.c: Implement config file parsing. * Makefile.am (bin_PROGRAMS): Add symcryptrun. (symcryptrun_SOURCES, symcryptrun_LDADD): New variables. * symcryptrun.c: New file. 2005-03-31 Werner Koch * gpg-connect-agent.c (start_agent): Use PATHSEP_C instead of ':'. 2005-03-09 Werner Koch * gpgconf-comp.c : Add honor-http-proxy. 2005-02-25 Werner Koch * no-libgcrypt.c (gcry_strdup): New. 2005-02-24 Werner Koch * gpg-connect-agent.c: New. * Makefile.am: Add it. 2004-12-21 Werner Koch * gpgconf-comp.c (get_config_pathname) [DOSISH]: Detect absolute pathnames with a drive letter. 2004-12-15 Werner Koch * Makefile.am (bin_PROGRAMS) [W32]: Do not build watchgnupg. * gpgconf-comp.c (gpg_agent_runtime_change) [W32]: No way yet to send a signal. Disable. (change_options_file, change_options_program) [W32]: No link(2), so we disable it. (gc_component_change_options): Use rename instead of link. 2004-12-13 Werner Koch * gpgconf-comp.c : Fixed typo. 2004-11-24 Werner Koch * gpgconf-comp.c : Add --ignore-http-dp, --ignore-ldap-dp and --ignore-ocsp-service-url. 2004-11-23 Werner Koch * gpgconf-comp.c : Add the proxy options. : Add --prefer-system-daemon. 2004-11-11 Werner Koch * watchgnupg.c (main): Fixed test for read error. 2004-10-22 Werner Koch * Makefile.am (bin_SCRIPTS): Add gpgsm-gencert.sh * gpgsm-gencert.sh: Fixed copyright; its part of GnuPG thus FSF. 2004-10-01 Werner Koch * gpgconf-comp.c: Made all strings for --log-file read the same. 2004-10-01 Werner Koch * gpgconf-comp.c (my_dgettext): Also switch codeset and directory for the other used domains (i.e. dirmngr). * gpgconf.c (main): Fixed translation markers. 2004-09-30 Werner Koch * gpgconf.c (i18n_init): Always use LC_ALL. * Makefile.am: Adjusted for gettext 0.14. 2004-09-29 Werner Koch * gpgconf-comp.c: Made the entries fro GROUPs translatable. Include i18n.h. (my_dgettext): Hack to use the gnupg2 domain. 2004-08-09 Moritz Schulte * gpgsm-gencert.sh: New file. 2004-06-16 Werner Koch * rfc822parse.c (rfc822parse_get_field): Add arg VALUEOFF. 2004-06-14 Werner Koch * no-libgcrypt.c (gcry_realloc, gcry_xmalloc, gcry_xcalloc): New. * gpgconf-comp.c (retrieve_options_from_program) (retrieve_options_from_file, change_options_file) (change_options_program, gc_component_change_options): Replaced getline by read_line and test for allocation failure. 2004-05-21 Marcus Brinkmann * gpgconf-comp.c (gc_options_dirmngr): Remove CRL group, put its only option "max-replies" into LDAP group. (gc_component): Change description of dirmngr to "Directory Manager". * gpgconf-comp.c (gc_component_change_options): Move the per-process backup file into a standard location. 2004-05-03 Werner Koch * gpgconf-comp.c: Add --allow-mark-trusted for the gpg-agent. 2004-04-30 Werner Koch * gpgconf-comp.c: Added more runtime flags for the gpg-agent backend. 2004-04-29 Marcus Brinkmann * gpgconf-comp.c (change_options_program): Turn on utf8-strings in the gpgconf specific part of the config file for the GnuPG backend. 2004-04-28 Werner Koch * gpgconf-comp.c: Add --ocsp-signer for the dirmngr backend. 2004-04-20 Marcus Brinkmann * gpgconf-comp.c (gc_options_gpg_agent): Change type of ignore-cache-for-signing option to GC_ARG_TYPE_NONE. 2004-04-07 Werner Koch * gpgconf-comp.c (my_dgettext): Switch the codeset once to utf-8. Allow building with out NLS. 2004-03-23 Marcus Brinkmann * gpgconf-comp.c (gc_options_dirmngr): Set GC_OPT_FLAG_ARG_OPT for "LDAP Server". (change_options_file): Remove assertion that tests that this flag is not present. Handle an empty string in OPTION->new_value. * gpgconf.c (main): Remove obsolete warning. 2004-03-23 Werner Koch * gpgconf-comp.c (gc_options_gpg): New. (gc_component_t, gc_component): Add GC_BACKEND_GPG. (gc_options_dirmngr): Add allow-ocsp. 2004-03-23 Marcus Brinkmann * gpgconf-comp.c (gc_flag): Add missing flags. * gpgconf-comp.c: Include . (gc_backend): Add new member runtime_change. (gpg_agent_runtime_change): New function. (gc_component_change_options): New variable runtime. Initialize it. If an option is changed that has the GC_OPT_FLAG_RUNTIME bit set, also set the corresponding runtime variable. Finally, call the runtime_change callback of the backend if needed. 2004-03-16 Werner Koch * gpgconf-comp.c (gc_options_gpg_agent): Implemented. (gc_options_gpgsm, gc_options_scdaemon): Implemented. (gc_backend_t): Add GC_BACKEND_SCDAEMON. 2004-03-12 Marcus Brinkmann * gpgconf-comp.c (gc_component_change_options): Set the filenames of the option's backend, not of the component. Also use GC_BACKEND_NR, not GC_COMPONENT_NR. 2004-03-09 Werner Koch * gpgconf-comp.c [_riscos_]: Removed special code for RISC OS; we don't want to clutter our code with system dependent stuff. 2004-03-08 Marcus Brinkmann * gpgconf-comp.c (retrieve_options_from_file): Quote each string in the list, not only the first. 2004-02-26 Marcus Brinkmann * gpgconf-comp.c (gc_component_list_options): Do not print empty groups. * gpgconf-comp.c (option_check_validity): Check if option is active. (change_options_file): Implement. * gpgconf-comp.c (retrieve_options_from_program): Remove broken string handling. * gpgconf-comp.c (change_options_program): Support all types of options, including list types. * README.gpgconf: Fix description of arguments. * gpgconf-comp.c (option_check_validity): Rewritten to properly support optional arguments in lists. * README.gpgconf: Add info about optional arg and arg type 0. * gpgconf-comp.c (gc_component_change_options): Parse list of arg type 0 options. (option_check_validity): Add new argument NEW_VALUE_NR. Perform rigorous validity checks. (change_options_program): Disable an option also if we have a new value for it. 2004-02-25 Marcus Brinkmann * gpgconf-comp.c (gc_component_list_options): Correct output for lists of arg type none. (struct gc_option): Add new member new_flags. (option_check_validity): Check OPTION->new_flags beside OPTION->new_value. Add new argument FLAGS. (gc_component_change_options): Support default flag correctly. (change_options_program): Likewise. 2004-02-24 Marcus Brinkmann * README.gpgconf: Revert last change. Add new flags "default", "default desc" and "no arg desc". Add new field ARGDEF. Add new field FLAG to backend interface. * gpgconf-comp.c (struct gc_option): Make flags of type unsigned long. (gc_component_list_options): Adjust type for flags. Add default argument field. (retrieve_options_from_program): Use "1" as value for non-option arguments, not "Y". (gc_component_change_options): Read in flags from input. 2004-02-23 Marcus Brinkmann * README.gpgconf: Change meaning of type 0 options value if it is the empty string or "0". * gpgconf.h (struct): Add member runtime. * gpgconf.c: Add new option oRuntime. (main): Same here. * gpgconf-comp.c (hextobyte): New function. (percent_deescape): New function. (get_config_pathname): Percent deescape pathname if taken from option (default) value. Use default value only if it exists and is not empty. Use empty string otherwise. Don't include leading quote in pathname. (change_options_program): Percent deescape string before writing it out. * gpgconf-comp.c (gc_component_list_options): Do not skip groups on output. 2004-02-18 Werner Koch * gpgconf-comp.c: Added empty components for gpgsm and scdaemon. 2004-02-12 Werner Koch * watchgnupg.c (main): Implement option "--". (print_version): New. * Makefile.am: Include cmacros.am for common flags. 2004-02-03 Werner Koch * addgnupghome: Try to use getent, so that it also works for NIS setups. 2004-01-31 Marcus Brinkmann * gpgconf-comp.c: Some bug fixes, parse only defaults from the program, and read the current values from the configuration file directly. 2004-01-30 Marcus Brinkmann * gpgconf-comp.c (gc_error): New function, use it instead of error() throughout. * gpgconf-comp.c: Use xmalloc, libcommon's asctimestamp and gnupg_get_time, fix error() invocation and use getline() consistently. 2004-01-30 Werner Koch * addgnupghome: Also set the group of copied files. 2004-01-30 Werner Koch * Makefile.am (sbin_SCRIPTS): New, to install addgnupghome. (EXTRA_DIST): Added rfc822parse.c rfc822parse.h gpgparsemail.c which might be useful for debugging. 2004-01-29 Werner Koch * addgnupghome: New. 2004-01-29 Marcus Brinkmann * gpgconf-list.c: File removed. * README.gpgconf: New file. * gpgconf-comp.c: New file. * Makefile.am (gpgconf_SOURCES): Remove gpgconf-list.c, add gpgconf-comp.c. 2004-01-16 Werner Koch * watchgnupg.c (main): Need to use FD_ISSET for the client descriptors too; aiiih. Set the listening socket to non-blocking. 2004-01-10 Werner Koch * Makefile.am: Use GPG_ERROR_CFLAGS 2004-01-05 Werner Koch * Manifest: New. * gpgconf.c, gpgconf.h, gpgconf-list.c: New. A skeleton for now. * no-libgcrypt.c: New. * Makefile.am: Add above. 2003-12-23 Werner Koch * Makefile.am: New. * watchgnupg.c: New. Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 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/tools/Makefile.am b/tools/Makefile.am index 1d04964c0..ea066e67b 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -1,105 +1,105 @@ # Makefile.am - Tools directory # Copyright (C) 2003, 2007 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 3 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, see . EXTRA_DIST = \ Manifest watchgnupg.c \ addgnupghome applygnupgdefaults gpgsm-gencert.sh \ lspgpot mail-signed-keys convert-from-106 sockprox.c \ ccidmon.c AM_CPPFLAGS = -I$(top_srcdir)/gl -I$(top_srcdir)/intl -I$(top_srcdir)/common include $(top_srcdir)/am/cmacros.am AM_CFLAGS = $(LIBGCRYPT_CFLAGS) $(GPG_ERROR_CFLAGS) $(LIBASSUAN_CFLAGS) sbin_SCRIPTS = addgnupghome applygnupgdefaults bin_SCRIPTS = gpgsm-gencert.sh if HAVE_USTAR # bin_SCRIPTS += gpg-zip noinst_SCRIPTS = gpg-zip endif if BUILD_SYMCRYPTRUN symcryptrun = symcryptrun else symcryptrun = endif bin_PROGRAMS = gpgconf gpg-connect-agent gpgkey2ssh ${symcryptrun} if !HAVE_W32_SYSTEM bin_PROGRAMS += watchgnupg gpgparsemail endif if !DISABLE_REGEX libexec_PROGRAMS = gpg-check-pattern endif noinst_PROGRAMS = clean-sat mk-tdata make-dns-cert gpgsplit -common_libs = $(libcommon) ../jnlib/libjnlib.a ../gl/libgnu.a +common_libs = $(libcommon) ../gl/libgnu.a pwquery_libs = ../common/libsimple-pwquery.a gpgsplit_LDADD = $(common_libs) \ $(LIBGCRYPT_LIBS) $(GPG_ERROR_LIBS) \ $(ZLIBS) $(LIBINTL) $(LIBICONV) gpgconf_SOURCES = gpgconf.c gpgconf.h gpgconf-comp.c no-libgcrypt.c -# jnlib/common sucks in gpg-error, will they, nil they (some compilers +# common sucks in gpg-error, will they, nil they (some compilers # do not eliminate the supposed-to-be-unused-inline-functions). gpgconf_LDADD = $(common_libs) \ $(LIBINTL) $(GPG_ERROR_LIBS) $(LIBICONV) $(W32SOCKLIBS) gpgparsemail_SOURCES = gpgparsemail.c rfc822parse.c rfc822parse.h gpgparsemail_LDADD = symcryptrun_SOURCES = symcryptrun.c symcryptrun_LDADD = $(LIBUTIL_LIBS) $(common_libs) $(pwquery_libs) \ $(LIBGCRYPT_LIBS) $(GPG_ERROR_LIBS) $(LIBINTL) \ $(LIBICONV) $(W32SOCKLIBS) watchgnupg_SOURCES = watchgnupg.c watchgnupg_LDADD = $(NETLIBS) gpg_connect_agent_SOURCES = gpg-connect-agent.c no-libgcrypt.c # FIXME: remove PTH_LIBS (why do we need them at all?) gpg_connect_agent_LDADD = ../common/libgpgrl.a $(common_libs) \ $(LIBASSUAN_LIBS) $(PTH_LIBS) $(GPG_ERROR_LIBS) \ $(LIBREADLINE) $(LIBINTL) $(NETLIBS) $(LIBICONV) gpgkey2ssh_SOURCES = gpgkey2ssh.c gpgkey2ssh_CFLAGS = $(LIBGCRYPT_CFLAGS) $(GPG_ERROR_CFLAGS) -# common sucks in jnlib, via use of BUG() in an inline function, which +# common via use of BUG() in an inline function, which # some compilers do not eliminate. gpgkey2ssh_LDADD = $(common_libs) \ $(LIBGCRYPT_LIBS) $(GPG_ERROR_LIBS) $(LIBINTL) $(LIBICONV) if !DISABLE_REGEX gpg_check_pattern_SOURCES = gpg-check-pattern.c gpg_check_pattern_CFLAGS = $(LIBGCRYPT_CFLAGS) $(GPG_ERROR_CFLAGS) gpg_check_pattern_LDADD = $(common_libs) $(LIBGCRYPT_LIBS) $(GPG_ERROR_LIBS) \ $(LIBINTL) $(LIBICONV) $(W32SOCKLIBS) endif # Make sure that all libs are build before we use them. This is # important for things like make -j2. $(PROGRAMS): $(common_libs) $(pwquery_libs) ../common/libgpgrl.a