From cvs at cvs.gnupg.org Mon Jan 6 17:17:54 2014 From: cvs at cvs.gnupg.org (by Werner Koch) Date: Mon, 06 Jan 2014 17:17:54 +0100 Subject: [git] GPGME - branch, master, updated. gpgme-1.4.2-15-g6564e5e Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "GnuPG Made Easy". The branch, master has been updated via 6564e5e78e8c6e5a120675a5699b5b75248cfbc7 (commit) via 02ba35c1b6a2cbb3361b2f2ad507c53564b2be0b (commit) from b0aaa3f9aef36634b5c391812362f016114f02ba (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 6564e5e78e8c6e5a120675a5699b5b75248cfbc7 Author: Werner Koch Date: Mon Jan 6 17:16:52 2014 +0100 Add global flags disable-gpgconf, gpgconf-name, and gpg-name. * src/gpgme.c (gpgme_set_global_flag): Add names "disable-gpgconf", "gpgconf-name", and "gpg-name". * src/dirinfo.c (_gpgme_dirinfo_disable_gpgconf): New. (get_gpgconf_item): Minor debug info change. * src/posix-util.c (default_gpg_name, default_gpgconf_name): Add vars. (_gpgme_set_default_gpg_name): New. (_gpgme_set_default_gpgconf_name): New. (_gpgme_get_gpg_path, _gpgme_get_gpgconf_path): Use new vars. (walk_path): Add debug output on failure. * src/w32-util.c (default_gpg_name, default_gpgconf_name): Add vars. (replace_slashes): New. (get_basename): New. (_gpgme_set_default_gpg_name): New. (_gpgme_set_default_gpgconf_name): New. (_gpgme_get_gpg_path, _gpgme_get_gpgconf_path): Use new vars. * tests/t-engine-info.c (main): Add --verbose and --set-global-flag options. -- Note that the Windows part has not been tested. diff --git a/doc/gpgme.texi b/doc/gpgme.texi index 18b3c94..3f31492 100644 --- a/doc/gpgme.texi +++ b/doc/gpgme.texi @@ -1,5 +1,5 @@ -\input texinfo @c -*- mode: texinfo; coding: latin-1; -*- - at documentencoding ISO-8859-1 +\input texinfo @c -*- mode: texinfo; coding: utf-8; -*- + at documentencoding UTF-8 @setfilename gpgme.info @settitle The `GnuPG Made Easy' Reference Manual @@ -14,7 +14,7 @@ @copying Copyright @copyright{} 2002, 2003, 2004, 2005, 2006, 2007, -2008, 2010, 2012, 2013 g10 Code GmbH. +2008, 2010, 2012, 2013, 2014 g10 Code GmbH. @quotation Permission is granted to copy, distribute and/or modify this document @@ -72,7 +72,7 @@ This is Edition @value{EDITION}, last updated @value{UPDATED}, of @center for version @value{VERSION} @page @vskip 0pt plus 1filll -Published by g10 Code GmbH@* H?ttenstr. 61@* 40699 Erkrath, Germany +Published by g10 Code GmbH@* H????ttenstr. 61@* 40699 Erkrath, Germany @insertcopying @end titlepage @@ -648,14 +648,39 @@ does not return a detailed error code). On some systems it is not easy to set environment variables and thus hard to use @acronym{GPGME}'s internal trace facility for debugging. This function has been introduced as an alternative way to enable -debugging. It is important to assure that only one thread accesses - at acronym{GPGME} functions between a call to this function and after -the return from the call to @code{gpgme_check_version}. - -To enable debugging, you need to call this function as early as -possible --- even before @code{gpgme_check_version} --- with the -string ``debug'' for @var{name} and @var{value} identical to the value -used with the environment variable @code{GPGME_DEBUG}. +debugging and for a couple of other rarely used tweaks. It is +important to assure that only one thread accesses @acronym{GPGME} +functions between a call to this function and after the return from +the call to @code{gpgme_check_version}. + +All currently supported features require that this function is called +as early as possible --- even before @code{gpgme_check_version}. The +features are identified by the following values for @var{name}: + + at table @code + at item "debug" +To enable debugging use the string ``debug'' for @var{name} and + at var{value} identical to the value used with the environment variable + at code{GPGME_DEBUG}. + + at item "disable-gpgconf" +Using this feature with any @var{value} disables the detection of the +gpgconf program and thus forces GPGME to fallback into the simple +OpenPGP only mode. It may be used to force the use of GnuPG-1 on +systems which have both GPG versions installed. Note that in general +the use of @code{gpgme_set_engine_info} is a better way to select a +specific engine version. + + at item "gpgconf-name" + at itemx "gpg-name" +Set the name of the gpgconf respective gpg binary. The defaults are + at code{GNU/GnuPG/gpgconf} and @code{GNU/GnuPG/gpg}. Under Unix the +leading directory part is ignored. Under Windows the leading +directory part is used as the default installation directory; the + at code{.exe} suffix is added by GPGME. Use forward slashed even under +Windows. + + at end table This function returns @code{0} on success. In contrast to other functions the non-zero return value on failure does not convey any diff --git a/src/dirinfo.c b/src/dirinfo.c index 2e387fa..eb29c6b 100644 --- a/src/dirinfo.c +++ b/src/dirinfo.c @@ -48,6 +48,7 @@ enum /* Values retrieved via gpgconf and cached here. */ static struct { int valid; /* Cached information is valid. */ + int disable_gpgconf; char *homedir; char *agent_socket; char *gpgconf_name; @@ -58,6 +59,15 @@ static struct { } dirinfo; + +/* Helper function to be used only by gpgme_set_global_flag. */ +void +_gpgme_dirinfo_disable_gpgconf (void) +{ + dirinfo.disable_gpgconf = 1; +} + + /* Parse the output of "gpgconf --list-dirs". This function expects that DIRINFO_LOCK is held by the caller. If COMPONENTS is set, the output of --list-components is expected. */ @@ -198,16 +208,16 @@ get_gpgconf_item (int what) { char *pgmname; - pgmname = _gpgme_get_gpgconf_path (); + pgmname = dirinfo.disable_gpgconf? NULL : _gpgme_get_gpgconf_path (); if (pgmname && access (pgmname, F_OK)) { _gpgme_debug (DEBUG_INIT, - "gpgme_dinfo: gpgconf='%s' [not installed]\n", pgmname); + "gpgme-dinfo: gpgconf='%s' [not installed]\n", pgmname); free (pgmname); pgmname = NULL; /* Not available. */ } else - _gpgme_debug (DEBUG_INIT, "gpgme_dinfo: gpgconf='%s'\n", + _gpgme_debug (DEBUG_INIT, "gpgme-dinfo: gpgconf='%s'\n", pgmname? pgmname : "[null]"); if (!pgmname) { @@ -231,22 +241,22 @@ get_gpgconf_item (int what) allocated. */ dirinfo.valid = 1; if (dirinfo.gpg_name) - _gpgme_debug (DEBUG_INIT, "gpgme_dinfo: gpg='%s'\n", + _gpgme_debug (DEBUG_INIT, "gpgme-dinfo: gpg='%s'\n", dirinfo.gpg_name); if (dirinfo.g13_name) - _gpgme_debug (DEBUG_INIT, "gpgme_dinfo: g13='%s'\n", + _gpgme_debug (DEBUG_INIT, "gpgme-dinfo: g13='%s'\n", dirinfo.g13_name); if (dirinfo.gpgsm_name) - _gpgme_debug (DEBUG_INIT, "gpgme_dinfo: gpgsm='%s'\n", + _gpgme_debug (DEBUG_INIT, "gpgme-dinfo: gpgsm='%s'\n", dirinfo.gpgsm_name); if (dirinfo.homedir) - _gpgme_debug (DEBUG_INIT, "gpgme_dinfo: homedir='%s'\n", + _gpgme_debug (DEBUG_INIT, "gpgme-dinfo: homedir='%s'\n", dirinfo.homedir); if (dirinfo.agent_socket) - _gpgme_debug (DEBUG_INIT, "gpgme_dinfo: agent='%s'\n", + _gpgme_debug (DEBUG_INIT, "gpgme-dinfo: agent='%s'\n", dirinfo.agent_socket); if (dirinfo.uisrv_socket) - _gpgme_debug (DEBUG_INIT, "gpgme_dinfo: uisrv='%s'\n", + _gpgme_debug (DEBUG_INIT, "gpgme-dinfo: uisrv='%s'\n", dirinfo.uisrv_socket); } switch (what) diff --git a/src/gpgme.c b/src/gpgme.c index a8de64b..4a8afa9 100644 --- a/src/gpgme.c +++ b/src/gpgme.c @@ -37,6 +37,7 @@ #include "wait.h" #include "debug.h" #include "priv-io.h" +#include "sys-util.h" /* The default locale. */ @@ -65,6 +66,15 @@ gpgme_set_global_flag (const char *name, const char *value) return -1; else if (!strcmp (name, "debug")) return _gpgme_debug_set_debug_envvar (value); + else if (!strcmp (name, "disable-gpgconf")) + { + _gpgme_dirinfo_disable_gpgconf (); + return 0; + } + else if (!strcmp (name, "gpgconf-name")) + return _gpgme_set_default_gpgconf_name (value); + else if (!strcmp (name, "gpg-name")) + return _gpgme_set_default_gpg_name (value); else return -1; } diff --git a/src/posix-util.c b/src/posix-util.c index d4e4e3f..5bfc486 100644 --- a/src/posix-util.c +++ b/src/posix-util.c @@ -29,6 +29,46 @@ #include "util.h" #include "sys-util.h" +#include "debug.h" + +/* These variables store the malloced name of alternative default + binaries. The are set only once by gpgme_set_global_flag. */ +static char *default_gpg_name; +static char *default_gpgconf_name; + +/* Set the default name for the gpg binary. This function may only be + called by gpgme_set_global_flag. Returns 0 on success. Leading + directories are removed from NAME. */ +int +_gpgme_set_default_gpg_name (const char *name) +{ + const char *s; + + s = strrchr (name, '/'); + if (s) + name = s + 1; + + if (!default_gpg_name) + default_gpg_name = strdup (name); + return !default_gpg_name; +} + +/* Set the default name for the gpgconf binary. This function may + only be called by gpgme_set_global_flag. Returns 0 on success. + Leading directories are removed from NAME. */ +int +_gpgme_set_default_gpgconf_name (const char *name) +{ + const char *s; + + s = strrchr (name, '/'); + if (s) + name = s + 1; + + if (!default_gpgconf_name) + default_gpgconf_name = strdup (name); + return !default_gpgconf_name; +} /* Find an executable program PGM along the envvar PATH. */ @@ -60,6 +100,9 @@ walk_path (const char *pgm) path = s + 1; } + _gpgme_debug (DEBUG_ENGINE, "gpgme-walk_path: '%s' not found in '%s'", + pgm, path); + free (fname); return NULL; } @@ -72,7 +115,7 @@ walk_path (const char *pgm) char * _gpgme_get_gpg_path (void) { - return walk_path ("gpg"); + return walk_path (default_gpg_name? default_gpg_name : "gpg"); } @@ -81,7 +124,7 @@ _gpgme_get_gpg_path (void) char * _gpgme_get_gpgconf_path (void) { - return walk_path ("gpgconf"); + return walk_path (default_gpgconf_name? default_gpgconf_name : "gpgconf"); } /* See w32-util.c */ diff --git a/src/sys-util.h b/src/sys-util.h index 3686f89..7180fca 100644 --- a/src/sys-util.h +++ b/src/sys-util.h @@ -21,6 +21,9 @@ #define SYS_UTIL_H /*-- {posix,w32}-util.c --*/ +int _gpgme_set_default_gpg_name (const char *name); +int _gpgme_set_default_gpgconf_name (const char *name); + char *_gpgme_get_gpg_path (void); char *_gpgme_get_gpgconf_path (void); diff --git a/src/util.h b/src/util.h index 57c8b13..c0934e1 100644 --- a/src/util.h +++ b/src/util.h @@ -51,6 +51,8 @@ int _gpgme_get_conf_int (const char *key, int *value); void _gpgme_allow_set_foreground_window (pid_t pid); /*-- dirinfo.c --*/ +void _gpgme_dirinfo_disable_gpgconf (void); + const char *_gpgme_get_default_homedir (void); const char *_gpgme_get_default_agent_socket (void); const char *_gpgme_get_default_gpg_name (void); diff --git a/src/w32-util.c b/src/w32-util.c index 31a58bb..3884b40 100644 --- a/src/w32-util.c +++ b/src/w32-util.c @@ -81,6 +81,11 @@ DEFINE_STATIC_LOCK (get_path_lock); file name of the DLL or executable which contains the gpgme code. */ static HMODULE my_hmodule; +/* These variables store the malloced name of alternative default + binaries. The are set only once by gpgme_set_global_flag. */ +static char *default_gpg_name; +static char *default_gpgconf_name; + #ifdef HAVE_ALLOW_SET_FOREGROUND_WINDOW @@ -151,6 +156,32 @@ wchar_to_utf8 (const wchar_t *string) } +/* Replace all forward slashes by backslashes. */ +static void +replace_slashes (char *string) +{ + for (; *string; string++) + if (*string == '/') + *string = '\\'; +} + + +/* Get the base name of NAME. Returns a pointer into NAME right after + the last slash or backslash or to NAME if no slash or backslash + exists. */ +static const char * +get_basename (const char *name) +{ + const char *mark, *s; + + for (mark=NULL, s=name; *s; s++) + if (*s == '/' || *s == '\\') + mark = s; + + return mark? mark+1 : name; +} + + void _gpgme_allow_set_foreground_window (pid_t pid) { @@ -373,7 +404,7 @@ find_program_in_inst_dir (const char *inst_dir, const char *name) char *dir; /* If an installation directory has been passed, this overrides a - location given bu the registry. The idea here is that we prefer + location given by the registry. The idea here is that we prefer a program installed alongside with gpgme. We don't want the registry to override this to have a better isolation of an gpgme aware applications for other effects. Note that the "Install @@ -424,6 +455,41 @@ find_program_at_standard_place (const char *name) } +/* Set the default name for the gpg binary. This function may only be + called by gpgme_set_global_flag. Returns 0 on success. */ +int +_gpgme_set_default_gpg_name (const char *name) +{ + if (!default_gpg_name) + { + default_gpg_name = malloc (strlen (name) + 5); + if (default_gpg_name) + { + strcpy (stpcpy (default_gpg_name, name), ".exe"); + replace_slashes (default_gpg_name); + } + } + return !default_gpg_name; +} + +/* Set the default name for the gpgconf binary. This function may only be + called by gpgme_set_global_flag. Returns 0 on success. */ +int +_gpgme_set_default_gpgconf_name (const char *name) +{ + if (!default_gpgconf_name) + { + default_gpgconf_name = malloc (strlen (name) + 5); + if (default_gpgconf_name) + { + strcpy (stpcpy (default_gpgconf_name, name), ".exe"); + replace_slashes (default_gpgconf_name); + } + } + return !default_gpgconf_name; +} + + /* Return the full file name of the GPG binary. This function is used if gpgconf was not found and thus it can be assumed that gpg2 is not installed. This function is only called by get_gpgconf_item @@ -432,27 +498,47 @@ char * _gpgme_get_gpg_path (void) { char *gpg; - const char *inst_dir; + const char *inst_dir, *name; inst_dir = _gpgme_get_inst_dir (); - gpg = find_program_in_inst_dir (inst_dir, "gpg.exe"); + gpg = find_program_in_inst_dir + (inst_dir, + default_gpg_name? get_basename (default_gpg_name) : "gpg.exe"); if (!gpg) - gpg = find_program_at_standard_place ("GNU\\GnuPG\\gpg.exe"); + { + name = (default_gpg_name? default_gpg_name + /* */ : "GNU\\GnuPG\\gpg.exe"); + gpg = find_program_at_standard_place (name); + if (!gpg) + _gpgme_debug (DEBUG_ENGINE, "_gpgme_get_gpg_path: '%s' not found", + name); + } + return gpg; } + /* This function is only called by get_gpgconf_item and may not be called concurrently. */ char * _gpgme_get_gpgconf_path (void) { char *gpgconf; - const char *inst_dir; + const char *inst_dir, *name; inst_dir = _gpgme_get_inst_dir (); - gpgconf = find_program_in_inst_dir (inst_dir, "gpgconf.exe"); + gpgconf = find_program_in_inst_dir + (inst_dir, + default_gpgconf_name? get_basename (default_gpgconf_name) : "gpgconf.exe"); if (!gpgconf) - gpgconf = find_program_at_standard_place ("GNU\\GnuPG\\gpgconf.exe"); + { + name = (default_gpgconf_name? default_gpgconf_name + /* */ : "GNU\\GnuPG\\gpgconf.exe"); + gpgconf = find_program_at_standard_place (name); + if (!gpgconf) + _gpgme_debug (DEBUG_ENGINE, "_gpgme_get_gpgconf_path: '%s' not found", + name); + } return gpgconf; } diff --git a/tests/t-engine-info.c b/tests/t-engine-info.c index 43acd3d..11fe4a4 100644 --- a/tests/t-engine-info.c +++ b/tests/t-engine-info.c @@ -28,6 +28,12 @@ #include +#define PGM "t-engine-info" + +static int verbose; + + + #define fail_if_err(err) \ do \ @@ -42,13 +48,66 @@ while (0) - int main (int argc, char **argv ) { + int last_argc = -1; gpgme_engine_info_t info; gpgme_error_t err; + if (argc) + { argc--; argv++; } + + while (argc && last_argc != argc ) + { + last_argc = argc; + if (!strcmp (*argv, "--")) + { + argc--; argv++; + break; + } + else if (!strcmp (*argv, "--help")) + { + fputs ("usage: " PGM " [options]\n" + "Options:\n" + " --set-global-flag KEY VALUE\n", + stdout); + exit (0); + } + else if (!strcmp (*argv, "--verbose")) + { + verbose++; + argc--; argv++; + } + else if (!strcmp (*argv, "--set-global-flag")) + { + argc--; argv++; + if (argc < 2) + { + fprintf (stderr, PGM ": not enough arguments for option\n"); + exit (1); + } + if (gpgme_set_global_flag (argv[0], argv[1])) + { + fprintf (stderr, PGM ": gpgme_set_global_flag failed\n"); + exit (1); + } + argc--; argv++; + argc--; argv++; + } + else if (!strncmp (*argv, "--", 2)) + { + fprintf (stderr, PGM ": unknown option '%s'\n", *argv); + exit (1); + } + } + + if (argc) + { + fprintf (stderr, PGM ": unexpected arguments\n"); + exit (1); + } + gpgme_check_version (NULL); err = gpgme_get_engine_info (&info); fail_if_err (err); commit 02ba35c1b6a2cbb3361b2f2ad507c53564b2be0b Author: Werner Koch Date: Fri Dec 27 16:08:20 2013 +0100 Locate engine names only at runtime and prefer GnuPG-2. * configure.ac (NEED_GPG_VERSION, NEED_GPGSM_VERSION) (NEED_G13_VERSION, NEED_GPGCONF_VERSION): Remove vars and all related checks. Do not check for any engine version. (HAVE_ASSUAN): Remove AM conditional. * src/Makefile.am: Remove separate component vars and always build all engines but uiserver. * src/dirinfo.c (WANT_GPGCONF_NAME): New. (struct dirinfo): Add field gpgconf_name. (_gpgme_get_default_gpgconf_name): Use WANT_GPGCONF_NAME. (get_gpgconf_item): Set gpgconf name and adjust for _gpgme_get_*_path now returning a malloced string. * src/engine.c (engine_ops): Always init all engines except for uiserver. * src/posix-util.c (_gpgme_get_gpgsm_path, _gpgme_get_g13_path): Remove unused functions. (walk_path): New. (_gpgme_get_gpg_path, _gpgme_get_gpgconf_path ): Re-implement using walk_path. * src/w32-util.c (_gpgme_get_gpgsm_path, _gpgme_get_g13_path): Remove unused functions. (_gpgme_get_gpg_path, _gpgme_get_gpgconf_path): Return a malloced string. * src/engine-g13.c (g13_get_req_version): Use a hardwired string with the required version. This info belongs into this file. * src/engine-gpg.c (gpg_get_req_version): Ditto. * src/engine-gpgconf.c (gpgconf_get_req_version): Ditto. * src/engine-gpgsm.c (gpgsm_get_req_version): Ditto. * tests/t-engine-info.c: Replace now useless test by an info output. * tests/gpg/Makefile.am (GPG, GPG_AGENT): Hardwire gpg and gpg-agent. * tests/gpgsm/Makefile.am (GPGSM): Hardwire gpgsm. Signed-off-by: Werner Koch diff --git a/NEWS b/NEWS index f68035d..8f9127e 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,16 @@ +Noteworthy changes in version 1.5.0 (unreleased) +------------------------------------------------ + + * On Unices the engine file names are not not anymore hardwired but + located via the envvar PATH. All configuration options to set the + name of the engines for configure run are removed. + + * If GPGME find the gpgconf binary it defaults to using gpg2 or + whatever gpgconf tells as name for the OpenPGP engine. If gpgconf + is not found, GPGME looks for an engine named "gpg". + + + Noteworthy changes in version 1.4.3 (2013-08-12) ------------------------------------------------ diff --git a/README b/README index e886647..3b39215 100644 --- a/README +++ b/README @@ -41,7 +41,7 @@ See the file INSTALL for generic installation instructions. Check that you have unmodified sources. See below on how to do this. Don't skip it - this is an important step! -To build GPGME, you need to install libgpg-error (>= 1.8) and +To build GPGME, you need to install libgpg-error (>= 1.11) and Libassuan (>= 2.0.2). For support of the OpenPGP protocol (default), you should use the @@ -50,13 +50,6 @@ ftp://ftp.gnupg.org/gcrypt/gnupg/ For support of the CMS (Cryptographic Message Syntax) protocol, you need a GnuPG version >= 2.0. -If configure can't find the `gpg' binary in your path, you can specify -the location with the --with-gpg=/path/to/gpg argument to configure. - -If configure can't find the `gpgsm' binary in your path, you can -specify the location with the --with-gpgsm=/path/to/gpgsm argument to -configure. - On some platforms GPGME based applications might hang at certain operations when using GPGME_PROTOCOL_CMS. A workaround for this problem is to build with the configure option --disable-fd-passing. diff --git a/configure.ac b/configure.ac index 92375e6..9575db2 100644 --- a/configure.ac +++ b/configure.ac @@ -65,7 +65,7 @@ LIBGPGME_LT_REVISION=0 GPGME_CONFIG_API_VERSION=1 ############################################## -NEED_GPG_ERROR_VERSION=1.8 +NEED_GPG_ERROR_VERSION=1.11 NEED_LIBASSUAN_API=2 NEED_LIBASSUAN_VERSION=2.0.2 @@ -254,7 +254,32 @@ AC_SUBST(BUILD_TIMESTAMP) AC_DEFINE_UNQUOTED(BUILD_TIMESTAMP, "$BUILD_TIMESTAMP", [The time this package was configured for a build]) +# +# Options to disable some regression tests +# +run_gpgconf_test="yes" +AC_ARG_ENABLE(gpgconf-test, + AC_HELP_STRING([--disable-gpgconf-test], [disable GPGCONF regression test]), + run_gpgconf_test=$enableval) +AM_CONDITIONAL(RUN_GPGCONF_TESTS, test "$run_gpgconf_test" = "yes") + +run_gpg_test="yes" +AC_ARG_ENABLE(gpg-test, + AC_HELP_STRING([--disable-gpg-test], [disable GPG regression test]), + run_gpg_test=$enableval) +AM_CONDITIONAL(RUN_GPG_TESTS, test "$run_gpg_test" = "yes") + +run_gpgsm_test="yes" +AC_ARG_ENABLE(gpgsm-test, + AC_HELP_STRING([--disable-gpgsm-test], [disable GPGSM regression test]), + run_gpgsm_test=$enableval) +AM_CONDITIONAL(RUN_GPGSM_TESTS, test "$run_gpgsm_test" = "yes") +run_g13_test="yes" +AC_ARG_ENABLE(g13-test, + AC_HELP_STRING([--disable-g13-test], [disable G13 regression test]), + run_g13_test=$enableval) +AM_CONDITIONAL(RUN_G13_TESTS, test "$run_g13_test" = "yes") # Checks for header files. @@ -394,478 +419,6 @@ if test "$have_libassuan" = "yes"; then AC_DEFINE_UNQUOTED(GPGME_LIBASSUAN_VERSION, "$libassuan_version", [version of the libassuan library]) fi -AM_CONDITIONAL(HAVE_ASSUAN, test "$have_libassuan" = "yes") -if test "$have_libassuan" = "yes"; then - AC_DEFINE(ENABLE_ASSUAN,1,[Whether Assuan support is enabled]) -fi - -# Checks for system services -NEED_GPG_VERSION_DEFAULT=1.4.0 -NEED_GPGSM_VERSION_DEFAULT=1.9.6 -NEED_GPGCONF_VERSION_DEFAULT=2.0.4 -NEED_G13_VERSION_DEFAULT=2.1.0 -NEED_GPG_VERSION="$NEED_GPG_VERSION_DEFAULT" -NEED_GPGSM_VERSION="$NEED_GPGSM_VERSION_DEFAULT" -NEED_GPGCONF_VERSION="$NEED_GPGCONF_VERSION_DEFAULT" -NEED_G13_VERSION="$NEED_G13_VERSION_DEFAULT" -AC_ARG_WITH(gpg-version, - AC_HELP_STRING([--with-gpg-version=VER], [require GnuPG version VER]), - NEED_GPG_VERSION=$withval) -if test "$NEED_GPG_VERSION" = "yes"; then - NEED_GPG_VERSION="$NEED_GPG_VERSION_DEFAULT" -fi -if test "$NEED_GPG_VERSION" = "no"; then - NEED_GPG_VERSION=0.0.0 -fi -AC_ARG_WITH(gpgsm-version, - AC_HELP_STRING([--with-gpgsm-version=VER], [require GPGSM version VER]), - NEED_GPGSM_VERSION=$withval) -if test "$NEED_GPGSM_VERSION" = "yes"; then - NEED_GPGSM_VERSION="$NEED_GPGSM_VERSION_DEFAULT" -fi -if test "$NEED_GPGSM_VERSION" = "no"; then - NEED_GPGSM_VERSION=0.0.0 -fi -AC_ARG_WITH(gpgconf-version, - AC_HELP_STRING([--with-gpgconf-version=VER], [require GPGCONF version VER]), - NEED_GPGCONF_VERSION=$withval) -if test "$NEED_GPGCONF_VERSION" = "yes"; then - NEED_GPGCONF_VERSION="$NEED_GPGCONF_VERSION_DEFAULT" -fi -if test "$NEED_GPGCONF_VERSION" = "no"; then - NEED_GPGCONF_VERSION=0.0.0 -fi -AC_ARG_WITH(g13-version, - AC_HELP_STRING([--with-g13-version=VER], [require G13 version VER]), - NEED_G13_VERSION=$withval) -if test "$NEED_G13_VERSION" = "yes"; then - NEED_G13_VERSION="$NEED_G13_VERSION_DEFAULT" -fi -if test "$NEED_G13_VERSION" = "no"; then - NEED_G13_VERSION=0.0.0 -fi - -AC_DEFINE_UNQUOTED(NEED_GPGCONF_VERSION, "$NEED_GPGCONF_VERSION", - [Min. needed GPGCONF version.]) -AC_DEFINE_UNQUOTED(NEED_GPG_VERSION, "$NEED_GPG_VERSION", - [Min. needed GnuPG version.]) -AC_DEFINE_UNQUOTED(NEED_GPGSM_VERSION, "$NEED_GPGSM_VERSION", - [Min. needed GPGSM version.]) -AC_DEFINE_UNQUOTED(NEED_G13_VERSION, "$NEED_G13_VERSION", - [Min. needed G13 version.]) - -# -# Check for GPGCONF -# -gpgconf_usable_for_test=no -NO_OVERRIDE=no -AC_ARG_WITH(gpgconf, - AC_HELP_STRING([--with-gpgconf=PATH], - [use gpgconf binary at PATH]), - GPGCONF=$withval, NO_OVERRIDE=yes) -if test "$NO_OVERRIDE" = "yes" || test "$GPGCONF" = "yes"; then - GPGCONF= - NO_OVERRIDE=yes - if test "$cross_compiling" != "yes"; then - AC_PATH_PROG(GPGCONF, gpgconf) - fi - if test -z "$GPGCONF"; then - GPGCONF="$GPGCONF_DEFAULT" - fi -fi -if test "$GPGCONF" = no; then - if test "$NO_OVERRIDE" = "yes"; then - if test "$cross_compiling" != "yes"; then - AC_MSG_WARN([ -*** -*** Could not find gpgconf, install gpgconf or use --with-gpgconf=PATH to enable it -***]) - else - AC_MSG_ERROR([ -*** -*** Can not determine path to gpgconf when cross-compiling, use --with-gpgconf=PATH -***]) - fi - fi -else - AC_DEFINE_UNQUOTED(GPGCONF_PATH, "$GPGCONF", [Path to the GPGCONF binary.]) - AC_DEFINE(ENABLE_GPGCONF,1,[Whether GPGCONF support is enabled]) -fi -AM_CONDITIONAL(HAVE_GPGCONF, test "$GPGCONF" != "no") - -dnl Check for GPGCONF version requirement. -GPGCONF_VERSION=unknown -ok=maybe -if test -z "$GPGCONF" -o "x$GPGCONF" = "xno"; then - ok=no -else - if test "$cross_compiling" = "yes"; then - AC_MSG_WARN([GPGCONF version can not be checked when cross compiling]) - ok=no - else - if test ! -x "$GPGCONF"; then - AC_MSG_WARN([GPGCONF not executable, version check disabled]) - ok=no - fi - fi -fi -if test "$ok" = "maybe"; then - AC_MSG_CHECKING(for GPGCONF >= $NEED_GPGCONF_VERSION) - req_major=`echo $NEED_GPGCONF_VERSION | \ - sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'` - req_minor=`echo $NEED_GPGCONF_VERSION | \ - sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'` - req_micro=`echo $NEED_GPGCONF_VERSION | \ - sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'` - GPGCONF_VERSION=`$GPGCONF --version | sed -n '1 s/[[^0-9]]*\(.*\)/\1/p'` - major=`echo $GPGCONF_VERSION | \ - sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'` - minor=`echo $GPGCONF_VERSION | \ - sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'` - micro=`echo $GPGCONF_VERSION | \ - sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'` - - if test "$major" -gt "$req_major"; then - ok=yes - else - if test "$major" -eq "$req_major"; then - if test "$minor" -gt "$req_minor"; then - ok=yes - else - if test "$minor" -eq "$req_minor"; then - if test "$micro" -ge "$req_micro"; then - ok=yes - fi - fi - fi - fi - fi - if test "$ok" = "yes"; then - AC_MSG_RESULT(yes) - if test "$cross_compiling" != "yes"; then - gpgconf_usable_for_test=yes - fi - else - AC_MSG_RESULT(no) - AC_MSG_WARN([GPGCONF must be at least version $NEED_GPGCONF_VERSION]) - fi -fi -run_gpgconf_test="$ok" -AC_ARG_ENABLE(gpgconf-test, - AC_HELP_STRING([--disable-gpgconf-test], [disable GPGCONF run test]), - run_gpgconf_test=$enableval) -AM_CONDITIONAL(RUN_GPGCONF_TESTS, test "$run_gpgconf_test" = "yes") - - -# -# Check for GPG -# -NO_OVERRIDE=no -AC_ARG_WITH(gpg, - AC_HELP_STRING([--with-gpg=PATH], [use GnuPG binary at PATH]), - GPG=$withval, NO_OVERRIDE=yes) -if test "$NO_OVERRIDE" = "yes" || test "$GPG" = "yes"; then - GPG= - NO_OVERRIDE=yes - if test "$cross_compiling" != "yes"; then - if test "$gpgconf_usable_for_test" = "yes"; then - GPG="`$GPGCONF --list-components | grep ^gpg: | cut -d: -f 3`" - else - AC_PATH_PROG(GPG, gpg) - fi - fi - if test -z "$GPG"; then - GPG="$GPG_DEFAULT" - fi -fi -if test "$GPG" = no; then - if test "$NO_OVERRIDE" = "yes"; then - if test "$cross_compiling" != "yes"; then - AC_MSG_WARN([ -*** -*** Could not find GnuPG, install GnuPG or use --with-gpg=PATH to enable it -***]) - else - AC_MSG_ERROR([ -*** -*** Can not determine path to GnuPG when cross-compiling, use --with-gpg=PATH -***]) - fi - fi -else - AC_DEFINE_UNQUOTED(GPG_PATH, "$GPG", [Path to the GnuPG binary.]) - AC_SUBST(GPG) -fi -dnl Check for GnuPG version requirement. -GPG_VERSION=unknown -ok=maybe -if test -z "$GPG" -o "x$GPG" = "xno"; then - ok=no -else - if test "$cross_compiling" = "yes"; then - AC_MSG_WARN([GnuPG version can not be checked when cross compiling]) - ok=no - else - if test ! -x "$GPG"; then - AC_MSG_WARN([GnuPG not executable, version check disabled]) - ok=no - fi - fi -fi -if test "$ok" = "maybe"; then - AC_MSG_CHECKING(for GPG >= $NEED_GPG_VERSION) - req_major=`echo $NEED_GPG_VERSION | \ - sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'` - req_minor=`echo $NEED_GPG_VERSION | \ - sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'` - req_micro=`echo $NEED_GPG_VERSION | \ - sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'` - GPG_VERSION=`$GPG --version | sed -n '1 s/[[^0-9]]*\(.*\)/\1/p'` - major=`echo $GPG_VERSION | \ - sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'` - minor=`echo $GPG_VERSION | \ - sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'` - micro=`echo $GPG_VERSION | \ - sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'` - - if test "$major" -gt "$req_major"; then - ok=yes - else - if test "$major" -eq "$req_major"; then - if test "$minor" -gt "$req_minor"; then - ok=yes - else - if test "$minor" -eq "$req_minor"; then - if test "$micro" -ge "$req_micro"; then - ok=yes - fi - fi - fi - fi - fi - if test "$ok" = "yes"; then - AC_MSG_RESULT(yes) - else - AC_MSG_RESULT(no) - AC_MSG_WARN([GPG must be at least version $NEED_GPG_VERSION]) - fi -fi -run_gpg_test="$ok" -AC_ARG_ENABLE(gpg-test, - AC_HELP_STRING([--disable-gpg-test], [disable GPG run test]), - run_gpg_test=$enableval) -AM_CONDITIONAL(RUN_GPG_TESTS, test "$run_gpg_test" = "yes") -AC_SUBST(GPG_PATH) - - -# -# Check for GPGSM -# -NO_OVERRIDE=no -AC_ARG_WITH(gpgsm, - AC_HELP_STRING([--with-gpgsm=PATH], [use GpgSM binary at PATH]), - GPGSM=$withval, NO_OVERRIDE=yes) -if test "$NO_OVERRIDE" = "yes" || test "$GPGSM" = "yes"; then - GPGSM= - NO_OVERRIDE=yes - if test "$cross_compiling" != "yes"; then - if test "$gpgconf_usable_for_test" = "yes"; then - GPGSM="`$GPGCONF --list-components | grep ^gpgsm: | cut -d: -f 3`" - else - AC_PATH_PROG(GPGSM, gpgsm) - fi - fi - if test -z "$GPGSM"; then - GPGSM="$GPGSM_DEFAULT" - fi -fi -if test "$GPGSM" = no; then - if test "$NO_OVERRIDE" = "yes"; then - if test "$cross_compiling" != "yes"; then - AC_MSG_WARN([ -*** -*** Could not find GpgSM, install GpgSM or use --with-gpgsm=PATH to enable it -***]) - else - AC_MSG_ERROR([ -*** -*** Can not determine path to GpgSM when cross-compiling, use --with-gpgsm=PATH -***]) - fi - fi -else - AC_DEFINE_UNQUOTED(GPGSM_PATH, "$GPGSM", [Path to the GPGSM binary.]) - AC_DEFINE(ENABLE_GPGSM,1,[Whether GPGSM support is enabled]) -fi -AM_CONDITIONAL(HAVE_GPGSM, test "$GPGSM" != "no") - - -dnl Check for GPGSM version requirement. -GPGSM_VERSION=unknown -ok=maybe -if test -z "$GPGSM" -o "x$GPGSM" = "xno"; then - ok=no -else - if test "$cross_compiling" = "yes"; then - AC_MSG_WARN([GPGSM version can not be checked when cross compiling]) - ok=no - else - if test ! -x "$GPGSM"; then - AC_MSG_WARN([GPGSM not executable, version check disabled]) - ok=no - fi - fi -fi -if test "$ok" = "maybe"; then - AC_MSG_CHECKING(for GPGSM >= $NEED_GPGSM_VERSION) - req_major=`echo $NEED_GPGSM_VERSION | \ - sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'` - req_minor=`echo $NEED_GPGSM_VERSION | \ - sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'` - req_micro=`echo $NEED_GPGSM_VERSION | \ - sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'` - GPGSM_VERSION=`$GPGSM --version | sed -n '1 s/[[^0-9]]*\(.*\)/\1/p'` - major=`echo $GPGSM_VERSION | \ - sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'` - minor=`echo $GPGSM_VERSION | \ - sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'` - micro=`echo $GPGSM_VERSION | \ - sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'` - - if test "$major" -gt "$req_major"; then - ok=yes - else - if test "$major" -eq "$req_major"; then - if test "$minor" -gt "$req_minor"; then - ok=yes - else - if test "$minor" -eq "$req_minor"; then - if test "$micro" -ge "$req_micro"; then - ok=yes - fi - fi - fi - fi - fi - if test "$ok" = "yes"; then - AC_MSG_RESULT(yes) - else - AC_MSG_RESULT(no) - AC_MSG_WARN([GPGSM must be at least version $NEED_GPGSM_VERSION]) - fi -fi -run_gpgsm_test="$ok" -AC_ARG_ENABLE(gpgsm-test, - AC_HELP_STRING([--disable-gpgsm-test], [disable GPGSM run test]), - run_gpgsm_test=$enableval) -AM_CONDITIONAL(RUN_GPGSM_TESTS, test "$run_gpgsm_test" = "yes") - - -# -# Check for G13 -# -NO_OVERRIDE=no -AC_ARG_WITH(g13, - AC_HELP_STRING([--with-g13=PATH], - [use g13 binary at PATH]), - G13=$withval, NO_OVERRIDE=yes) -if test "$NO_OVERRIDE" = "yes" || test "$G13" = "yes"; then - G13= - NO_OVERRIDE=yes - if test "$cross_compiling" != "yes"; then - if test "$gpgconf_usable_for_test" = "yes"; then - G13="`$GPGCONF --list-components | grep ^g13: | cut -d: -f 3`" - if test -z "$G13"; then - # Use a hack if gpgconf has no support for g13. - G13="`$GPGCONF --list-dirs | grep ^bindir: | cut -d: -f 2`/g13" - fi - else - AC_PATH_PROG(G13, g13) - fi - fi - if test -z "$G13"; then - G13="$G13_DEFAULT" - fi -fi -if test "$G13" = no; then - if test "$NO_OVERRIDE" = "yes"; then - if test "$cross_compiling" != "yes"; then - AC_MSG_WARN([ -*** -*** Could not find g13, install g13 or use --with-g13=PATH to enable it -***]) - else - AC_MSG_ERROR([ -*** -*** Can not determine path to g13 when cross-compiling, use --with-g13=PATH -***]) - fi - fi -else - AC_DEFINE_UNQUOTED(G13_PATH, "$G13", [Path to the G13 binary.]) - AC_DEFINE(ENABLE_G13,1,[Whether G13 support is enabled]) -fi -AM_CONDITIONAL(HAVE_G13, test "$G13" != "no") - -dnl Check for G13 version requirement. -G13_VERSION=unknown -ok=maybe -if test -z "$G13" -o "x$G13" = "xno"; then - ok=no -else - if test "$cross_compiling" = "yes"; then - AC_MSG_WARN([G13 version can not be checked when cross compiling]) - ok=no - else - if test ! -x "$G13"; then - AC_MSG_WARN([G13 not executable, version check disabled]) - ok=no - fi - fi -fi -if test "$ok" = "maybe"; then - AC_MSG_CHECKING(for G13 >= $NEED_G13_VERSION) - req_major=`echo $NEED_G13_VERSION | \ - sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'` - req_minor=`echo $NEED_G13_VERSION | \ - sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'` - req_micro=`echo $NEED_G13_VERSION | \ - sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'` - G13_VERSION=`$G13 --version | sed -n '1 s/.*\ \([[0-9]].*\)/\1/p'` - major=`echo $G13_VERSION | \ - sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'` - minor=`echo $G13_VERSION | \ - sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'` - micro=`echo $G13_VERSION | \ - sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'` - - if test "$major" -gt "$req_major"; then - ok=yes - else - if test "$major" -eq "$req_major"; then - if test "$minor" -gt "$req_minor"; then - ok=yes - else - if test "$minor" -eq "$req_minor"; then - if test "$micro" -ge "$req_micro"; then - ok=yes - fi - fi - fi - fi - fi - if test "$ok" = "yes"; then - AC_MSG_RESULT(yes) - else - AC_MSG_RESULT(no) - AC_MSG_WARN([G13 must be at least version $NEED_G13_VERSION]) - fi -fi -run_g13_test="$ok" -AC_ARG_ENABLE(g13-test, - AC_HELP_STRING([--disable-g13-test], [disable G13 run test]), - run_g13_test=$enableval) -AM_CONDITIONAL(RUN_G13_TESTS, test "$run_g13_test" = "yes") # @@ -1030,7 +583,7 @@ if test "$have_libassuan" = "no"; then die=yes AC_MSG_NOTICE([[ *** -*** You need libassuan to build this program with GPGSM support. +*** 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). @@ -1067,17 +620,6 @@ echo " Revision: mym4_revision (mym4_revision_dec) Platform: $host - Gpgconf at: $GPGCONF - Gpgconf version: $GPGCONF_VERSION, min. $NEED_GPGCONF_VERSION - GPG at: $GPG - GPG version: $GPG_VERSION, min. $NEED_GPG_VERSION - Gpgsm at: $GPGSM - Gpgsm version: $GPGSM_VERSION, min. $NEED_GPGSM_VERSION - G13 at: $G13 - G13 version: $G13_VERSION, min. $NEED_G13_VERSION - - Assuan version: $libassuan_config_version, min. $NEED_LIBASSUAN_VERSION - UI Server: $uiserver FD Passing: $use_descriptor_passing GPGME Pthread: $have_pthread diff --git a/src/Makefile.am b/src/Makefile.am index 1f95103..abc014c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -66,30 +66,6 @@ if HAVE_W32CE_SYSTEM system_components += w32-ce.h w32-ce.c endif -if HAVE_GPGSM -gpgsm_components = engine-gpgsm.c -else -gpgsm_components = -endif - -if HAVE_ASSUAN -assuan_components = assuan-support.c engine-assuan.c -else -assuan_components = -endif - -if HAVE_GPGCONF -gpgconf_components = engine-gpgconf.c -else -gpgconf_components = -endif - -if HAVE_G13 -g13_components = engine-g13.c -else -g13_components = -endif - if HAVE_UISERVER uiserver_components = engine-uiserver.c else @@ -113,11 +89,11 @@ main_sources = \ sign.c passphrase.c progress.c \ key.c keylist.c trust-item.c trustlist.c \ import.c export.c genkey.c delete.c edit.c getauditlog.c \ - opassuan.c passwd.c \ + opassuan.c passwd.c assuan-support.c \ engine.h engine-backend.h engine.c engine-gpg.c status-table.c \ - $(gpgsm_components) $(assuan_components) $(gpgconf_components) \ + engine-gpgsm.c engine-assuan.c engine-gpgconf.c \ $(uiserver_components) \ - $(g13_components) vfs-mount.c vfs-create.c \ + engine-g13.c vfs-mount.c vfs-create.c \ gpgconf.c \ sema.h priv-io.h $(system_components) sys-util.h dirinfo.c \ debug.c debug.h gpgme.c version.c error.c diff --git a/src/dirinfo.c b/src/dirinfo.c index 27c0dd7..2e387fa 100644 --- a/src/dirinfo.c +++ b/src/dirinfo.c @@ -38,6 +38,7 @@ enum { WANT_HOMEDIR, WANT_AGENT_SOCKET, + WANT_GPGCONF_NAME, WANT_GPG_NAME, WANT_GPGSM_NAME, WANT_G13_NAME, @@ -49,6 +50,7 @@ static struct { int valid; /* Cached information is valid. */ char *homedir; char *agent_socket; + char *gpgconf_name; char *gpg_name; char *gpgsm_name; char *g13_name; @@ -194,13 +196,14 @@ get_gpgconf_item (int what) LOCK (dirinfo_lock); if (!dirinfo.valid) { - const char *pgmname; + char *pgmname; pgmname = _gpgme_get_gpgconf_path (); if (pgmname && access (pgmname, F_OK)) { _gpgme_debug (DEBUG_INIT, "gpgme_dinfo: gpgconf='%s' [not installed]\n", pgmname); + free (pgmname); pgmname = NULL; /* Not available. */ } else @@ -212,12 +215,13 @@ get_gpgconf_item (int what) GnuPG-1. */ pgmname = _gpgme_get_gpg_path (); if (pgmname) - dirinfo.gpg_name = strdup (pgmname); + dirinfo.gpg_name = pgmname; } else { read_gpgconf_dirs (pgmname, 0); read_gpgconf_dirs (pgmname, 1); + dirinfo.gpgconf_name = pgmname; } /* Even if the reading of the directories failed (e.g. due to an too old version gpgconf or no gpgconf at all), we need to @@ -249,6 +253,7 @@ get_gpgconf_item (int what) { case WANT_HOMEDIR: result = dirinfo.homedir; break; case WANT_AGENT_SOCKET: result = dirinfo.agent_socket; break; + case WANT_GPGCONF_NAME: result = dirinfo.gpgconf_name; break; case WANT_GPG_NAME: result = dirinfo.gpg_name; break; case WANT_GPGSM_NAME: result = dirinfo.gpgsm_name; break; case WANT_G13_NAME: result = dirinfo.g13_name; break; @@ -294,14 +299,11 @@ _gpgme_get_default_g13_name (void) return get_gpgconf_item (WANT_G13_NAME); } -/* Return the default gpgconf file name. Returns NULL if not known. - Because gpgconf is the binary used to retrieved all these default - names, this function is merely a simple wrapper around the function - used to locate this binary. */ +/* Return the default gpgconf file name. Returns NULL if not known. */ const char * _gpgme_get_default_gpgconf_name (void) { - return _gpgme_get_gpgconf_path (); + return get_gpgconf_item (WANT_GPGCONF_NAME); } /* Return the default UI-server socket name. Returns NULL if not diff --git a/src/engine-backend.h b/src/engine-backend.h index a4c0eb2..a768652 100644 --- a/src/engine-backend.h +++ b/src/engine-backend.h @@ -128,18 +128,10 @@ struct engine_ops extern struct engine_ops _gpgme_engine_ops_gpg; /* OpenPGP. */ -#ifdef ENABLE_GPGSM extern struct engine_ops _gpgme_engine_ops_gpgsm; /* CMS. */ -#endif -#ifdef ENABLE_GPGCONF extern struct engine_ops _gpgme_engine_ops_gpgconf; /* gpg-conf. */ -#endif -#ifdef ENABLE_ASSUAN extern struct engine_ops _gpgme_engine_ops_assuan; /* Low-level Assuan. */ -#endif -#ifdef ENABLE_G13 extern struct engine_ops _gpgme_engine_ops_g13; /* Crypto VFS. */ -#endif #ifdef ENABLE_UISERVER extern struct engine_ops _gpgme_engine_ops_uiserver; #endif diff --git a/src/engine-g13.c b/src/engine-g13.c index b97e0b4..f091015 100644 --- a/src/engine-g13.c +++ b/src/engine-g13.c @@ -107,7 +107,7 @@ g13_get_version (const char *file_name) static const char * g13_get_req_version (void) { - return NEED_G13_VERSION; + return "2.1.0"; } diff --git a/src/engine-gpg.c b/src/engine-gpg.c index 3bc9f66..2f59bb9 100644 --- a/src/engine-gpg.c +++ b/src/engine-gpg.c @@ -1,7 +1,7 @@ /* engine-gpg.c - Gpg Engine. Copyright (C) 2000 Werner Koch (dd9jn) Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, - 2009, 2010, 2012 g10 Code GmbH + 2009, 2010, 2012, 2013 g10 Code GmbH This file is part of GPGME. @@ -303,7 +303,7 @@ gpg_get_version (const char *file_name) static const char * gpg_get_req_version (void) { - return NEED_GPG_VERSION; + return "1.4.0"; } diff --git a/src/engine-gpgconf.c b/src/engine-gpgconf.c index 1d457bb..47cde66 100644 --- a/src/engine-gpgconf.c +++ b/src/engine-gpgconf.c @@ -68,7 +68,7 @@ gpgconf_get_version (const char *file_name) static const char * gpgconf_get_req_version (void) { - return NEED_GPGCONF_VERSION; + return "2.0.4"; } diff --git a/src/engine-gpgsm.c b/src/engine-gpgsm.c index cee20e3..24cd34d 100644 --- a/src/engine-gpgsm.c +++ b/src/engine-gpgsm.c @@ -127,7 +127,7 @@ gpgsm_get_version (const char *file_name) static const char * gpgsm_get_req_version (void) { - return NEED_GPGSM_VERSION; + return "2.0.4"; } diff --git a/src/engine.c b/src/engine.c index 09f379c..80febea 100644 --- a/src/engine.c +++ b/src/engine.c @@ -46,26 +46,10 @@ struct engine static struct engine_ops *engine_ops[] = { &_gpgme_engine_ops_gpg, /* OpenPGP. */ -#ifdef ENABLE_GPGSM &_gpgme_engine_ops_gpgsm, /* CMS. */ -#else - NULL, -#endif -#ifdef ENABLE_GPGCONF &_gpgme_engine_ops_gpgconf, /* gpg-conf. */ -#else - NULL, -#endif -#ifdef ENABLE_ASSUAN &_gpgme_engine_ops_assuan, /* Low-Level Assuan. */ -#else - NULL, -#endif -#ifdef ENABLE_G13 &_gpgme_engine_ops_g13, /* Crypto VFS. */ -#else - NULL, -#endif #ifdef ENABLE_UISERVER &_gpgme_engine_ops_uiserver /* UI-Server. */ #else diff --git a/src/posix-util.c b/src/posix-util.c index fd44507..d4e4e3f 100644 --- a/src/posix-util.c +++ b/src/posix-util.c @@ -30,47 +30,60 @@ #include "util.h" #include "sys-util.h" -const char * -_gpgme_get_gpg_path (void) -{ -#ifdef GPG_PATH - return GPG_PATH; -#else - return NULL; -#endif -} -const char * -_gpgme_get_gpgsm_path (void) +/* Find an executable program PGM along the envvar PATH. */ +static char * +walk_path (const char *pgm) { -#ifdef GPGSM_PATH - return GPGSM_PATH; -#else + const char *path, *s; + char *fname, *p; + + path = getenv ("PATH"); + if (!path) + path = "/bin:/usr/bin:."; + + fname = malloc (strlen (path) + 1 + strlen (pgm) + 1); + if (!fname) + return NULL; + + for (;;) + { + for (s=path, p=fname; *s && *s != ':'; s++, p++) + *p = *s; + if (*p != '/') + *p++ = '/'; + strcpy (p, pgm); + if (!access (fname, X_OK)) + return fname; + if (!*s) + break; + path = s + 1; + } + + free (fname); return NULL; -#endif } -const char * -_gpgme_get_gpgconf_path (void) + +/* Return the full file name of the GPG binary. This function is used + if gpgconf was not found and thus it can be assumed that gpg2 is + not installed. This function is only called by get_gpgconf_item + and may not be called concurrently. */ +char * +_gpgme_get_gpg_path (void) { -#ifdef GPGCONF_PATH - return GPGCONF_PATH; -#else - return NULL; -#endif + return walk_path ("gpg"); } -const char * -_gpgme_get_g13_path (void) + +/* This function is only called by get_gpgconf_item and may not be + called concurrently. */ +char * +_gpgme_get_gpgconf_path (void) { -#ifdef G13_PATH - return G13_PATH; -#else - return NULL; -#endif + return walk_path ("gpgconf"); } - /* See w32-util.c */ int _gpgme_get_conf_int (const char *key, int *value) diff --git a/src/sys-util.h b/src/sys-util.h index f6506d3..3686f89 100644 --- a/src/sys-util.h +++ b/src/sys-util.h @@ -21,9 +21,7 @@ #define SYS_UTIL_H /*-- {posix,w32}-util.c --*/ -const char *_gpgme_get_gpg_path (void); -const char *_gpgme_get_gpgsm_path (void); -const char *_gpgme_get_gpgconf_path (void); -const char *_gpgme_get_g13_path (void); +char *_gpgme_get_gpg_path (void); +char *_gpgme_get_gpgconf_path (void); #endif /* SYS_UTIL_H */ diff --git a/src/util.h b/src/util.h index c432980..57c8b13 100644 --- a/src/util.h +++ b/src/util.h @@ -151,25 +151,13 @@ const char *_gpgme_get_w32spawn_path (void); char *_gpgme_w32ce_get_debug_envvar (void); #endif /*HAVE_W32CE_SYSTEM*/ -/*-- Error codes not yet available in current gpg-error.h. --*/ -#ifndef GPG_ERR_UNFINISHED -#define GPG_ERR_UNFINISHED 199 -#endif -#ifndef GPG_ERR_NOT_OPERATIONAL -#define GPG_ERR_NOT_OPERATIONAL 176 -#endif -#ifndef GPG_ERR_MISSING_ISSUER_CERT -#define GPG_ERR_MISSING_ISSUER_CERT 185 -#endif -#ifdef ENABLE_ASSUAN #include /* System hooks for assuan integration. */ extern struct assuan_system_hooks _gpgme_assuan_system_hooks; extern struct assuan_malloc_hooks _gpgme_assuan_malloc_hooks; int _gpgme_assuan_log_cb (assuan_context_t ctx, void *hook, unsigned int cat, const char *msg); -#endif #endif /* UTIL_H */ diff --git a/src/w32-util.c b/src/w32-util.c index 4cee1cb..31a58bb 100644 --- a/src/w32-util.c +++ b/src/w32-util.c @@ -374,7 +374,7 @@ find_program_in_inst_dir (const char *inst_dir, const char *name) /* If an installation directory has been passed, this overrides a location given bu the registry. The idea here is that we prefer - a a program installed alongside with gpgme. We don't want the + a program installed alongside with gpgme. We don't want the registry to override this to have a better isolation of an gpgme aware applications for other effects. Note that the "Install Directory" registry item has been used for ages in Gpg4win and @@ -424,72 +424,36 @@ find_program_at_standard_place (const char *name) } -const char * +/* Return the full file name of the GPG binary. This function is used + if gpgconf was not found and thus it can be assumed that gpg2 is + not installed. This function is only called by get_gpgconf_item + and may not be called concurrently. */ +char * _gpgme_get_gpg_path (void) { - static char *gpg_program; + char *gpg; const char *inst_dir; inst_dir = _gpgme_get_inst_dir (); - LOCK (get_path_lock); - if (!gpg_program) - gpg_program = find_program_in_inst_dir (inst_dir, "gpg.exe"); - if (!gpg_program) - gpg_program = find_program_at_standard_place ("GNU\\GnuPG\\gpg.exe"); - UNLOCK (get_path_lock); - return gpg_program; + gpg = find_program_in_inst_dir (inst_dir, "gpg.exe"); + if (!gpg) + gpg = find_program_at_standard_place ("GNU\\GnuPG\\gpg.exe"); + return gpg; } - -const char * -_gpgme_get_gpgsm_path (void) -{ - static char *gpgsm_program; - const char *inst_dir; - - inst_dir = _gpgme_get_inst_dir (); - LOCK (get_path_lock); - if (!gpgsm_program) - gpgsm_program = find_program_in_inst_dir (inst_dir, "gpgsm.exe"); - if (!gpgsm_program) - gpgsm_program = find_program_at_standard_place ("GNU\\GnuPG\\gpgsm.exe"); - UNLOCK (get_path_lock); - return gpgsm_program; -} - - -const char * +/* This function is only called by get_gpgconf_item and may not be + called concurrently. */ +char * _gpgme_get_gpgconf_path (void) { - static char *gpgconf_program; - const char *inst_dir; - - inst_dir = _gpgme_get_inst_dir (); - LOCK (get_path_lock); - if (!gpgconf_program) - gpgconf_program = find_program_in_inst_dir (inst_dir, "gpgconf.exe"); - if (!gpgconf_program) - gpgconf_program - = find_program_at_standard_place ("GNU\\GnuPG\\gpgconf.exe"); - UNLOCK (get_path_lock); - return gpgconf_program; -} - - -const char * -_gpgme_get_g13_path (void) -{ - static char *g13_program; + char *gpgconf; const char *inst_dir; inst_dir = _gpgme_get_inst_dir (); - LOCK (get_path_lock); - if (!g13_program) - g13_program = find_program_in_inst_dir (inst_dir, "g13.exe"); - if (!g13_program) - g13_program = find_program_at_standard_place ("GNU\\GnuPG\\g13.exe"); - UNLOCK (get_path_lock); - return g13_program; + gpgconf = find_program_in_inst_dir (inst_dir, "gpgconf.exe"); + if (!gpgconf) + gpgconf = find_program_at_standard_place ("GNU\\GnuPG\\gpgconf.exe"); + return gpgconf; } diff --git a/tests/gpg/Makefile.am b/tests/gpg/Makefile.am index c9000c9..e72bd49 100644 --- a/tests/gpg/Makefile.am +++ b/tests/gpg/Makefile.am @@ -19,8 +19,8 @@ ## Process this file with automake to produce Makefile.in -GPG = @GPG@ -GPG_AGENT = @GPG_AGENT@ +GPG = gpg +GPG_AGENT = gpg-agent TESTS_ENVIRONMENT = GNUPGHOME=$(abs_builddir) LC_ALL=C GPG_AGENT_INFO= diff --git a/tests/gpgsm/Makefile.am b/tests/gpgsm/Makefile.am index 9086134..45b3b50 100644 --- a/tests/gpgsm/Makefile.am +++ b/tests/gpgsm/Makefile.am @@ -1,27 +1,27 @@ # Copyright (C) 2000 Werner Koch (dd9jn) # Copyright (C) 2001 g10 Code GmbH -# +# # This file is part of GPGME. -# +# # GPGME is free software; you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as # published by the Free Software Foundation; either version 2.1 of the # License, or (at your option) any later version. -# +# # GPGME is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General # Public License for more details. -# +# # You should have received a copy of the GNU Lesser General Public # License along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA ## Process this file with automake to produce Makefile.in -GPGSM = @GPGSM@ +GPGSM = gpgsm -TESTS_ENVIRONMENT = GNUPGHOME=$(abs_builddir) GPG_AGENT_INFO= +TESTS_ENVIRONMENT = GNUPGHOME=$(abs_builddir) GPG_AGENT_INFO= noinst_HEADERS = t-support.h TESTS = t-import t-keylist t-encrypt t-verify t-decrypt t-sign t-export @@ -41,7 +41,7 @@ noinst_PROGRAMS = $(TESTS) t-genkey cms-keylist cms-decrypt key_id = 32100C27173EF6E9C4E9A25D3D69F86D37A4F939 CLEANFILES = pubring.kbx pubring.kbx~ gpgsm.conf trustlist.txt \ - random_seed S.gpg-agent + random_seed S.gpg-agent clean-local: -gpg-connect-agent KILLAGENT /bye @@ -51,7 +51,7 @@ all-local: ./pubring.kbx ./gpgsm.conf ./private-keys-v1.d/$(key_id).key ./trustl export GNUPGHOME := $(abs_builddir) -export GPG_AGENT_INFO := +export GPG_AGENT_INFO := ./pubring.kbx: $(srcdir)/cert_g10code_test1.der $(GPGSM) --import $(srcdir)/cert_g10code_test1.der diff --git a/tests/t-engine-info.c b/tests/t-engine-info.c index ec2e1e8..43acd3d 100644 --- a/tests/t-engine-info.c +++ b/tests/t-engine-info.c @@ -41,30 +41,6 @@ } \ while (0) - -void -check_engine_info (gpgme_engine_info_t info, gpgme_protocol_t protocol, - const char *file_name, const char *req_version) -{ - if (info->protocol != protocol) - { - fprintf (stderr, "Unexpected protocol %i (expected %i instead)\n", - info->protocol, protocol); - exit (1); - } - if (strcmp (info->file_name, file_name)) - { - fprintf (stderr, "Unexpected file name to executable %s (expected %s instead)\n", - info->file_name, file_name); - exit (1); - } - if (strcmp (info->req_version, req_version)) - { - fprintf (stderr, "Unexpected required version %s (expected %s instead)\n", - info->req_version, req_version); - exit (1); - } -} int @@ -77,18 +53,9 @@ main (int argc, char **argv ) err = gpgme_get_engine_info (&info); fail_if_err (err); - check_engine_info (info, GPGME_PROTOCOL_OpenPGP, GPG_PATH, NEED_GPG_VERSION); - - info = info->next; -#ifdef GPGSM_PATH - check_engine_info (info, GPGME_PROTOCOL_CMS, GPGSM_PATH, NEED_GPGSM_VERSION); -#else - if (info) - { - fprintf (stderr, "Unexpected engine info.\n"); - exit (1); - } -#endif + for (; info; info = info->next) + fprintf (stdout, "protocol=%d engine='%s' v='%s' (min='%s')\n", + info->protocol, info->file_name, info->version, info->req_version); return 0; } ----------------------------------------------------------------------- Summary of changes: NEWS | 13 ++ README | 9 +- configure.ac | 512 +++-------------------------------------------- doc/gpgme.texi | 49 +++-- src/Makefile.am | 30 +-- src/dirinfo.c | 44 ++-- src/engine-backend.h | 8 - src/engine-g13.c | 2 +- src/engine-gpg.c | 4 +- src/engine-gpgconf.c | 2 +- src/engine-gpgsm.c | 2 +- src/engine.c | 16 -- src/gpgme.c | 10 + src/posix-util.c | 110 +++++++--- src/sys-util.h | 9 +- src/util.h | 14 +- src/w32-util.c | 154 +++++++++----- tests/gpg/Makefile.am | 4 +- tests/gpgsm/Makefile.am | 16 +- tests/t-engine-info.c | 98 +++++---- 20 files changed, 388 insertions(+), 718 deletions(-) hooks/post-receive -- GnuPG Made Easy http://git.gnupg.org From cvs at cvs.gnupg.org Mon Jan 6 17:18:09 2014 From: cvs at cvs.gnupg.org (by Werner Koch) Date: Mon, 06 Jan 2014 17:18:09 +0100 Subject: [git] Assuan - branch, master, updated. libassuan-2.1.1-3-ge78abe4 Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "IPC library used by GnuPG". The branch, master has been updated via e78abe490ff6806f8083b23075ae036e5894513a (commit) from 46b6d97b4a396c16df53e82872c3cc772d427623 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit e78abe490ff6806f8083b23075ae036e5894513a Author: Werner Koch Date: Mon Jan 6 16:16:24 2014 +0100 Update libtool and autogen.sh. -- This is the version from current libgpg-error which already has the changes done here plus these: bf0d67db * Update libtool to support Android. dd05f379 * Fix libtool 2.4.2 to correctly detect .def files. 6971fe55 * Update to libtool 2.4.2. diff --git a/autogen.sh b/autogen.sh index 4e0987f..3e12b86 100755 --- a/autogen.sh +++ b/autogen.sh @@ -109,7 +109,7 @@ if [ "$myhost" = "w32" ]; then ;; *) [ -z "$w32root" ] && w32root="$HOME/w32root" - toolprefixes="$w32_toolprefixes i586-mingw32msvc" + toolprefixes="$w32_toolprefixes i686-w64-mingw32 i586-mingw32msvc" toolprefixes="$toolprefixes i386-mingw32msvc mingw32" ;; esac diff --git a/ltmain.sh b/ltmain.sh index d47c0ba..07bf696 100755 --- a/ltmain.sh +++ b/ltmain.sh @@ -1,9 +1,9 @@ -# libtool (GNU libtool) 2.4 +# libtool (GNU libtool) 2.4.2 # Written by Gordon Matzigkeit , 1996 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, -# 2007, 2008, 2009, 2010 Free Software Foundation, Inc. +# 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. # This is free software; see the source for copying conditions. There is NO # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. @@ -41,6 +41,7 @@ # --quiet, --silent don't print informational messages # --no-quiet, --no-silent # print informational messages (default) +# --no-warn don't display warning messages # --tag=TAG use configuration variables from tag TAG # -v, --verbose print more informational messages than default # --no-verbose don't print the extra informational messages @@ -69,7 +70,7 @@ # compiler: $LTCC # compiler flags: $LTCFLAGS # linker: $LD (gnu? $with_gnu_ld) -# $progname: (GNU libtool) 2.4 Debian-2.4-2 +# $progname: (GNU libtool) 2.4.2 Debian-2.4.2-1 # automake: $automake_version # autoconf: $autoconf_version # @@ -79,9 +80,9 @@ PROGRAM=libtool PACKAGE=libtool -VERSION="2.4 Debian-2.4-2" +VERSION="2.4.2 Debian-2.4.2-1" TIMESTAMP="" -package_revision=1.3293 +package_revision=1.3337 # Be Bourne compatible if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then @@ -136,15 +137,10 @@ progpath="$0" : ${CP="cp -f"} test "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'} -: ${EGREP="/bin/grep -E"} -: ${FGREP="/bin/grep -F"} -: ${GREP="/bin/grep"} -: ${LN_S="ln -s"} : ${MAKE="make"} : ${MKDIR="mkdir"} : ${MV="mv -f"} : ${RM="rm -f"} -: ${SED="/bin/sed"} : ${SHELL="${CONFIG_SHELL-/bin/sh}"} : ${Xsed="$SED -e 1s/^X//"} @@ -387,7 +383,7 @@ case $progpath in ;; *) save_IFS="$IFS" - IFS=: + IFS=${PATH_SEPARATOR-:} for progdir in $PATH; do IFS="$save_IFS" test -x "$progdir/$progname" && break @@ -415,6 +411,10 @@ sed_make_literal_regex='s,[].[^$\\*\/],\\&,g' # (escaped) backslashes. A very naive implementation. lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' +# Sed substitution to remove simple comments and empty +# lines from a Windows .def file. +sed_uncomment_deffile='/^;/d; /^[ ]*$/d' + # Re-`\' parameter expansions in output of double_quote_subst that were # `\'-ed in input to the same. If an odd number of `\' preceded a '$' # in input to double_quote_subst, that '$' was protected from expansion. @@ -771,8 +771,8 @@ func_help () s*\$LTCFLAGS*'"$LTCFLAGS"'* s*\$LD*'"$LD"'* s/\$with_gnu_ld/'"$with_gnu_ld"'/ - s/\$automake_version/'"`(automake --version) 2>/dev/null |$SED 1q`"'/ - s/\$autoconf_version/'"`(autoconf --version) 2>/dev/null |$SED 1q`"'/ + s/\$automake_version/'"`(${AUTOMAKE-automake} --version) 2>/dev/null |$SED 1q`"'/ + s/\$autoconf_version/'"`(${AUTOCONF-autoconf} --version) 2>/dev/null |$SED 1q`"'/ p d } @@ -1052,6 +1052,7 @@ opt_finish=false opt_help=false opt_help_all=false opt_silent=: +opt_warning=: opt_verbose=: opt_silent=false opt_verbose=false @@ -1120,6 +1121,10 @@ esac opt_silent=false func_append preserve_args " $opt" ;; + --no-warning|--no-warn) + opt_warning=false +func_append preserve_args " $opt" + ;; --no-verbose) opt_verbose=false func_append preserve_args " $opt" @@ -2059,7 +2064,7 @@ func_mode_compile () *.[cCFSifmso] | \ *.ada | *.adb | *.ads | *.asm | \ *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ - *.[fF][09]? | *.for | *.java | *.obj | *.sx | *.cu | *.cup) + *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) func_xform "$libobj" libobj=$func_xform_result ;; @@ -3201,11 +3206,13 @@ func_mode_install () # Set up the ranlib parameters. oldlib="$destdir/$name" + func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 + tool_oldlib=$func_to_tool_file_result func_show_eval "$install_prog \$file \$oldlib" 'exit $?' if test -n "$stripme" && test -n "$old_striplib"; then - func_show_eval "$old_striplib $oldlib" 'exit $?' + func_show_eval "$old_striplib $tool_oldlib" 'exit $?' fi # Do each command in the postinstall commands. @@ -3470,7 +3477,7 @@ static const void *lt_preloaded_setup() { # linked before any other PIC object. But we must not use # pic_flag when linking with -static. The problem exists in # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. - *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) + *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; *-*-hpux*) pic_flag_for_symtable=" $pic_flag" ;; @@ -3982,14 +3989,17 @@ func_exec_program_core () # launches target application with the remaining arguments. func_exec_program () { - for lt_wr_arg - do - case \$lt_wr_arg in - --lt-*) ;; - *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; - esac - shift - done + case \" \$* \" in + *\\ --lt-*) + for lt_wr_arg + do + case \$lt_wr_arg in + --lt-*) ;; + *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; + esac + shift + done ;; + esac func_exec_program_core \${1+\"\$@\"} } @@ -5057,9 +5067,15 @@ void lt_dump_script (FILE* f) { EOF func_emit_wrapper yes | - $SED -e 's/\([\\"]\)/\\\1/g' \ - -e 's/^/ fputs ("/' -e 's/$/\\n", f);/' - + $SED -n -e ' +s/^\(.\{79\}\)\(..*\)/\1\ +\2/ +h +s/\([\\"]\)/\\\1/g +s/$/\\n/ +s/\([^\n]*\).*/ fputs ("\1", f);/p +g +D' cat <<"EOF" } EOF @@ -5643,7 +5659,8 @@ func_mode_link () continue ;; - -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads) + -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ + |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) func_append compiler_flags " $arg" func_append compile_command " $arg" func_append finalize_command " $arg" @@ -6150,7 +6167,8 @@ func_mode_link () lib= found=no case $deplib in - -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads) + -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ + |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) if test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" @@ -6839,7 +6857,7 @@ func_mode_link () test "$hardcode_direct_absolute" = no; then add="$dir/$linklib" elif test "$hardcode_minus_L" = yes; then - add_dir="-L$dir" + add_dir="-L$absdir" # Try looking first in the location we're being installed to. if test -n "$inst_prefix_dir"; then case $libdir in @@ -7324,6 +7342,7 @@ func_mode_link () # which has an extra 1 added just for fun # case $version_type in + # correct linux to gnu/linux during the next big refactor darwin|linux|osf|windows|none) func_arith $number_major + $number_minor current=$func_arith_result @@ -7443,7 +7462,7 @@ func_mode_link () versuffix="$major.$revision" ;; - linux) + linux) # correct to gnu/linux during the next big refactor func_arith $current - $age major=.$func_arith_result versuffix="$major.$age.$revision" @@ -8039,6 +8058,11 @@ EOF # Test again, we may have decided not to build it any more if test "$build_libtool_libs" = yes; then + # Remove ${wl} instances when linking with ld. + # FIXME: should test the right _cmds variable. + case $archive_cmds in + *\$LD\ *) wl= ;; + esac if test "$hardcode_into_libs" = yes; then # Hardcode the library paths hardcode_libdirs= @@ -8069,7 +8093,7 @@ EOF elif test -n "$runpath_var"; then case "$perm_rpath " in *" $libdir "*) ;; - *) func_apped perm_rpath " $libdir" ;; + *) func_append perm_rpath " $libdir" ;; esac fi done @@ -8077,11 +8101,7 @@ EOF if test -n "$hardcode_libdir_separator" && test -n "$hardcode_libdirs"; then libdir="$hardcode_libdirs" - if test -n "$hardcode_libdir_flag_spec_ld"; then - eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\" - else - eval dep_rpath=\"$hardcode_libdir_flag_spec\" - fi + eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" fi if test -n "$runpath_var" && test -n "$perm_rpath"; then # We should set the runpath_var. @@ -8140,7 +8160,7 @@ EOF cygwin* | mingw* | cegcc*) if test -n "$export_symbols" && test -z "$export_symbols_regex"; then # exporting using user supplied symfile - if test "x`$SED 1q $export_symbols`" != xEXPORTS; then + if test "x`$SED "$sed_uncomment_deffile" $export_symbols | $SED 1q`" != xEXPORTS; then # and it's NOT already a .def file. Must figure out # which of the given symbols are data symbols and tag # them as such. So, trigger use of export_symbols_cmds. @@ -9171,6 +9191,8 @@ EOF esac done fi + func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 + tool_oldlib=$func_to_tool_file_result eval cmds=\"$old_archive_cmds\" func_len " $cmds" @@ -9280,7 +9302,8 @@ EOF *.la) func_basename "$deplib" name="$func_basename_result" - eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` + func_resolve_sysroot "$deplib" + eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` test -z "$libdir" && \ func_fatal_error "\`$deplib' is not a valid libtool archive" func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" diff --git a/m4/libtool.m4 b/m4/libtool.m4 index bd71daa..1d62b05 100644 --- a/m4/libtool.m4 +++ b/m4/libtool.m4 @@ -1,8 +1,8 @@ # libtool.m4 - Configure libtool for the host system. -*-Autoconf-*- # # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, -# 2006, 2007, 2008, 2009, 2010 Free Software Foundation, -# Inc. +# 2006, 2007, 2008, 2009, 2010, 2011 Free Software +# Foundation, Inc. # Written by Gordon Matzigkeit, 1996 # # This file is free software; the Free Software Foundation gives @@ -11,8 +11,8 @@ m4_define([_LT_COPYING], [dnl # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, -# 2006, 2007, 2008, 2009, 2010 Free Software Foundation, -# Inc. +# 2006, 2007, 2008, 2009, 2010, 2011 Free Software +# Foundation, Inc. # Written by Gordon Matzigkeit, 1996 # # This file is part of GNU Libtool. @@ -146,6 +146,8 @@ AC_REQUIRE([AC_CANONICAL_BUILD])dnl AC_REQUIRE([_LT_PREPARE_SED_QUOTE_VARS])dnl AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH])dnl +_LT_DECL([], [PATH_SEPARATOR], [1], [The PATH separator for the build system])dnl +dnl _LT_DECL([], [host_alias], [0], [The host system])dnl _LT_DECL([], [host], [0])dnl _LT_DECL([], [host_os], [0])dnl @@ -637,7 +639,7 @@ m4_ifset([AC_PACKAGE_NAME], [AC_PACKAGE_NAME ])config.lt[]dnl m4_ifset([AC_PACKAGE_VERSION], [ AC_PACKAGE_VERSION]) configured by $[0], generated by m4_PACKAGE_STRING. -Copyright (C) 2010 Free Software Foundation, Inc. +Copyright (C) 2011 Free Software Foundation, Inc. This config.lt script is free software; the Free Software Foundation gives unlimited permision to copy, distribute and modify it." @@ -801,6 +803,7 @@ AC_DEFUN([LT_LANG], m4_case([$1], [C], [_LT_LANG(C)], [C++], [_LT_LANG(CXX)], + [Go], [_LT_LANG(GO)], [Java], [_LT_LANG(GCJ)], [Fortran 77], [_LT_LANG(F77)], [Fortran], [_LT_LANG(FC)], @@ -822,6 +825,31 @@ m4_defun([_LT_LANG], ])# _LT_LANG +m4_ifndef([AC_PROG_GO], [ +############################################################ +# NOTE: This macro has been submitted for inclusion into # +# GNU Autoconf as AC_PROG_GO. When it is available in # +# a released version of Autoconf we should remove this # +# macro and use it instead. # +############################################################ +m4_defun([AC_PROG_GO], +[AC_LANG_PUSH(Go)dnl +AC_ARG_VAR([GOC], [Go compiler command])dnl +AC_ARG_VAR([GOFLAGS], [Go compiler flags])dnl +_AC_ARG_VAR_LDFLAGS()dnl +AC_CHECK_TOOL(GOC, gccgo) +if test -z "$GOC"; then + if test -n "$ac_tool_prefix"; then + AC_CHECK_PROG(GOC, [${ac_tool_prefix}gccgo], [${ac_tool_prefix}gccgo]) + fi +fi +if test -z "$GOC"; then + AC_CHECK_PROG(GOC, gccgo, gccgo, false) +fi +])#m4_defun +])#m4_ifndef + + # _LT_LANG_DEFAULT_CONFIG # ----------------------- m4_defun([_LT_LANG_DEFAULT_CONFIG], @@ -852,6 +880,10 @@ AC_PROVIDE_IFELSE([AC_PROG_GCJ], m4_ifdef([LT_PROG_GCJ], [m4_define([LT_PROG_GCJ], defn([LT_PROG_GCJ])[LT_LANG(GCJ)])])])])]) +AC_PROVIDE_IFELSE([AC_PROG_GO], + [LT_LANG(GO)], + [m4_define([AC_PROG_GO], defn([AC_PROG_GO])[LT_LANG(GO)])]) + AC_PROVIDE_IFELSE([LT_PROG_RC], [LT_LANG(RC)], [m4_define([LT_PROG_RC], defn([LT_PROG_RC])[LT_LANG(RC)])]) @@ -954,7 +986,13 @@ m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[ $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c 2>conftest.err _lt_result=$? - if test -f libconftest.dylib && test ! -s conftest.err && test $_lt_result = 0; then + # If there is a non-empty error log, and "single_module" + # appears in it, assume the flag caused a linker warning + if test -s conftest.err && $GREP single_module conftest.err; then + cat conftest.err >&AS_MESSAGE_LOG_FD + # Otherwise, if the output was created with a 0 exit code from + # the compiler, it worked. + elif test -f libconftest.dylib && test $_lt_result -eq 0; then lt_cv_apple_cc_single_mod=yes else cat conftest.err >&AS_MESSAGE_LOG_FD @@ -962,6 +1000,7 @@ m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[ rm -rf libconftest.dylib* rm -f conftest.* fi]) + AC_CACHE_CHECK([for -exported_symbols_list linker flag], [lt_cv_ld_exported_symbols_list], [lt_cv_ld_exported_symbols_list=no @@ -973,6 +1012,7 @@ m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[ [lt_cv_ld_exported_symbols_list=no]) LDFLAGS="$save_LDFLAGS" ]) + AC_CACHE_CHECK([for -force_load linker flag],[lt_cv_ld_force_load], [lt_cv_ld_force_load=no cat > conftest.c << _LT_EOF @@ -990,7 +1030,9 @@ _LT_EOF echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&AS_MESSAGE_LOG_FD $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err _lt_result=$? - if test -f conftest && test ! -s conftest.err && test $_lt_result = 0 && $GREP forced_load conftest 2>&1 >/dev/null; then + if test -s conftest.err && $GREP force_load conftest.err; then + cat conftest.err >&AS_MESSAGE_LOG_FD + elif test -f conftest && test $_lt_result -eq 0 && $GREP forced_load conftest >/dev/null 2>&1 ; then lt_cv_ld_force_load=yes else cat conftest.err >&AS_MESSAGE_LOG_FD @@ -1035,8 +1077,8 @@ _LT_EOF ]) -# _LT_DARWIN_LINKER_FEATURES -# -------------------------- +# _LT_DARWIN_LINKER_FEATURES([TAG]) +# --------------------------------- # Checks for linker and compiler features on darwin m4_defun([_LT_DARWIN_LINKER_FEATURES], [ @@ -1047,6 +1089,8 @@ m4_defun([_LT_DARWIN_LINKER_FEATURES], _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported if test "$lt_cv_ld_force_load" = "yes"; then _LT_TAGVAR(whole_archive_flag_spec, $1)='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`' + m4_case([$1], [F77], [_LT_TAGVAR(compiler_needs_object, $1)=yes], + [FC], [_LT_TAGVAR(compiler_needs_object, $1)=yes]) else _LT_TAGVAR(whole_archive_flag_spec, $1)='' fi @@ -1336,14 +1380,27 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) CFLAGS="$SAVE_CFLAGS" fi ;; -sparc*-*solaris*) +*-*solaris*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then case `/usr/bin/file conftest.o` in *64-bit*) case $lt_cv_prog_gnu_ld in - yes*) LD="${LD-ld} -m elf64_sparc" ;; + yes*) + case $host in + i?86-*-solaris*) + LD="${LD-ld} -m elf_x86_64" + ;; + sparc*-*-solaris*) + LD="${LD-ld} -m elf64_sparc" + ;; + esac + # GNU ld 2.21 introduced _sol2 emulations. Use them if available. + if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then + LD="${LD-ld}_sol2" + fi + ;; *) if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then LD="${LD-ld} -64" @@ -1420,13 +1477,13 @@ old_postuninstall_cmds= if test -n "$RANLIB"; then case $host_os in openbsd*) - old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib" + old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib" ;; *) - old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib" + old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib" ;; esac - old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib" + old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_oldlib" fi case $host_os in @@ -1606,6 +1663,11 @@ AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl lt_cv_sys_max_cmd_len=196608 ;; + os2*) + # The test takes a long time on OS/2. + lt_cv_sys_max_cmd_len=8192 + ;; + osf*) # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not @@ -1645,7 +1707,7 @@ AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl # If test is not a shell built-in, we'll probably end up computing a # maximum length that is only half of the actual maximum length, but # we can't tell. - while { test "X"`func_fallback_echo "$teststring$teststring" 2>/dev/null` \ + while { test "X"`env echo "$teststring$teststring" 2>/dev/null` \ = "X$teststring$teststring"; } >/dev/null 2>&1 && test $i != 17 # 1/2 MB should be enough do @@ -2191,7 +2253,7 @@ need_version=unknown case $host_os in aix3*) - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' shlibpath_var=LIBPATH @@ -2200,7 +2262,7 @@ aix3*) ;; aix[[4-9]]*) - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no hardcode_into_libs=yes @@ -2265,7 +2327,7 @@ beos*) ;; bsdi[[45]]*) - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' @@ -2404,7 +2466,7 @@ m4_if([$1], [],[ ;; dgux*) - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' @@ -2412,10 +2474,6 @@ dgux*) shlibpath_var=LD_LIBRARY_PATH ;; -freebsd1*) - dynamic_linker=no - ;; - freebsd* | dragonfly*) # DragonFly does not have aout. When/if they implement a new # versioning mechanism, adjust this. @@ -2423,7 +2481,7 @@ freebsd* | dragonfly*) objformat=`/usr/bin/objformat` else case $host_os in - freebsd[[123]]*) objformat=aout ;; + freebsd[[23]].*) objformat=aout ;; *) objformat=elf ;; esac fi @@ -2441,7 +2499,7 @@ freebsd* | dragonfly*) esac shlibpath_var=LD_LIBRARY_PATH case $host_os in - freebsd2*) + freebsd2.*) shlibpath_overrides_runpath=yes ;; freebsd3.[[01]]* | freebsdelf3.[[01]]*) @@ -2461,7 +2519,7 @@ freebsd* | dragonfly*) ;; gnu*) - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' @@ -2472,7 +2530,7 @@ gnu*) ;; haiku*) - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no dynamic_linker="$host_os runtime_loader" @@ -2533,7 +2591,7 @@ hpux9* | hpux10* | hpux11*) ;; interix[[3-9]]*) - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' @@ -2549,7 +2607,7 @@ irix5* | irix6* | nonstopux*) nonstopux*) version_type=nonstopux ;; *) if test "$lt_cv_prog_gnu_ld" = yes; then - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor else version_type=irix fi ;; @@ -2586,9 +2644,29 @@ linux*oldld* | linux*aout* | linux*coff*) dynamic_linker=no ;; -# This must be Linux ELF. +linux*android*) + version_type=none # Android doesn't support versioned libraries. + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$shared_ext' + soname_spec='$libname$release$shared_ext' + finish_cmds= + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + + # This implies no fast_install, which is unacceptable. + # Some rework will be needed to allow for fast_install + # before this can be enabled. + hardcode_into_libs=yes + + dynamic_linker='Android linker' + # Don't embed -rpath directories since the linker doesn't support them. + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + ;; + +# This must be glibc/ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu) - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' @@ -2663,7 +2741,7 @@ netbsd*) ;; newsos6) - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes @@ -2732,7 +2810,7 @@ rdos*) ;; solaris*) - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' @@ -2757,7 +2835,7 @@ sunos4*) ;; sysv4 | sysv4.3*) - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH @@ -2781,7 +2859,7 @@ sysv4 | sysv4.3*) sysv4*MP*) if test -d /usr/nec ;then - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' soname_spec='$libname${shared_ext}.$major' shlibpath_var=LD_LIBRARY_PATH @@ -2812,7 +2890,7 @@ sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) tpf*) # TPF is a cross-target only. Preferred cross-host = GNU/Linux. - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' @@ -2822,7 +2900,7 @@ tpf*) ;; uts4*) - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH @@ -3244,7 +3322,7 @@ irix5* | irix6* | nonstopux*) lt_cv_deplibs_check_method=pass_all ;; -# This must be Linux ELF. +# This must be glibc/ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu) lt_cv_deplibs_check_method=pass_all ;; @@ -3664,6 +3742,7 @@ for ac_symprfx in "" "_"; do # which start with @ or ?. lt_cv_sys_global_symbol_pipe="$AWK ['"\ " {last_section=section; section=\$ 3};"\ +" /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\ " /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\ " \$ 0!~/External *\|/{next};"\ " / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\ @@ -4248,7 +4327,9 @@ m4_if([$1], [CXX], [ case $cc_basename in nvcc*) # Cuda Compiler Driver 2.2 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Xlinker ' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-Xcompiler -fPIC' + if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then + _LT_TAGVAR(lt_prog_compiler_pic, $1)="-Xcompiler $_LT_TAGVAR(lt_prog_compiler_pic, $1)" + fi ;; esac else @@ -4340,18 +4421,33 @@ m4_if([$1], [CXX], [ ;; *) case `$CC -V 2>&1 | sed 5q` in - *Sun\ F* | *Sun*Fortran*) + *Sun\ Ceres\ Fortran* | *Sun*Fortran*\ [[1-7]].* | *Sun*Fortran*\ 8.[[0-3]]*) # Sun Fortran 8.3 passes all unrecognized flags to the linker _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='' ;; + *Sun\ F* | *Sun*Fortran*) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' + ;; *Sun\ C*) # Sun C 5.9 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' ;; + *Intel*\ [[CF]]*Compiler*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + ;; + *Portland\ Group*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; esac ;; esac @@ -4511,7 +4607,9 @@ m4_if([$1], [CXX], [ ;; cygwin* | mingw* | cegcc*) case $cc_basename in - cl*) ;; + cl*) + _LT_TAGVAR(exclude_expsyms, $1)='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' + ;; *) _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols' _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'] @@ -4539,7 +4637,6 @@ m4_if([$1], [CXX], [ _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= - _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported @@ -4702,7 +4799,7 @@ _LT_EOF _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' # If the export-symbols file already is a .def file (1st line # is EXPORTS), use it as is; otherwise, prepend... - _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then + _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED \"$sed_uncomment_deffile\" $export_symbols | $SED 1q`" = xEXPORTS; then cp $export_symbols $output_objdir/$soname.def; else echo EXPORTS > $output_objdir/$soname.def; @@ -4793,8 +4890,7 @@ _LT_EOF xlf* | bgf* | bgxlf* | mpixlf*) # IBM XL Fortran 10.1 on PPC cannot create shared libs itself _LT_TAGVAR(whole_archive_flag_spec, $1)='--whole-archive$convenience --no-whole-archive' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= - _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='-rpath $libdir' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib' if test "x$supports_anon_versioning" = xyes; then _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ @@ -5080,7 +5176,7 @@ _LT_EOF shrext_cmds=".dll" # FIXME: Setting linknames here is a bad hack. _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames=' - _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then + _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED \"$sed_uncomment_deffile\" $export_symbols | $SED 1q`" = xEXPORTS; then sed -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp; else sed -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp; @@ -5090,6 +5186,7 @@ _LT_EOF # The linker will not automatically build a static lib if we build a DLL. # _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + _LT_TAGVAR(exclude_expsyms, $1)='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1,DATA/'\'' | $SED -e '\''/^[[AITW]][[ ]]/s/.*[[ ]]//'\'' | sort | uniq > $export_symbols' # Don't use ranlib _LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib' @@ -5136,10 +5233,6 @@ _LT_EOF _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; - freebsd1*) - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor # support. Future versions do this automatically, but an explicit c++rt0.o # does not break anything, and helps significantly (at the cost of a little @@ -5152,7 +5245,7 @@ _LT_EOF ;; # Unfortunately, older versions of FreeBSD 2 do not have this feature. - freebsd2*) + freebsd2.*) _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_minus_L, $1)=yes @@ -5191,7 +5284,6 @@ _LT_EOF fi if test "$with_gnu_ld" = no; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' - _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes @@ -5633,9 +5725,6 @@ _LT_TAGDECL([], [no_undefined_flag], [1], _LT_TAGDECL([], [hardcode_libdir_flag_spec], [1], [Flag to hardcode $libdir into a binary during linking. This must work even if $libdir does not exist]) -_LT_TAGDECL([], [hardcode_libdir_flag_spec_ld], [1], - [[If ld is used when linking, flag to hardcode $libdir into a binary - during linking. This must work even if $libdir does not exist]]) _LT_TAGDECL([], [hardcode_libdir_separator], [1], [Whether we need a single "-rpath" flag with a separated argument]) _LT_TAGDECL([], [hardcode_direct], [0], @@ -5793,7 +5882,6 @@ _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= -_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported @@ -6087,7 +6175,7 @@ if test "$_lt_caught_CXX_error" != yes; then shrext_cmds=".dll" # FIXME: Setting linknames here is a bad hack. _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames=' - _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then + _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED \"$sed_uncomment_deffile\" $export_symbols | $SED 1q`" = xEXPORTS; then $SED -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp; else $SED -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp; @@ -6128,7 +6216,7 @@ if test "$_lt_caught_CXX_error" != yes; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' # If the export-symbols file already is a .def file (1st line # is EXPORTS), use it as is; otherwise, prepend... - _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then + _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED \"$sed_uncomment_deffile\" $export_symbols | $SED 1q`" = xEXPORTS; then cp $export_symbols $output_objdir/$soname.def; else echo EXPORTS > $output_objdir/$soname.def; @@ -6163,7 +6251,7 @@ if test "$_lt_caught_CXX_error" != yes; then esac ;; - freebsd[[12]]*) + freebsd2.*) # C++ shared libraries reported to be fairly broken before # switch to ELF _LT_TAGVAR(ld_shlibs, $1)=no @@ -6924,12 +7012,18 @@ public class foo { } }; _LT_EOF +], [$1], [GO], [cat > conftest.$ac_ext <<_LT_EOF +package foo +func foo() { +} +_LT_EOF ]) _lt_libdeps_save_CFLAGS=$CFLAGS case "$CC $CFLAGS " in #( *\ -flto*\ *) CFLAGS="$CFLAGS -fno-lto" ;; *\ -fwhopr*\ *) CFLAGS="$CFLAGS -fno-whopr" ;; +*\ -fuse-linker-plugin*\ *) CFLAGS="$CFLAGS -fno-use-linker-plugin" ;; esac dnl Parse the compiler output and extract the necessary @@ -7126,7 +7220,6 @@ _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= -_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_automatic, $1)=no @@ -7259,7 +7352,6 @@ _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= -_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_automatic, $1)=no @@ -7446,6 +7538,77 @@ CFLAGS=$lt_save_CFLAGS ])# _LT_LANG_GCJ_CONFIG +# _LT_LANG_GO_CONFIG([TAG]) +# -------------------------- +# Ensure that the configuration variables for the GNU Go compiler +# are suitably defined. These variables are subsequently used by _LT_CONFIG +# to write the compiler configuration to `libtool'. +m4_defun([_LT_LANG_GO_CONFIG], +[AC_REQUIRE([LT_PROG_GO])dnl +AC_LANG_SAVE + +# Source file extension for Go test sources. +ac_ext=go + +# Object file extension for compiled Go test sources. +objext=o +_LT_TAGVAR(objext, $1)=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code="package main; func main() { }" + +# Code to be used in simple link tests +lt_simple_link_test_code='package main; func main() { }' + +# ltmain only uses $CC for tagged configurations so make sure $CC is set. +_LT_TAG_COMPILER + +# save warnings/boilerplate of simple test code +_LT_COMPILER_BOILERPLATE +_LT_LINKER_BOILERPLATE + +# Allow CC to be a program name with arguments. +lt_save_CC=$CC +lt_save_CFLAGS=$CFLAGS +lt_save_GCC=$GCC +GCC=yes +CC=${GOC-"gccgo"} +CFLAGS=$GOFLAGS +compiler=$CC +_LT_TAGVAR(compiler, $1)=$CC +_LT_TAGVAR(LD, $1)="$LD" +_LT_CC_BASENAME([$compiler]) + +# Go did not exist at the time GCC didn't implicitly link libc in. +_LT_TAGVAR(archive_cmds_need_lc, $1)=no + +_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds +_LT_TAGVAR(reload_flag, $1)=$reload_flag +_LT_TAGVAR(reload_cmds, $1)=$reload_cmds + +## CAVEAT EMPTOR: +## There is no encapsulation within the following macros, do not change +## the running order or otherwise move them around unless you know exactly +## what you are doing... +if test -n "$compiler"; then + _LT_COMPILER_NO_RTTI($1) + _LT_COMPILER_PIC($1) + _LT_COMPILER_C_O($1) + _LT_COMPILER_FILE_LOCKS($1) + _LT_LINKER_SHLIBS($1) + _LT_LINKER_HARDCODE_LIBPATH($1) + + _LT_CONFIG($1) +fi + +AC_LANG_RESTORE + +GCC=$lt_save_GCC +CC=$lt_save_CC +CFLAGS=$lt_save_CFLAGS +])# _LT_LANG_GO_CONFIG + + # _LT_LANG_RC_CONFIG([TAG]) # ------------------------- # Ensure that the configuration variables for the Windows resource compiler @@ -7515,6 +7678,13 @@ dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([LT_AC_PROG_GCJ], []) +# LT_PROG_GO +# ---------- +AC_DEFUN([LT_PROG_GO], +[AC_CHECK_TOOL(GOC, gccgo,) +]) + + # LT_PROG_RC # ---------- AC_DEFUN([LT_PROG_RC], diff --git a/m4/ltoptions.m4 b/m4/ltoptions.m4 index 17cfd51..5d9acd8 100644 --- a/m4/ltoptions.m4 +++ b/m4/ltoptions.m4 @@ -326,9 +326,24 @@ dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], []) # MODE is either `yes' or `no'. If omitted, it defaults to `both'. m4_define([_LT_WITH_PIC], [AC_ARG_WITH([pic], - [AS_HELP_STRING([--with-pic], + [AS_HELP_STRING([--with-pic@<:@=PKGS@:>@], [try to use only PIC/non-PIC objects @<:@default=use both@:>@])], - [pic_mode="$withval"], + [lt_p=${PACKAGE-default} + case $withval in + yes|no) pic_mode=$withval ;; + *) + pic_mode=default + # Look at the argument we got. We use all the common list separators. + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for lt_pkg in $withval; do + IFS="$lt_save_ifs" + if test "X$lt_pkg" = "X$lt_p"; then + pic_mode=yes + fi + done + IFS="$lt_save_ifs" + ;; + esac], [pic_mode=default]) test -z "$pic_mode" && pic_mode=m4_default([$1], [default]) diff --git a/m4/ltversion.m4 b/m4/ltversion.m4 index 9c7b5d4..07a8602 100644 --- a/m4/ltversion.m4 +++ b/m4/ltversion.m4 @@ -9,15 +9,15 @@ # @configure_input@ -# serial 3293 ltversion.m4 +# serial 3337 ltversion.m4 # This file is part of GNU Libtool -m4_define([LT_PACKAGE_VERSION], [2.4]) -m4_define([LT_PACKAGE_REVISION], [1.3293]) +m4_define([LT_PACKAGE_VERSION], [2.4.2]) +m4_define([LT_PACKAGE_REVISION], [1.3337]) AC_DEFUN([LTVERSION_VERSION], -[macro_version='2.4' -macro_revision='1.3293' +[macro_version='2.4.2' +macro_revision='1.3337' _LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?]) _LT_DECL(, macro_revision, 0) ]) ----------------------------------------------------------------------- Summary of changes: autogen.sh | 2 +- ltmain.sh | 101 +++++++++++-------- m4/libtool.m4 | 292 +++++++++++++++++++++++++++++++++++++++++++------------ m4/ltoptions.m4 | 19 +++- m4/ltversion.m4 | 10 +- 5 files changed, 316 insertions(+), 108 deletions(-) hooks/post-receive -- IPC library used by GnuPG http://git.gnupg.org From cvs at cvs.gnupg.org Tue Jan 7 18:04:25 2014 From: cvs at cvs.gnupg.org (by Werner Koch) Date: Tue, 07 Jan 2014 18:04:25 +0100 Subject: [git] GPGME - branch, master, updated. gpgme-1.4.2-18-gab6e718 Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "GnuPG Made Easy". The branch, master has been updated via ab6e718327451e418782990c5a0a4e72588e3f0b (commit) via 121efcc5618374a1b4450b1d6a18bb3c35edb1fd (commit) via d63058b852b83515e7715103c04a684ecf59838a (commit) from 6564e5e78e8c6e5a120675a5699b5b75248cfbc7 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit ab6e718327451e418782990c5a0a4e72588e3f0b Author: Werner Koch Date: Tue Jan 7 17:59:59 2014 +0100 Make gpgconf engine work again - fixes 02ba35c1. * src/gpgconf.c: Remove ENABLE_GPGCONF and move prototypes to ... * src/engine-backend.h: ... here. -- gpgconf is a required part for gpgme. diff --git a/src/engine-backend.h b/src/engine-backend.h index a768652..7e6c0c1 100644 --- a/src/engine-backend.h +++ b/src/engine-backend.h @@ -136,4 +136,16 @@ extern struct engine_ops _gpgme_engine_ops_g13; /* Crypto VFS. */ extern struct engine_ops _gpgme_engine_ops_uiserver; #endif + +/* Prototypes for extra functions in engine-gpgconf.c */ +gpgme_error_t _gpgme_conf_arg_new (gpgme_conf_arg_t *arg_p, + gpgme_conf_type_t type, const void *value); +void _gpgme_conf_arg_release (gpgme_conf_arg_t arg, gpgme_conf_type_t type); +gpgme_error_t _gpgme_conf_opt_change (gpgme_conf_opt_t opt, int reset, + gpgme_conf_arg_t arg); +void _gpgme_conf_release (gpgme_conf_comp_t conf); +gpgme_error_t _gpgme_conf_load (void *engine, gpgme_conf_comp_t *conf_p); + + + #endif /* ENGINE_BACKEND_H */ diff --git a/src/gpgconf.c b/src/gpgconf.c index 47ef47a..6591452 100644 --- a/src/gpgconf.c +++ b/src/gpgconf.c @@ -28,18 +28,7 @@ #include "engine.h" #include "debug.h" -#ifdef ENABLE_GPGCONF -/* engine-gpgconf.c. */ -gpgme_error_t _gpgme_conf_arg_new (gpgme_conf_arg_t *arg_p, - gpgme_conf_type_t type, const void *value); -void _gpgme_conf_arg_release (gpgme_conf_arg_t arg, gpgme_conf_type_t type); -gpgme_error_t _gpgme_conf_opt_change (gpgme_conf_opt_t opt, int reset, - gpgme_conf_arg_t arg); -void _gpgme_conf_release (gpgme_conf_comp_t conf); -gpgme_error_t _gpgme_conf_load (void *engine, gpgme_conf_comp_t *conf_p); -gpgme_error_t gpgme_op_conf_save (gpgme_ctx_t ctx, gpgme_conf_comp_t comp); - -#endif +#include "engine-backend.h" /* Allocate a new gpgme_conf_arg_t. */ @@ -47,11 +36,7 @@ gpgme_error_t gpgme_conf_arg_new (gpgme_conf_arg_t *arg_p, gpgme_conf_type_t type, const void *value) { -#ifdef ENABLE_GPGCONF return _gpgme_conf_arg_new (arg_p, type, value); -#else - return gpg_error (GPG_ERR_NOT_IMPLEMENTED); -#endif } @@ -59,9 +44,7 @@ gpgme_conf_arg_new (gpgme_conf_arg_t *arg_p, void gpgme_conf_arg_release (gpgme_conf_arg_t arg, gpgme_conf_type_t type) { -#ifdef ENABLE_GPGCONF _gpgme_conf_arg_release (arg, type); -#endif } @@ -69,11 +52,7 @@ gpgme_conf_arg_release (gpgme_conf_arg_t arg, gpgme_conf_type_t type) gpgme_error_t gpgme_conf_opt_change (gpgme_conf_opt_t opt, int reset, gpgme_conf_arg_t arg) { -#ifdef ENABLE_GPGCONF return _gpgme_conf_opt_change (opt, reset, arg); -#else - return gpg_error (GPG_ERR_NOT_IMPLEMENTED); -#endif } @@ -82,9 +61,7 @@ gpgme_conf_opt_change (gpgme_conf_opt_t opt, int reset, gpgme_conf_arg_t arg) void gpgme_conf_release (gpgme_conf_comp_t conf) { -#ifdef ENABLE_GPGCONF _gpgme_conf_release (conf); -#endif } @@ -93,7 +70,6 @@ gpgme_conf_release (gpgme_conf_comp_t conf) gpgme_error_t gpgme_op_conf_load (gpgme_ctx_t ctx, gpgme_conf_comp_t *conf_p) { -#ifdef ENABLE_GPGCONF gpgme_error_t err; gpgme_protocol_t proto; @@ -109,9 +85,6 @@ gpgme_op_conf_load (gpgme_ctx_t ctx, gpgme_conf_comp_t *conf_p) err = _gpgme_engine_op_conf_load (ctx->engine, conf_p); ctx->protocol = proto; return err; -#else - return gpg_error (GPG_ERR_NOT_IMPLEMENTED); -#endif } @@ -119,7 +92,6 @@ gpgme_op_conf_load (gpgme_ctx_t ctx, gpgme_conf_comp_t *conf_p) gpgme_error_t gpgme_op_conf_save (gpgme_ctx_t ctx, gpgme_conf_comp_t comp) { -#ifdef ENABLE_GPGCONF gpgme_error_t err; gpgme_protocol_t proto; @@ -135,9 +107,6 @@ gpgme_op_conf_save (gpgme_ctx_t ctx, gpgme_conf_comp_t comp) err = _gpgme_engine_op_conf_save (ctx->engine, comp); ctx->protocol = proto; return err; -#else - return gpg_error (GPG_ERR_NOT_IMPLEMENTED); -#endif } commit 121efcc5618374a1b4450b1d6a18bb3c35edb1fd Author: Werner Koch Date: Tue Jan 7 13:32:08 2014 +0100 Make gpgme_new return a proper error if no engines are installed. * src/engine.c (gpgme_get_engine_info): Improve error handling. (_gpgme_engine_info_copy): Ditto. * src/gpgme.c (gpgme_new): Return error GPG_ERR_NO_ENGINE. diff --git a/src/engine.c b/src/engine.c index 80febea..4f2000c 100644 --- a/src/engine.c +++ b/src/engine.c @@ -182,6 +182,8 @@ _gpgme_engine_info_release (gpgme_engine_info_t info) gpgme_error_t gpgme_get_engine_info (gpgme_engine_info_t *info) { + gpgme_error_t err; + LOCK (engine_info_lock); if (!engine_info) { @@ -194,6 +196,7 @@ gpgme_get_engine_info (gpgme_engine_info_t *info) GPGME_PROTOCOL_UISERVER }; unsigned int proto; + err = 0; for (proto = 0; proto < DIM (proto_list); proto++) { const char *ofile_name = engine_get_file_name (proto_list[proto]); @@ -205,13 +208,24 @@ gpgme_get_engine_info (gpgme_engine_info_t *info) continue; file_name = strdup (ofile_name); - home_dir = ohome_dir? strdup (ohome_dir): NULL; + if (!file_name) + err = gpg_error_from_syserror (); + + if (ohome_dir) + { + home_dir = strdup (ohome_dir); + if (!home_dir && !err) + err = gpg_error_from_syserror (); + } + else + home_dir = NULL; *lastp = malloc (sizeof (*engine_info)); - if (!*lastp || !file_name) - { - int saved_err = gpg_error_from_syserror (); + if (!*lastp && !err) + err = gpg_error_from_syserror (); + if (err) + { _gpgme_engine_info_release (engine_info); engine_info = NULL; @@ -221,7 +235,7 @@ gpgme_get_engine_info (gpgme_engine_info_t *info) free (home_dir); UNLOCK (engine_info_lock); - return saved_err; + return err; } (*lastp)->protocol = proto_list[proto]; @@ -273,11 +287,13 @@ _gpgme_engine_info_copy (gpgme_engine_info_t *r_info) assert (info->file_name); file_name = strdup (info->file_name); + if (!file_name) + err = gpg_error_from_syserror (); if (info->home_dir) { home_dir = strdup (info->home_dir); - if (!home_dir) + if (!home_dir && !err) err = gpg_error_from_syserror (); } else @@ -286,19 +302,19 @@ _gpgme_engine_info_copy (gpgme_engine_info_t *r_info) if (info->version) { version = strdup (info->version); - if (!version) + if (!version && !err) err = gpg_error_from_syserror (); } else version = NULL; *lastp = malloc (sizeof (*engine_info)); - if (!*lastp || !file_name || err) - { - int saved_err = gpg_error_from_syserror (); + if (!*lastp && !err) + err = gpg_error_from_syserror (); + if (err) + { _gpgme_engine_info_release (new_info); - if (file_name) free (file_name); if (home_dir) @@ -307,7 +323,7 @@ _gpgme_engine_info_copy (gpgme_engine_info_t *r_info) free (version); UNLOCK (engine_info_lock); - return saved_err; + return err; } (*lastp)->protocol = info->protocol; diff --git a/src/gpgme.c b/src/gpgme.c index 4a8afa9..3d00018 100644 --- a/src/gpgme.c +++ b/src/gpgme.c @@ -86,6 +86,7 @@ gpgme_set_global_flag (const char *name, const char *value) gpgme_error_t gpgme_new (gpgme_ctx_t *r_ctx) { + gpgme_error_t err; gpgme_ctx_t ctx; TRACE_BEG (DEBUG_CTX, "gpgme_new", r_ctx); @@ -101,11 +102,13 @@ gpgme_new (gpgme_ctx_t *r_ctx) INIT_LOCK (ctx->lock); - _gpgme_engine_info_copy (&ctx->engine_info); - if (!ctx->engine_info) + err = _gpgme_engine_info_copy (&ctx->engine_info); + if (!err && !ctx->engine_info) + err = gpg_error (GPG_ERR_NO_ENGINE); + if (err) { free (ctx); - return TRACE_ERR (gpg_error_from_syserror ()); + return TRACE_ERR (err); } ctx->keylist_mode = GPGME_KEYLIST_MODE_LOCAL; commit d63058b852b83515e7715103c04a684ecf59838a Author: Werner Koch Date: Tue Jan 7 12:44:55 2014 +0100 Print the full PATH in the log if gpg was not found. * src/posix-util.c (walk_path): Keep a copy of PATH. diff --git a/src/posix-util.c b/src/posix-util.c index 5bfc486..1b92ec1 100644 --- a/src/posix-util.c +++ b/src/posix-util.c @@ -75,17 +75,18 @@ _gpgme_set_default_gpgconf_name (const char *name) static char * walk_path (const char *pgm) { - const char *path, *s; + const char *orig_path, *path, *s; char *fname, *p; - path = getenv ("PATH"); - if (!path) - path = "/bin:/usr/bin:."; + orig_path = getenv ("PATH"); + if (!orig_path) + orig_path = "/bin:/usr/bin:."; - fname = malloc (strlen (path) + 1 + strlen (pgm) + 1); + fname = malloc (strlen (orig_path) + 1 + strlen (pgm) + 1); if (!fname) return NULL; + path = orig_path; for (;;) { for (s=path, p=fname; *s && *s != ':'; s++, p++) @@ -101,7 +102,7 @@ walk_path (const char *pgm) } _gpgme_debug (DEBUG_ENGINE, "gpgme-walk_path: '%s' not found in '%s'", - pgm, path); + pgm, orig_path); free (fname); return NULL; ----------------------------------------------------------------------- Summary of changes: src/engine-backend.h | 12 ++++++++++++ src/engine.c | 40 ++++++++++++++++++++++++++++------------ src/gpgconf.c | 33 +-------------------------------- src/gpgme.c | 9 ++++++--- src/posix-util.c | 13 +++++++------ 5 files changed, 54 insertions(+), 53 deletions(-) hooks/post-receive -- GnuPG Made Easy http://git.gnupg.org From cvs at cvs.gnupg.org Tue Jan 7 18:10:28 2014 From: cvs at cvs.gnupg.org (by Werner Koch) Date: Tue, 07 Jan 2014 18:10:28 +0100 Subject: [git] GPGME - branch, master, updated. gpgme-1.4.2-19-g74c0075 Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "GnuPG Made Easy". The branch, master has been updated via 74c0075ca2f37758d1c6fb1c59bf3f6e42b42770 (commit) from ab6e718327451e418782990c5a0a4e72588e3f0b (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 74c0075ca2f37758d1c6fb1c59bf3f6e42b42770 Author: Werner Koch Date: Tue Jan 7 18:08:41 2014 +0100 Set next version to 1.5.0 -- diff --git a/configure.ac b/configure.ac index 9575db2..97bfa1f 100644 --- a/configure.ac +++ b/configure.ac @@ -28,8 +28,8 @@ min_automake_version="1.11" # commit and push so that the git magic is able to work. See below # for the LT versions. m4_define(mym4_version_major, [1]) -m4_define(mym4_version_minor, [4]) -m4_define(mym4_version_micro, [3]) +m4_define(mym4_version_minor, [5]) +m4_define(mym4_version_micro, [0]) # Below is m4 magic to extract and compute the revision number, the # decimalized short revision number, a beta version string, and a flag ----------------------------------------------------------------------- Summary of changes: configure.ac | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) hooks/post-receive -- GnuPG Made Easy http://git.gnupg.org From cvs at cvs.gnupg.org Wed Jan 8 16:49:05 2014 From: cvs at cvs.gnupg.org (by Werner Koch) Date: Wed, 08 Jan 2014 16:49:05 +0100 Subject: [git] KSBA - branch, master, updated. libksba-1.3.0-8-g629c1f0 Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "KSBA is a library to access X.509 certificates and CMS data.". The branch, master has been updated via 629c1f0b16b12418711516de3bef5298ab45fe12 (commit) via a7b75d6e8e8af79eab9ece7a4061ea48eab8a81d (commit) from d69cde444b2a4b106b4d8c6857efe7d5e8ce18fc (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 629c1f0b16b12418711516de3bef5298ab45fe12 Author: Werner Koch Date: Wed Jan 8 16:47:46 2014 +0100 Add --enable-silent-rules stuff. * configure.ac: Add AM_SILENT_RULES. diff --git a/configure.ac b/configure.ac index fe76192..2c5cd7e 100644 --- a/configure.ac +++ b/configure.ac @@ -110,6 +110,7 @@ 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) +AM_SILENT_RULES AC_PROG_AWK AC_PROG_CC AC_PROG_CPP commit a7b75d6e8e8af79eab9ece7a4061ea48eab8a81d Author: Werner Koch Date: Thu Apr 18 14:40:43 2013 +0200 Fix libtool 2.4.2 to correctly detect .def files. * ltmain.sh (sed_uncomment_deffile): New. (orig_export_symbols): Uncomment def file before testing for EXPORTS. * m4/libtool.m4: Do the same for the generated code. -- The old code was not correct in that it only looked at the first line and puts an EXPORTS keyword in front if missing. Binutils 2.22 accepted a duplicated EXPORTS keyword but at least 2.23.2 is more stringent and bails out without this fix. There is no need to send this upstream. Upstream's git master has a lot of changes including a similar fix for this problems. There are no signs that a libtool 2.4.3 will be released to fix this problem and thus we need to stick to our copy of 2.4.2 along with this patch. Signed-off-by: Werner Koch diff --git a/ltmain.sh b/ltmain.sh index c7d06c3..24e3fd3 100644 --- a/ltmain.sh +++ b/ltmain.sh @@ -411,6 +411,10 @@ sed_make_literal_regex='s,[].[^$\\*\/],\\&,g' # (escaped) backslashes. A very naive implementation. lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' +# Sed substitution to remove simple comments and empty +# lines from a Windows .def file. +sed_uncomment_deffile='/^;/d; /^[ ]*$/d' + # Re-`\' parameter expansions in output of double_quote_subst that were # `\'-ed in input to the same. If an odd number of `\' preceded a '$' # in input to double_quote_subst, that '$' was protected from expansion. @@ -8143,7 +8147,7 @@ EOF cygwin* | mingw* | cegcc*) if test -n "$export_symbols" && test -z "$export_symbols_regex"; then # exporting using user supplied symfile - if test "x`$SED 1q $export_symbols`" != xEXPORTS; then + if test "x`$SED "$sed_uncomment_deffile" $export_symbols | $SED 1q`" != xEXPORTS; then # and it's NOT already a .def file. Must figure out # which of the given symbols are data symbols and tag # them as such. So, trigger use of export_symbols_cmds. diff --git a/m4/libtool.m4 b/m4/libtool.m4 index 3e5f199..1d62b05 100644 --- a/m4/libtool.m4 +++ b/m4/libtool.m4 @@ -4799,7 +4799,7 @@ _LT_EOF _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' # If the export-symbols file already is a .def file (1st line # is EXPORTS), use it as is; otherwise, prepend... - _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then + _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED \"$sed_uncomment_deffile\" $export_symbols | $SED 1q`" = xEXPORTS; then cp $export_symbols $output_objdir/$soname.def; else echo EXPORTS > $output_objdir/$soname.def; @@ -5176,7 +5176,7 @@ _LT_EOF shrext_cmds=".dll" # FIXME: Setting linknames here is a bad hack. _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames=' - _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then + _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED \"$sed_uncomment_deffile\" $export_symbols | $SED 1q`" = xEXPORTS; then sed -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp; else sed -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp; @@ -6175,7 +6175,7 @@ if test "$_lt_caught_CXX_error" != yes; then shrext_cmds=".dll" # FIXME: Setting linknames here is a bad hack. _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames=' - _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then + _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED \"$sed_uncomment_deffile\" $export_symbols | $SED 1q`" = xEXPORTS; then $SED -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp; else $SED -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp; @@ -6216,7 +6216,7 @@ if test "$_lt_caught_CXX_error" != yes; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' # If the export-symbols file already is a .def file (1st line # is EXPORTS), use it as is; otherwise, prepend... - _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then + _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED \"$sed_uncomment_deffile\" $export_symbols | $SED 1q`" = xEXPORTS; then cp $export_symbols $output_objdir/$soname.def; else echo EXPORTS > $output_objdir/$soname.def; ----------------------------------------------------------------------- Summary of changes: configure.ac | 1 + ltmain.sh | 6 +++++- m4/libtool.m4 | 8 ++++---- 3 files changed, 10 insertions(+), 5 deletions(-) hooks/post-receive -- KSBA is a library to access X.509 certificates and CMS data. http://git.gnupg.org From cvs at cvs.gnupg.org Wed Jan 8 19:45:39 2014 From: cvs at cvs.gnupg.org (by Werner Koch) Date: Wed, 08 Jan 2014 19:45:39 +0100 Subject: [git] GCRYPT - branch, master, updated. libgcrypt-1.6.0-14-ge313b9d Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The GNU crypto library". The branch, master has been updated via e313b9d7b76f1d04be1e8c9d654166e9f73e0249 (commit) from 7fef7f481c0a1542be34d1dc831f58d41846ac29 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit e313b9d7b76f1d04be1e8c9d654166e9f73e0249 Author: Werner Koch Date: Wed Jan 8 19:45:13 2014 +0100 Typo fixes. -- diff --git a/NEWS b/NEWS index dbe30ee..878742e 100644 --- a/NEWS +++ b/NEWS @@ -36,7 +36,7 @@ Noteworthy changes in version 1.6.0 (2013-12-16) * Mitigated the Yarom/Falkner flush+reload side-channel attack on RSA secret keys. See [CVE-2013-4242]. - * Added support for Deterministic DSA as per RFC-6969. + * Added support for Deterministic DSA as per RFC-6979. * Added support for curve Ed25519. diff --git a/doc/gcrypt.texi b/doc/gcrypt.texi index dc42950..d5b6c8e 100644 --- a/doc/gcrypt.texi +++ b/doc/gcrypt.texi @@ -951,7 +951,7 @@ The default is @code{GCRY_RNG_TYPE_STANDARD} unless FIPS mode as been enabled; in which case @code{GCRY_RNG_TYPE_FIPS} is used and locked against further changes. - at item GCRYCTL_GETT_CURRENT_RNG_TYPE; Arguments: int * + at item GCRYCTL_GET_CURRENT_RNG_TYPE; Arguments: int * This command stores the type of the currently used RNG as an integer value at the provided address. ----------------------------------------------------------------------- Summary of changes: NEWS | 2 +- doc/gcrypt.texi | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) hooks/post-receive -- The GNU crypto library http://git.gnupg.org From cvs at cvs.gnupg.org Wed Jan 8 20:03:39 2014 From: cvs at cvs.gnupg.org (by Werner Koch) Date: Wed, 08 Jan 2014 20:03:39 +0100 Subject: [git] GCRYPT - branch, master, updated. libgcrypt-1.6.0-15-g4b7db51 Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The GNU crypto library". The branch, master has been updated via 4b7db51ad5d1bf98fd08ca3048f258059eca61a4 (commit) from e313b9d7b76f1d04be1e8c9d654166e9f73e0249 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 4b7db51ad5d1bf98fd08ca3048f258059eca61a4 Author: Werner Koch Date: Wed Jan 8 20:03:15 2014 +0100 Fix another minor typo. -- diff --git a/doc/gcrypt.texi b/doc/gcrypt.texi index d5b6c8e..dfff1b1 100644 --- a/doc/gcrypt.texi +++ b/doc/gcrypt.texi @@ -3321,7 +3321,7 @@ memory, two fast convenience function are available for this task: @code{gcry_md_hash_buffers} is a shortcut function to calculate a message digest from several buffers. This function does not require a -context and immediately returns the message digest of of the data +context and immediately returns the message digest of the data described by @var{iov} and @var{iovcnt}. @var{digest} must be allocated by the caller, large enough to hold the message digest yielded by the the specified algorithm @var{algo}. This required size ----------------------------------------------------------------------- Summary of changes: doc/gcrypt.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- The GNU crypto library http://git.gnupg.org From cvs at cvs.gnupg.org Thu Jan 9 15:37:51 2014 From: cvs at cvs.gnupg.org (by Werner Koch) Date: Thu, 09 Jan 2014 15:37:51 +0100 Subject: [git] GnuPG - branch, master, updated. gnupg-2.1.0beta3-276-g477aaba Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The GNU Privacy Guard". The branch, master has been updated via 477aabaf753f987987f7a2e1f999a499ea3bd103 (commit) via aba53e9f96d0c9b270edef0806976a56326249c4 (commit) via 161ea8c8229a0f59626bae05ce300313477500c3 (commit) via 75ba215ebd8be7e14b26bb53ef3c7d41e4ce1e02 (commit) from 101a54add351ff62793cbfbf3877787c4791f833 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 477aabaf753f987987f7a2e1f999a499ea3bd103 Author: Werner Koch Date: Thu Jan 9 15:36:35 2014 +0100 Fix test for zlib. * configure.ac (HAVE_ZLIB): Define only if found. diff --git a/configure.ac b/configure.ac index 96b023a..03a2c27 100644 --- a/configure.ac +++ b/configure.ac @@ -1362,12 +1362,13 @@ if test "$use_zip" = yes ; then ]) AC_CHECK_HEADER(zlib.h, - AC_CHECK_LIB(z, deflateInit2_, - ZLIBS="-lz", - CPPFLAGS=${_cppflags} LDFLAGS=${_ldflags}), - CPPFLAGS=${_cppflags} LDFLAGS=${_ldflags}) - - AC_DEFINE(HAVE_ZIP,1, [Defined if ZIP and ZLIB are supported]) + AC_CHECK_LIB(z, deflateInit2_, + [ + ZLIBS="-lz" + AC_DEFINE(HAVE_ZIP,1, [Defined if ZIP and ZLIB are supported]) + ], + CPPFLAGS=${_cppflags} LDFLAGS=${_ldflags}), + CPPFLAGS=${_cppflags} LDFLAGS=${_ldflags}) fi commit aba53e9f96d0c9b270edef0806976a56326249c4 Author: Werner Koch Date: Wed Jan 8 16:47:46 2014 +0100 Add --enable-silent-rules stuff. * configure.ac: Add AM_SILENT_RULES. diff --git a/configure.ac b/configure.ac index a206188..96b023a 100644 --- a/configure.ac +++ b/configure.ac @@ -544,6 +544,7 @@ 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) +AM_SILENT_RULES AC_PROG_AWK AC_PROG_CC AC_PROG_CPP commit 161ea8c8229a0f59626bae05ce300313477500c3 Author: Werner Koch Date: Wed Jan 8 17:03:21 2014 +0100 Add i686-w64-mingw32 as w32 toolchain to autogen.sh. -- diff --git a/autogen.sh b/autogen.sh index 935a456..05ed1f2 100755 --- a/autogen.sh +++ b/autogen.sh @@ -129,7 +129,7 @@ if [ "$myhost" = "w32" ]; then ;; *) [ -z "$w32root" ] && w32root="$HOME/w32root" - toolprefixes="$w32_toolprefixes i586-mingw32msvc" + toolprefixes="$w32_toolprefixes i686-w64-mingw32 i586-mingw32msvc" toolprefixes="$toolprefixes i386-mingw32msvc mingw32" extraoptions="--enable-gpgtar $w32_extraoptions" ;; commit 75ba215ebd8be7e14b26bb53ef3c7d41e4ce1e02 Author: Werner Koch Date: Wed Jan 8 11:47:07 2014 +0100 w32: Add macro for the registry key. * configure.ac (GNUPG_REGISTRY_DIR) [W32]: New ac-define. * common/homedir.c (default_homedir): Use it. * common/logging.c (do_logv): Use it. diff --git a/common/homedir.c b/common/homedir.c index 682df9a..77622a1 100644 --- a/common/homedir.c +++ b/common/homedir.c @@ -222,7 +222,7 @@ default_homedir (void) char *tmp; tmp = read_w32_registry_string (NULL, - "Software\\GNU\\" GNUPG_NAME, + GNUPG_REGISTRY_DIR, "HomeDir"); if (tmp && !*tmp) { diff --git a/common/logging.c b/common/logging.c index e94cdaf..2b5bb2d 100644 --- a/common/logging.c +++ b/common/logging.c @@ -636,7 +636,7 @@ do_logv (int level, int ignore_arg_ptr, const char *fmt, va_list arg_ptr) tmp = (no_registry ? NULL - : read_w32_registry_string (NULL, "Software\\GNU\\"GNUPG_NAME, + : read_w32_registry_string (NULL, GNUPG_REGISTRY_DIR, "DefaultLogFile")); log_set_file (tmp && *tmp? tmp : NULL); jnlib_free (tmp); diff --git a/configure.ac b/configure.ac index fa841c4..a206188 100644 --- a/configure.ac +++ b/configure.ac @@ -1600,6 +1600,11 @@ AC_DEFINE_UNQUOTED(DIRMNGR_SOCK_NAME, "S.dirmngr", AC_DEFINE_UNQUOTED(GPGEXT_GPG, "gpg", [The standard binary file suffix]) +if test "$have_w32_system" = yes; then + AC_DEFINE_UNQUOTED(GNUPG_REGISTRY_DIR, "\\Software\\GNU\\GnuPG", + [The directory part of the W32 registry keys]) +fi + # # Provide information about the build. ----------------------------------------------------------------------- Summary of changes: autogen.sh | 2 +- common/homedir.c | 2 +- common/logging.c | 2 +- configure.ac | 19 +++++++++++++------ 4 files changed, 16 insertions(+), 9 deletions(-) hooks/post-receive -- The GNU Privacy Guard http://git.gnupg.org From cvs at cvs.gnupg.org Thu Jan 9 20:12:46 2014 From: cvs at cvs.gnupg.org (by Werner Koch) Date: Thu, 09 Jan 2014 20:12:46 +0100 Subject: [git] GnuPG - branch, master, updated. gnupg-2.1.0beta3-280-ga55ffb9 Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The GNU Privacy Guard". The branch, master has been updated via a55ffb9da9a844bd2bd73a4a2ea65bf18b21c57f (commit) via 5be845448074b94c9a346c6b53e022403fe5f59e (commit) via 00d5d2204cefb0f4b953e0c00448f16aab2d39c7 (commit) via fa318406c9bdb60aee1e1b410e4c9e0b3eb1392e (commit) from 477aabaf753f987987f7a2e1f999a499ea3bd103 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit a55ffb9da9a844bd2bd73a4a2ea65bf18b21c57f Author: Werner Koch Date: Thu Jan 9 19:14:09 2014 +0100 Improve the speedo make script. * scripts/gpg-w32-dev/README: Remove * scripts/gpg-w32-dev/GNUmakefile, scripts/gpg-w32-dev/speedo.mk: Merge into .. * scripts/speedo.mk: this. -- Speedo may now be used to build from GIT or tarballs and has a couple of other improvements as well. For best results the autogen.sh files of all source package should be updated to the one used in gnupg. Signed-off-by: Werner Koch diff --git a/Makefile.am b/Makefile.am index c9a7b50..08b5d32 100644 --- a/Makefile.am +++ b/Makefile.am @@ -26,7 +26,8 @@ GITLOG_TO_CHANGELOG=gitlog-to-changelog EXTRA_DIST = scripts/config.rpath scripts/potomo autogen.sh README.GIT \ ChangeLog-2011 po/ChangeLog-2011 scripts/ChangeLog-2011 \ scripts/gitlog-to-changelog \ - scripts/git-log-fix scripts/git-log-footer + scripts/git-log-fix scripts/git-log-footer \ + scripts/speedo.mk DISTCLEANFILES = g10defs.h if BUILD_GPGSM diff --git a/scripts/gpg-w32-dev/GNUmakefile b/scripts/gpg-w32-dev/GNUmakefile deleted file mode 100644 index 10ba92f..0000000 --- a/scripts/gpg-w32-dev/GNUmakefile +++ /dev/null @@ -1,142 +0,0 @@ -# Makefile - Makefile for speedo -# Copyright (C) 2008 g10 Code GmbH -# -# This file is part of speedo. -# -# speedo 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. -# -# speedo 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 . - -# speedo builds gnupg-related packages from SVN and installs them in a -# user directory, thereby providing a non-obstrusive test environment. -# The build system is similar to that of gpg4win. The following commands -# are supported: -# -# make all or make -# -# Builds all packages and installs them under playground/install. -# At the end, speedo prints commands that can be executed in the local shell -# to make use of the installed packages. -# -# make clean or make clean-PACKAGE -# -# Removes all packages or the package PACKAGE from the installation -# and build tree. A subsequent make will rebuild these (and only -# these) packages. -# -# make report or make report-PACKAGE -# -# Lists packages and versions. -# -# make dist -# -# Create a development ZIP archive. - - -# -------- - -# The packages that should be built. The order is also the build order. -speedo_spkgs = libgpg-error libgcrypt libassuan libksba gpgme - -# For each package, the following variables can be defined: -# -# speedo_pkg_PACKAGE_svn: The SVN repository that should be built. -# Branches or specific revisions can also be specified. -# -# speedo_pkg_PACKAGE_tar: URL to the tar file that should be built. -# -# Exactly one of the above variables is required. Note that this -# version of speedo does not cache repositories or tar files, and does -# not test the integrity of the downloaded software. If you care -# about this, you can also specify filenames to locally verified files. -# Filenames are differentiated from URLs by starting with a slash '/'. -# -# speedo_pkg_PACKAGE_configure: Extra arguments to configure. -# -# speedo_pkg_PACKAGE_make_args: Extra arguments to make. -# -# speedo_pkg_PACKAGE_make_args_inst: Extra arguments to make install. -# -# Note that you can override the defaults in this file in a local file -# "config.mk" - -# Set this to "svn" or "release". -WHAT=release - -ifeq ($(WHAT),svn) - svnrep = svn://cvs.gnupg.org/ - speedo_pkg_libgpg_error_svn = $(svnrep)/libgpg-error/trunk - speedo_pkg_libassuan_svn = $(svnrep)/libassuan/trunk - speedo_pkg_libgcrypt_svn = $(svnrep)/libgcrypt/trunk - speedo_pkg_libksba_svn = $(svnrep)/libksba/trunk - speedo_pkg_gpgme_svn = $(svnrep)/gpgme/trunk -else - pkgrep = ftp://ftp.gnupg.org/gcrypt - speedo_pkg_libgpg_error_tar = $(pkgrep)/libgpg-error/libgpg-error-1.8.tar.bz2 - speedo_pkg_libassuan_tar = $(pkgrep)/libassuan/libassuan-2.0.0.tar.bz2 - speedo_pkg_libgcrypt_tar = $(pkgrep)/libgcrypt/libgcrypt-1.4.6.tar.bz2 - speedo_pkg_libksba_tar = $(pkgrep)/libksba/libksba-1.0.7.tar.bz2 - speedo_pkg_gpgme_tar = $(pkgrep)/gpgme/gpgme-1.3.0.tar.bz2 -endif - -speedo_pkg_gnupg_configure = --with-pinentry-pgm=$(idir)/bin/pinentry \ - --with-dirmngr-pgm=$(idir)/bin/dirmngr - -speedo_pkg_dirmngr_configure = --localstatedir=/var --sysconfdir=/etc \ - --with-libgcrypt-prefix=$(idir) --with-gpg-error-prefix=$(idir) \ - --with-libassuan-prefix=$(idir) --with-libksba-prefix=$(idir) - -speedo_pkg_gpgme_configure = --with-gpg=$(idir)/bin/gpg2 \ - --with-gpgsm=$(idir)/bin/gpgsm \ - --with-gpgconf=$(idir)/bin/gpgconf - -speedo_pkg_pinentry_configure = --disable-pinentry-qt4 - -speedo_pkg_libgcrypt_configure = --disable-static - -speedo_pkg_libksba_configure = --disable-static - - -# --------- - -all: all-speedo - @echo export PATH=\"$(idir)/bin\":\$$PATH - @echo export LD_LIBRARY_PATH=\"$(idir)/lib\":\$$LD_LIBRARY_PATH - @echo hash -r - -report: report-speedo - -clean: clean-speedo - - -dist: all - set -e; date=$$(date -u +%Y%m%d); pkgname=gpg-w32-dev-$$date; \ - rm -rf $$pkgname $${pkgname}.zip || true; \ - cp -rL playground/install $${pkgname}; \ - rm -r $${pkgname}/share/info || true; \ - mkdir -p $${pkgname}/share/doc/gpg-w32-dev ;\ - echo "Included versions:" > $${pkgname}/README.txt ; \ - echo "" >> $${pkgname}/README.txt ; \ - $(MAKE) --no-print-directory report \ - | awk '{print $$2}' >> $${pkgname}/README.txt ; \ - cp GNUmakefile speedo.mk $${pkgname}/README.txt \ - $${pkgname}/share/doc/gpg-w32-dev/ ; \ - i586-mingw32msvc-strip $${pkgname}/bin/*.dll ; \ - zip -r9 $${pkgname}.zip $${pkgname} >/dev/null ; \ - rm -rf $$pkgname; \ - echo "$$pkgname.zip ready for distribution" >&2 - - -speedo_build_list = $(speedo_spkgs) - --include config.mk -include speedo.mk diff --git a/scripts/gpg-w32-dev/README b/scripts/gpg-w32-dev/README deleted file mode 100644 index ac2ffeb..0000000 --- a/scripts/gpg-w32-dev/README +++ /dev/null @@ -1,6 +0,0 @@ -These makefiles are used to build a simple development package of -GnuPG related libraries for Windoze. The ZIP archive includes only -the binaries, import libraries and header files. On a file server you -should keep the original source tarballs close to the archive file and -explain where to find the sources. GNU make is required. - diff --git a/scripts/gpg-w32-dev/speedo.mk b/scripts/gpg-w32-dev/speedo.mk deleted file mode 100644 index 4e0e63a..0000000 --- a/scripts/gpg-w32-dev/speedo.mk +++ /dev/null @@ -1,168 +0,0 @@ -# speedo.mk - Speedo rebuilds speedily. -# Copyright (C) 2008 g10 Code GmbH -# -# This file is part of speedo. -# -# speedo 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. -# -# speedo 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 . - -MKDIR=mkdir -STOW=stow - -# These paths must be absolute, as we switch directories pretty often. -root := $(shell pwd)/playground -bdir := $(root)/build -idir := $(root)/install -ipdir := $(root)/install/pkgs - -# The playground area is our scratch area, where we unpack, build and -# install the packages. -stamps/stamp-directories: - $(MKDIR) stamps - $(MKDIR) playground - $(MKDIR) $(bdir) - $(MKDIR) $(idir) - #$(MKDIR) $(ipdir) - touch stamps/stamp-directories - -# Frob the name $1 by converting all '-' and '+' characters to '_'. -define FROB_macro -$(subst +,_,$(subst -,_,$(1))) -endef - -# Get the variable $(1) (which may contain '-' and '+' characters). -define GETVAR -$($(call FROB_macro,$(1))) -endef - -# Set a couple of common variables. -define SETVARS - pkg="$(1)"; \ - svn="$(call GETVAR,speedo_pkg_$(1)_svn)"; \ - tar="$(call GETVAR,speedo_pkg_$(1)_tar)"; \ - pkgsdir="$(bdir)/$(1)"; \ - pkgbdir="$(bdir)/$(1)-build"; \ - pkgidir="$(ipdir)/$(1)"; \ - pkgcfg="$(call GETVAR,speedo_pkg_$(1)_configure)"; \ - pkgmkargs="$(call GETVAR,speedo_pkg_$(1)_make_args)"; \ - pkgmkargs_inst="$(call GETVAR,speedo_pkg_$(1)_make_args_inst)"; \ - export PATH="$(idir)/bin:$${PATH}"; \ - export LD_LIBRARY_PATH="$(idir)/lib:$${LD_LIBRARY_PATH}" -endef - - -# Template for source packages. - -define SPKG_template - -stamps/stamp-$(1)-00-unpack: stamps/stamp-directories - (cd $(bdir); \ - $(call SETVARS,$(1)); \ - if [ -n "$$$${svn}" ]; then \ - svn checkout "$$$${svn}" "$$$${pkg}"; \ - cd "$$$${pkg}"; \ - ./autogen.sh; \ - elif [ -n "$$$${tar}" ]; then \ - case "$$$${tar}" in \ - (*.gz) opt=z ;; \ - (*.bz2) opt=j ;; \ - (*) opt= ;; \ - esac; \ - case "$$$${tar}" in \ - (/*) cmd=cat ;; \ - (*) cmd="wget -q -O -" ;; \ - esac; \ - $$$${cmd} "$$$${tar}" | tar x$$$${opt}f - ; \ - base=`echo "$$$${tar}" | sed -e 's,^.*/,,' \ - | sed -e 's,\.tar.*$$$$,,'`; \ - mv $$$${base} $(1); \ - fi) - touch stamps/stamp-$(1)-00-unpack - -stamps/stamp-$(1)-01-configure: stamps/stamp-$(1)-00-unpack - ($(call SETVARS,$(1)); \ - mkdir "$$$${pkgbdir}"; \ - cd "$$$${pkgbdir}"; \ - eval "../$$$${pkg}/configure" \ - --enable-maintainer-mode \ - --prefix="$(idir)" \ - --host=i586-mingw32msvc \ - $$$${pkgcfg}) - touch stamps/stamp-$(1)-01-configure - -stamps/stamp-$(1)-02-make: stamps/stamp-$(1)-01-configure - ($(call SETVARS,$(1)); \ - cd "$$$${pkgbdir}"; \ - $(MAKE) $$$${pkgmkargs}) - touch stamps/stamp-$(1)-02-make - -# Note that post_install must come last because it may be empty and -# "; ;" is a syntax error. -stamps/stamp-$(1)-03-install: stamps/stamp-$(1)-02-make - ($(call SETVARS,$(1)); \ - cd "$$$${pkgbdir}"; \ - $(MAKE) $$$${pkgmkargs_inst} install-strip ; \ - $(call gpg4win_pkg_$(call FROB_macro,$(1))_post_install)) - touch stamps/stamp-$(1)-03-install - -stamps/stamp-final-$(1): stamps/stamp-$(1)-03-install - touch stamps/stamp-final-$(1) - -.PHONY : clean-$(1) -clean-$(1): - ($(call SETVARS,$(1)); \ - (cd $(ipdir) && \ - ($(STOW) -D "$$$${pkg}"; \ - rm -fR "$$$${pkg}")); \ - rm -fR "$$$${pkgsdir}" "$$$${pkgbdir}") - rm -f stamps/stamp-final-$(1) stamps/stamp-$(1)-* - -.PHONY : report-$(1) -report-$(1): - @($(call SETVARS,$(1)); \ - echo -n $(1):\ ; \ - if [ -n "$$$${svn}" ]; then \ - if [ -e .svn ]; then \ - cd $(bdir)/$(1) && \ - svn info | grep Repository ; \ - else \ - echo missing; \ - fi \ - elif [ -n "$$$${tar}" ]; then \ - base=`echo "$$$${tar}" | sed -e 's,^.*/,,' \ - | sed -e 's,\.tar.*$$$$,,'`; \ - echo $$$${base} ; \ - fi) - -endef - - -# Insert the template for each source package. -$(foreach spkg, $(speedo_spkgs), $(eval $(call SPKG_template,$(spkg)))) - -stamps/stamp-final: stamps/stamp-directories -stamps/stamp-final: $(addprefix stamps/stamp-final-,$(speedo_build_list)) - touch stamps/stamp-final - -all-speedo: stamps/stamp-final - -report-speedo: $(addprefix report-,$(speedo_build_list)) - -# Just to check if we catched all stamps. -clean-stamps: - $(RM) -fR $(stamps) - -clean-speedo: - $(RM) -fR playground stamps - -.PHONY : all-speedo report-speedo clean-stamps clean-speedo diff --git a/scripts/speedo.mk b/scripts/speedo.mk new file mode 100644 index 0000000..4148002 --- /dev/null +++ b/scripts/speedo.mk @@ -0,0 +1,364 @@ +# speedo.mk - Speedo rebuilds speedily. +# Copyright (C) 2008, 2014 g10 Code GmbH +# +# speedo 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. +# +# speedo 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 . + +# speedo builds gnupg-related packages from GIT and installs them in a +# user directory, thereby providing a non-obstrusive test environment. +# speedo does only work with GNU make. The build system is similar to +# that of gpg4win. The following commands are supported: +# +# make -f speedo.mk all +# or +# make -f speedo.mk +# +# Builds all packages and installs them under play/inst. At the end, +# speedo prints commands that can be executed in the local shell to +# make use of the installed packages. +# +# make -f speedo.mk clean +# or +# make -f speedo.mk clean-PACKAGE +# +# Removes all packages or the package PACKAGE from the installation +# and build tree. A subsequent make will rebuild these (and only +# these) packages. +# +# make -f speedo.mk report +# or +# make -f speedo.mk report-PACKAGE +# +# Lists packages and versions. +# + + + +# -------- + +# The packages that should be built. The order is also the build order. +speedo_spkgs = libgpg-error npth libgcrypt libassuan libksba gnupg gpgme gpa + +# version numbers of the released packages +# Fixme: Take the version numbers from gnupg-doc/web/swdb.mac +libgpg_error_ver = 1.12 +npth_ver = 0.91 +libgcrypt_ver = 1.6.0 +libassuan_ver = 2.1.1 +libksba_ver = 1.3.0 +gnupg_ver = 2.0.22 +gpgme_ver = 1.5.0 +gpa_ver = 0.9.5 + +# The GIT repository. Using a local repo is much faster. +#gitrep = git://git.gnupg.org +gitrep = ${HOME}/s + + +# For each package, the following variables can be defined: +# +# speedo_pkg_PACKAGE_git: The GIT repository that should be built. +# speedo_pkg_PACKAGE_gitref: The GIT revision to checkout +# +# speedo_pkg_PACKAGE_tar: URL to the tar file that should be built. +# +# Exactly one of the above variables is required. Note that this +# version of speedo does not cache repositories or tar files, and does +# not test the integrity of the downloaded software. If you care +# about this, you can also specify filenames to locally verified files. +# Filenames are differentiated from URLs by starting with a slash '/'. +# +# speedo_pkg_PACKAGE_configure: Extra arguments to configure. +# +# speedo_pkg_PACKAGE_make_args: Extra arguments to make. +# +# speedo_pkg_PACKAGE_make_args_inst: Extra arguments to make install. +# +# Note that you can override the defaults in this file in a local file +# "config.mk" + +# Set this to "git" or "release". +WHAT=release + +# Set target to "native" or "w32" +TARGETOS=native + +# Number of parallel make jobs +MAKE_J=3 + +ifeq ($(WHAT),git) + speedo_pkg_libgpg_error_git = $(gitrep)/libgpg-error + speedo_pkg_libgpg_error_gitref = master + speedo_pkg_npth_git = $(gitrep)/npth + speedo_pkg_npth_gitref = master + speedo_pkg_libassuan_git = $(gitrep)/libassuan + speedo_pkg_libassuan_gitref = master + speedo_pkg_libgcrypt_git = $(gitrep)/libgcrypt + speedo_pkg_libgcrypt_gitref = master + speedo_pkg_libksba_git = $(gitrep)/libksba + speedo_pkg_libksba_gitref = master + speedo_pkg_gnupg_git = $(gitrep)/gnupg + speedo_pkg_gnupg_gitref = master + speedo_pkg_gpgme_git = $(gitrep)/gpgme + speedo_pkg_gpgme_gitref = master + speedo_pkg_gpa_git = $(gitrep)/gpa + speedo_pkg_gpa_gitref = master +else + pkgrep = ftp://ftp.gnupg.org/gcrypt + speedo_pkg_libgpg_error_tar = \ + $(pkgrep)/libgpg-error/libgpg-error-$(libgpg_error_ver).tar.bz2 + speedo_pkg_npth_tar = \ + $(pkgrep)/npth/npth-$(npth_ver).tar.bz2 + speedo_pkg_libassuan_tar = \ + $(pkgrep)/libassuan/libassuan-$(libassuan_ver).tar.bz2 + speedo_pkg_libgcrypt_tar = \ + $(pkgrep)/libgcrypt/libgcrypt-$(libgcrypt_ver).tar.bz2 + speedo_pkg_libksba_tar = \ + $(pkgrep)/libksba/libksba-$(libksba_ver).tar.bz2 + speedo_pkg_gnupg_tar = \ + $(pkgrep)/gnupg/gnupg-$(gnupg_ver).tar.bz2 + speedo_pkg_gpgme_tar = \ + $(pkgrep)/gpgme/gpgme-$(gpgme_ver).tar.bz2 + speedo_pkg_gpa_tar = \ + $(pkgrep)/gpa/gpa-$(gpa_ver).tar.bz2 +endif + +speedo_pkg_pinentry_configure = --disable-pinentry-qt4 + +speedo_pkg_libgcrypt_configure = --disable-static + +speedo_pkg_libksba_configure = --disable-static + + +# --------- + +all: all-speedo + @echo export PATH=\"$(idir)/bin\":\$$PATH + @echo export LD_LIBRARY_PATH=\"$(idir)/lib\":\$$LD_LIBRARY_PATH + @echo hash -r + +report: report-speedo + +clean: clean-speedo + + +# Fixme: The dist target does not work anymore. +STRIP = i686-w64-mingw32-strip + +dist: all + set -e; date=$$(date -u +%Y%m%d); pkgname=gpg-w32-dev-$$date; \ + rm -rf $$pkgname $${pkgname}.zip || true; \ + cp -rL playground/install $${pkgname}; \ + rm -r $${pkgname}/share/info || true; \ + mkdir -p $${pkgname}/share/doc/gpg-w32-dev ;\ + echo "Included versions:" > $${pkgname}/README.txt ; \ + echo "" >> $${pkgname}/README.txt ; \ + $(MAKE) --no-print-directory report \ + | awk '{print $$2}' >> $${pkgname}/README.txt ; \ + cp GNUmakefile speedo.mk $${pkgname}/README.txt \ + $${pkgname}/share/doc/gpg-w32-dev/ ; \ + $(STRIP) $${pkgname}/bin/*.dll ; \ + zip -r9 $${pkgname}.zip $${pkgname} >/dev/null ; \ + rm -rf $$pkgname; \ + echo "$$pkgname.zip ready for distribution" >&2 + + +-include config.mk + +# +# The generic speedo code +# + +MKDIR=mkdir + + +# These paths must be absolute, as we switch directories pretty often. +root := $(shell pwd)/play +stampdir := $(root)/stamps +sdir := $(root)/src +bdir := $(root)/build +idir := $(root)/inst + +speedo_build_list = $(speedo_spkgs) + +ifeq ($(TARGETOS),w32) + speedo_autogen_buildopt="--build-w32" +else + speedo_autogen_buildopt= +endif + +ifeq ($(MAKE_J),) + speedo_makeopt= +else + speedo_makeopt=-j$(MAKE_J) +endif + + +# The playground area is our scratch area, where we unpack, build and +# install the packages. +$(stampdir)/stamp-directories: + $(MKDIR) $(root) + $(MKDIR) $(stampdir) + $(MKDIR) $(sdir) + $(MKDIR) $(bdir) + $(MKDIR) $(idir) + touch $(stampdir)/stamp-directories + +# Frob the name $1 by converting all '-' and '+' characters to '_'. +define FROB_macro +$(subst +,_,$(subst -,_,$(1))) +endef + +# Get the variable $(1) (which may contain '-' and '+' characters). +define GETVAR +$($(call FROB_macro,$(1))) +endef + +# Set a couple of common variables. +define SETVARS + pkg="$(1)"; \ + git="$(call GETVAR,speedo_pkg_$(1)_git)"; \ + gitref="$(call GETVAR,speedo_pkg_$(1)_gitref)"; \ + tar="$(call GETVAR,speedo_pkg_$(1)_tar)"; \ + pkgsdir="$(sdir)/$(1)"; \ + pkgbdir="$(bdir)/$(1)"; \ + pkgcfg="$(call GETVAR,speedo_pkg_$(1)_configure)"; \ + pkgmkargs="$(call GETVAR,speedo_pkg_$(1)_make_args)"; \ + pkgmkargs_inst="$(call GETVAR,speedo_pkg_$(1)_make_args_inst)"; \ + export PATH="$(idir)/bin:$${PATH}"; \ + export LD_LIBRARY_PATH="$(idir)/lib:$${LD_LIBRARY_PATH}" +endef + + +# Template for source packages. + +define SPKG_template + +$(stampdir)/stamp-$(1)-00-unpack: $(stampdir)/stamp-directories + @echo "speedo: /*" + @echo "speedo: * $(1)" + @echo "speedo: */" + @(cd $(sdir); \ + $(call SETVARS,$(1)); \ + if [ -n "$$$${git}" ]; then \ + echo "speedo: unpacking $(1) from $$$${git}:$$$${gitref}"; \ + git clone -q -b "$$$${gitref}" "$$$${git}" "$$$${pkg}"; \ + cd "$$$${pkg}" && \ + AUTOGEN_SH_SILENT=1 ./autogen.sh; \ + elif [ -n "$$$${tar}" ]; then \ + echo "speedo: unpacking $(1) from $$$${tar}"; \ + case "$$$${tar}" in \ + *.gz) opt=z ;; \ + *.bz2) opt=j ;; \ + *) opt= ;; \ + esac; \ + case "$$$${tar}" in \ + /*) cmd=cat ;; \ + *) cmd="wget -q -O -" ;; \ + esac; \ + $$$${cmd} "$$$${tar}" | tar x$$$${opt}f - ; \ + base=`echo "$$$${tar}" | sed -e 's,^.*/,,' \ + | sed -e 's,\.tar.*$$$$,,'`; \ + mv $$$${base} $(1); \ + else \ + echo "speedo: unpacking $(1) from UNKNOWN"; \ + fi) + @touch $(stampdir)/stamp-$(1)-00-unpack + +$(stampdir)/stamp-$(1)-01-configure: $(stampdir)/stamp-$(1)-00-unpack + @echo "speedo: configuring $(1)" + @($(call SETVARS,$(1)); \ + mkdir "$$$${pkgbdir}"; \ + cd "$$$${pkgbdir}"; \ + if [ -n "$(speedo_autogen_buildopt)" ]; then \ + eval AUTOGEN_SH_SILENT=1 w32root="$(idir)" \ + "$$$${pkgsdir}/autogen.sh" \ + $(speedo_autogen_buildopt) --silent \ + $$$${pkgcfg}; \ + else \ + eval "$$$${pkgsdir}/configure" \ + --silent \ + --enable-maintainer-mode \ + --prefix="$(idir)" \ + $$$${pkgcfg}; \ + fi) + @touch $(stampdir)/stamp-$(1)-01-configure + +$(stampdir)/stamp-$(1)-02-make: $(stampdir)/stamp-$(1)-01-configure + @echo "speedo: making $(1)" + @($(call SETVARS,$(1)); \ + cd "$$$${pkgbdir}"; \ + $(MAKE) --no-print-directory $(speedo_makeopt) $$$${pkgmkargs} V=0) + @touch $(stampdir)/stamp-$(1)-02-make + +# Note that post_install must come last because it may be empty and +# "; ;" is a syntax error. +$(stampdir)/stamp-$(1)-03-install: $(stampdir)/stamp-$(1)-02-make + @echo "speedo: installing $(1)" + @($(call SETVARS,$(1)); \ + cd "$$$${pkgbdir}"; \ + $(MAKE) --no-print-directory $$$${pkgmkargs_inst} install-strip V=0;\ + $(call gpg4win_pkg_$(call FROB_macro,$(1))_post_install)) + @touch $(stampdir)/stamp-$(1)-03-install + +$(stampdir)/stamp-final-$(1): $(stampdir)/stamp-$(1)-03-install + @touch $(stampdir)/stamp-final-$(1) + +.PHONY : clean-$(1) +clean-$(1): + @echo "speedo: uninstalling $(1)" + @($(call SETVARS,$(1)); \ + (cd "$$$${pkgbdir}"; \ + $(MAKE) --no-print-directory $$$${pkgmkargs_inst} uninstall V=0); \ + rm -fR "$$$${pkgsdir}" "$$$${pkgbdir}") + @rm -f $(stampdir)/stamp-final-$(1) $(stampdir)/stamp-$(1)-* + +.PHONY : report-$(1) +report-$(1): + @($(call SETVARS,$(1)); \ + echo -n $(1):\ ; \ + if [ -n "$$$${git}" ]; then \ + if [ -e "$$$${pkgsdir}/.git" ]; then \ + cd "$$$${pkgsdir}" && \ + git describe ; \ + else \ + echo missing; \ + fi \ + elif [ -n "$$$${tar}" ]; then \ + base=`echo "$$$${tar}" | sed -e 's,^.*/,,' \ + | sed -e 's,\.tar.*$$$$,,'`; \ + echo $$$${base} ; \ + fi) + +endef + + +# Insert the template for each source package. +$(foreach spkg, $(speedo_spkgs), $(eval $(call SPKG_template,$(spkg)))) + +$(stampdir)/stamp-final: $(stampdir)/stamp-directories +$(stampdir)/stamp-final: $(addprefix $(stampdir)/stamp-final-,$(speedo_build_list)) + touch $(stampdir)/stamp-final + +all-speedo: $(stampdir)/stamp-final + +report-speedo: $(addprefix report-,$(speedo_build_list)) + +# Just to check if we catched all stamps. +clean-stamps: + $(RM) -fR $(stampdir) + +clean-speedo: + $(RM) -fR play + +.PHONY : all-speedo report-speedo clean-stamps clean-speedo commit 5be845448074b94c9a346c6b53e022403fe5f59e Author: Werner Koch Date: Thu Jan 9 19:14:09 2014 +0100 autogen.sh: Add envvar AUTOGEN_SH_SILENT -- diff --git a/autogen.sh b/autogen.sh index 05ed1f2..712e070 100755 --- a/autogen.sh +++ b/autogen.sh @@ -28,6 +28,13 @@ check_version () { return 1 } +info () { + if [ -z "${SILENT}" ]; then + echo "autogen.sh:" $* + fi +} + + # Allow to override the default tool names AUTOCONF=${AUTOCONF_PREFIX}${AUTOCONF:-autoconf}${AUTOCONF_SUFFIX} AUTOHEADER=${AUTOCONF_PREFIX}${AUTOHEADER:-autoheader}${AUTOCONF_SUFFIX} @@ -40,13 +47,22 @@ MSGMERGE=${GETTEXT_PREFIX}${MSGMERGE:-msgmerge}${GETTEXT_SUFFIX} DIE=no FORCE= +SILENT= tmp=`dirname $0` tsdir=`cd "$tmp"; pwd` +if [ -n "${AUTOGEN_SH_SILENT}" ]; then + SILENT=" --silent" +fi +if test x"$1" = x"--help"; then + echo "usage: ./autogen.sh [--force] [--build-TYPE] [ARGS]" + exit 0 +fi if test x"$1" = x"--force"; then FORCE=" --force" shift fi + # Reject unsafe characters in $HOME, $tsdir and cwd. We consider spaces # as unsafe because it is too easy to get scripts wrong in this regard. am_lf=' @@ -81,7 +97,7 @@ amd64_toolprefixes= #amd64root= if [ -f "$HOME/.gnupg-autogen.rc" ]; then - echo "sourcing extra definitions from $HOME/.gnupg-autogen.rc" + info "sourcing extra definitions from $HOME/.gnupg-autogen.rc" . "$HOME/.gnupg-autogen.rc" fi @@ -134,7 +150,7 @@ if [ "$myhost" = "w32" ]; then extraoptions="--enable-gpgtar $w32_extraoptions" ;; esac - echo "Using $w32root as standard install directory" >&2 + info "Using $w32root as standard install directory" # Locate the cross compiler crossbindir= @@ -162,7 +178,8 @@ if [ "$myhost" = "w32" ]; then fi fi - $tsdir/configure --enable-maintainer-mode --prefix=${w32root} \ + $tsdir/configure --enable-maintainer-mode ${SILENT} \ + --prefix=${w32root} \ --host=${host} --build=${build} \ --with-gpg-error-prefix=${w32root} \ --with-ksba-prefix=${w32root} \ @@ -189,7 +206,7 @@ if [ "$myhost" = "amd64" ]; then build=`$tsdir/scripts/config.guess` [ -z "$amd64root" ] && amd64root="$HOME/amd64root" - echo "Using $amd64root as standard install directory" >&2 + info "Using $amd64root as standard install directory" toolprefixes="$amd64_toolprefixes x86_64-linux-gnu amd64-linux-gnu" @@ -215,7 +232,8 @@ if [ "$myhost" = "amd64" ]; then fi fi - $tsdir/configure --enable-maintainer-mode --prefix=${amd64root} \ + $tsdir/configure --enable-maintainer-mode ${SILENT} \ + --prefix=${amd64root} \ --host=${host} --build=${build} \ --with-gpg-error-prefix=${amd64root} \ --with-ksba-prefix=${amd64root} \ @@ -278,42 +296,44 @@ fi # Check the git setup. if [ -d .git ]; then + CP="cp -a" + [ -z "${SILENT}" ] && CP="$CP -v" if [ -f .git/hooks/pre-commit.sample -a ! -f .git/hooks/pre-commit ] ; then - cat <&2 + [ -z "${SILENT}" ] && cat <&2 + info "*** Adding GIT filter.cleanpo.clean configuration." git config --add filter.cleanpo.clean \ "awk '/^\"POT-Creation-Date:/&&!s{s=1;next};!/^#: /{print}'" fi if [ -f scripts/git-hooks/commit-msg -a ! -f .git/hooks/commit-msg ] ; then - cat <&2 + [ -z "${SILENT}" ] && cat < Date: Thu Jan 9 19:05:07 2014 +0100 gpgsplit: Allow building without zlib support. * tools/gpgsplit.c [!HAVE_ZLIB]: Do not include zlib.h. (handle_zlib): Build only if HAVE_ZLIB is defined. (write_part): Support zlib and zip only if HAVE_ZLIB is defined. Signed-off-by: Werner Koch diff --git a/tools/gpgsplit.c b/tools/gpgsplit.c index 928e283..78e87aa 100644 --- a/tools/gpgsplit.c +++ b/tools/gpgsplit.c @@ -29,9 +29,11 @@ #ifdef HAVE_DOSISH_SYSTEM # include /* for setmode() */ #endif -#include +#ifdef HAVE_ZIP +# include +#endif #ifdef HAVE_BZIP2 -#include +# include #endif /* HAVE_BZIP2 */ #if defined(__riscos__) && defined(USE_ZLIBRISCOS) # include "zlib-riscos.h" @@ -360,6 +362,7 @@ public_key_length (const unsigned char *buf, size_t buflen) return s - buf; } +#ifdef HAVE_ZIP static int handle_zlib(int algo,FILE *fpin,FILE *fpout) { @@ -452,6 +455,7 @@ handle_zlib(int algo,FILE *fpin,FILE *fpout) return 0; } +#endif /*HAVE_ZIP*/ #ifdef HAVE_BZIP2 static int @@ -698,11 +702,15 @@ write_part (FILE *fpin, unsigned long pktlen, if ((c = getc (fpin)) == EOF) goto read_error; - if(c==1 || c==2) + if (0) + ; +#ifdef HAVE_ZIP + else if(c==1 || c==2) { if(handle_zlib(c,fpin,fpout)) goto write_error; } +#endif /* HAVE_ZIP */ #ifdef HAVE_BZIP2 else if(c==3) { commit fa318406c9bdb60aee1e1b410e4c9e0b3eb1392e Author: Werner Koch Date: Thu Jan 9 17:51:46 2014 +0100 w32: Fix backslash quoting in registry name. * configure.ac (GNUPG_REGISTRY_DIR): Double backslashes. diff --git a/configure.ac b/configure.ac index 03a2c27..8bca728 100644 --- a/configure.ac +++ b/configure.ac @@ -1603,7 +1603,7 @@ AC_DEFINE_UNQUOTED(DIRMNGR_SOCK_NAME, "S.dirmngr", AC_DEFINE_UNQUOTED(GPGEXT_GPG, "gpg", [The standard binary file suffix]) if test "$have_w32_system" = yes; then - AC_DEFINE_UNQUOTED(GNUPG_REGISTRY_DIR, "\\Software\\GNU\\GnuPG", + AC_DEFINE_UNQUOTED(GNUPG_REGISTRY_DIR, "\\\\Software\\\\GNU\\\\GnuPG", [The directory part of the W32 registry keys]) fi ----------------------------------------------------------------------- Summary of changes: Makefile.am | 3 +- autogen.sh | 50 ++++-- configure.ac | 2 +- scripts/gpg-w32-dev/GNUmakefile | 142 --------------- scripts/gpg-w32-dev/README | 6 - scripts/gpg-w32-dev/speedo.mk | 168 ------------------ scripts/speedo.mk | 364 +++++++++++++++++++++++++++++++++++++++ tools/gpgsplit.c | 14 +- 8 files changed, 413 insertions(+), 336 deletions(-) delete mode 100644 scripts/gpg-w32-dev/GNUmakefile delete mode 100644 scripts/gpg-w32-dev/README delete mode 100644 scripts/gpg-w32-dev/speedo.mk create mode 100644 scripts/speedo.mk hooks/post-receive -- The GNU Privacy Guard http://git.gnupg.org From cvs at cvs.gnupg.org Fri Jan 10 14:04:12 2014 From: cvs at cvs.gnupg.org (by Werner Koch) Date: Fri, 10 Jan 2014 14:04:12 +0100 Subject: [git] GnuPG - branch, master, updated. gnupg-2.1.0beta3-282-ge7973d3 Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The GNU Privacy Guard". The branch, master has been updated via e7973d36d88178b4b0a977e3fcc0d62600777618 (commit) via 99a48b2fcdf7c33fe553511c12f2ebb8eea5c634 (commit) from a55ffb9da9a844bd2bd73a4a2ea65bf18b21c57f (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit e7973d36d88178b4b0a977e3fcc0d62600777618 Author: Werner Koch Date: Thu Jan 9 19:14:09 2014 +0100 Turn autogen.sh into a generic script. * autogen.sh: Revamp. * autogen.rc: New. * Makefile.am (EXTRA_DIST): Add autogen.rc. -- Signed-off-by: Werner Koch diff --git a/Makefile.am b/Makefile.am index 7cf6d38..cf84134 100644 --- a/Makefile.am +++ b/Makefile.am @@ -23,7 +23,7 @@ DISTCHECK_CONFIGURE_FLAGS = --enable-symcryptrun --enable-mailto --enable-gpgtar GITLOG_TO_CHANGELOG=gitlog-to-changelog -EXTRA_DIST = build-aux/config.rpath build-aux/potomo autogen.sh +EXTRA_DIST = build-aux/config.rpath build-aux/potomo autogen.sh autogen.rc ChangeLog-2011 po/ChangeLog-2011 build-aux/ChangeLog-2011 \ build-aux/gitlog-to-changelog \ build-aux/git-log-fix build-aux/git-log-footer \ diff --git a/autogen.rc b/autogen.rc new file mode 100644 index 0000000..0f3d9d8 --- /dev/null +++ b/autogen.rc @@ -0,0 +1,43 @@ +# autogen.sh configuration for GnuPG -*- sh -*- + +case "$myhost:$myhostsub" in + w32:ce) + extraoptions="--enable-dirmngr-auto-start --disable-scdaemon " + extraoptions="$extraoptions --disable-zip --enable-gpg2-is-gpg" + ;; + w32:) + extraoptions="--enable-gpgtar" + ;; +esac + +case "$myhost" in + w32) + configure_opts=" + --with-gpg-error-prefix=@SYSROOT@ + --with-ksba-prefix=@SYSROOT@ + --with-libgcrypt-prefix=@SYSROOT@ + --with-libassuan-prefix=@SYSROOT@ + --with-zlib=@SYSROOT@ + --with-regex=@SYSROOT@ + --with-npth-prefix=@SYSROOT@ + --with-adns=@SYSROOT@ + --disable-g13 + " + ;; + + amd64) + configure_opts=" + --with-gpg-error-prefix=@SYSROOT@ + --with-ksba-prefix=@SYSROOT@ + --with-libgcrypt-prefix=@SYSROOT@ + --with-libassuan-prefix=@SYSROOT@ + --with-zlib=/usr/x86_64-linux-gnu/usr + --with-pth-prefix=/usr/x86_64-linux-gnu/usr + " + ;; +esac + + +extra_aclocal_flags="-I gl/m4" + +final_info="./configure --sysconfdir=/etc --enable-maintainer-mode --enable-symcryptrun --enable-mailto --enable-gpgtar && make" diff --git a/autogen.sh b/autogen.sh index 712e070..ea3d5fc 100755 --- a/autogen.sh +++ b/autogen.sh @@ -1,7 +1,6 @@ #! /bin/sh -# Run this to generate all the initial makefiles, etc. -# -# Copyright (C) 2003 g10 Code GmbH +# autogen.sh +# Copyright (C) 2003, 2014 g10 Code GmbH # # This file is free software; as a special exception the author gives # unlimited permission to copy and/or distribute it, with or without @@ -10,6 +9,13 @@ # This program 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. +# +# This is a generic script to create the configure script and handle cross +# build environments. It requires the presence of a autogen.rc file to +# configure it for the respective package. It is maintained as part of +# GnuPG and source copied by other packages. +# +# Version: 2014-01-10 configure_ac="configure.ac" @@ -28,12 +34,28 @@ check_version () { return 1 } +fatal () { + echo "autogen.sh:" "$*" >&2 + DIE=yes +} + info () { if [ -z "${SILENT}" ]; then - echo "autogen.sh:" $* + echo "autogen.sh:" "$*" fi } +die_p () { + if [ "$DIE" = "yes" ]; then + echo "autogen.sh: Stop." >&2 + exit 1 + fi +} + +replace_sysroot () { + configure_opts=$(echo $configure_opts | sed "s#@SYSROOT@#${w32root}#g") + extraoptions=$(echo $extraoptions | sed "s#@SYSROOT@#${w32root}#g") +} # Allow to override the default tool names AUTOCONF=${AUTOCONF_PREFIX}${AUTOCONF:-autoconf}${AUTOCONF_SUFFIX} @@ -48,15 +70,20 @@ MSGMERGE=${GETTEXT_PREFIX}${MSGMERGE:-msgmerge}${GETTEXT_SUFFIX} DIE=no FORCE= SILENT= -tmp=`dirname $0` -tsdir=`cd "$tmp"; pwd` +tmp=$(dirname "$0") +tsdir=$(cd "${tmp}"; pwd) + if [ -n "${AUTOGEN_SH_SILENT}" ]; then SILENT=" --silent" fi if test x"$1" = x"--help"; then - echo "usage: ./autogen.sh [--force] [--build-TYPE] [ARGS]" + echo "usage: ./autogen.sh [--silent] [--force] [--build-TYPE] [ARGS]" exit 0 fi +if test x"$1" = x"--silent"; then + SILENT=" --silent" + shift +fi if test x"$1" = x"--force"; then FORCE=" --force" shift @@ -69,88 +96,108 @@ am_lf=' ' case `pwd` in *[\;\\\"\#\$\&\'\`$am_lf\ \ ]*) - echo "unsafe working directory name"; DIE=yes;; + fatal "unsafe working directory name" ;; esac case $tsdir in *[\;\\\"\#\$\&\'\`$am_lf\ \ ]*) - echo "unsafe source directory: \`$tsdir'"; DIE=yes;; + fatal "unsafe source directory: \`$tsdir'" ;; esac case $HOME in *[\;\\\"\#\$\&\'\`$am_lf\ \ ]*) - echo "unsafe home directory: \`$HOME'"; DIE=yes;; + fatal "unsafe home directory: \`$HOME'" ;; esac -if test "$DIE" = "yes"; then - exit 1 -fi +die_p + -# Begin list of optional variables sourced from ~/.gnupg-autogen.rc +# List of variables sourced from autogen.rc. The strings '@SYSROOT@' in +# these variables are replaced by the actual system root. +configure_opts= +extraoptions= +# List of optional variables sourced from autogen.rc and ~/.gnupg-autogen.rc w32_toolprefixes= w32_extraoptions= w32ce_toolprefixes= w32ce_extraoptions= +w64_toolprefixes= +w64_extraoptions= amd64_toolprefixes= # End list of optional variables sourced from ~/.gnupg-autogen.rc # What follows are variables which are sourced but default to # environment variables or lacking them hardcoded values. #w32root= #w32ce_root= +#w64root= #amd64root= -if [ -f "$HOME/.gnupg-autogen.rc" ]; then - info "sourcing extra definitions from $HOME/.gnupg-autogen.rc" - . "$HOME/.gnupg-autogen.rc" -fi - # Convenience option to use certain configure options for some hosts. myhost="" myhostsub="" case "$1" in --build-w32) myhost="w32" + shift ;; --build-w32ce) myhost="w32" myhostsub="ce" + shift + ;; + --build-w64) + myhost="w32" + myhostsub="64" + shift ;; --build-amd64) myhost="amd64" + shift ;; --build*) - echo "**Error**: invalid build option $1" >&2 - exit 1 + fatal "**Error**: invalid build option $1" + shift ;; *) ;; esac +die_p + +# Source our configuration +if [ -f "${tsdir}/autogen.rc" ]; then + . "${tsdir}/autogen.rc" +fi + +# Source optional site specific configuration +if [ -f "$HOME/.gnupg-autogen.rc" ]; then + info "sourcing extra definitions from $HOME/.gnupg-autogen.rc" + . "$HOME/.gnupg-autogen.rc" +fi -# ***** W32 build script ******* -# Used to cross-compile for Windows. +# ****************** +# W32 build script +# ****************** if [ "$myhost" = "w32" ]; then - shift - if [ ! -f $tsdir/scripts/config.guess ]; then - echo "$tsdir/scripts/config.guess not found" >&2 + if [ ! -f "$tsdir/build-aux/config.guess" ]; then + fatal "$tsdir/build-aux/config.guess not found" exit 1 fi - build=`$tsdir/scripts/config.guess` + build=`$tsdir/build-aux/config.guess` case $myhostsub in ce) w32root="$w32ce_root" [ -z "$w32root" ] && w32root="$HOME/w32ce_root" toolprefixes="$w32ce_toolprefixes arm-mingw32ce" - extraoptions="--enable-dirmngr-auto-start --disable-scdaemon " - extraoptions="$extraoptions --disable-zip --enable-gpg2-is-gpg" extraoptions="$extraoptions $w32ce_extraoptions" ;; *) [ -z "$w32root" ] && w32root="$HOME/w32root" toolprefixes="$w32_toolprefixes i686-w64-mingw32 i586-mingw32msvc" toolprefixes="$toolprefixes i386-mingw32msvc mingw32" - extraoptions="--enable-gpgtar $w32_extraoptions" + extraoptions="$extraoptions $w32_extraoptions" ;; esac info "Using $w32root as standard install directory" + replace_sysroot # Locate the cross compiler crossbindir= @@ -162,34 +209,25 @@ if [ "$myhost" = "w32" ]; then fi done if [ -z "$crossbindir" ]; then - echo "Cross compiler kit not installed" >&2 - if [ -z "$sub" ]; then - echo "Under Debian GNU/Linux, you may install it using" >&2 - echo " apt-get install mingw32 mingw32-runtime mingw32-binutils" >&2 + fatal "cross compiler kit not installed" + if [ -z "$myhostsub" ]; then + info "Under Debian GNU/Linux, you may install it using" + info " apt-get install mingw32 mingw32-runtime mingw32-binutils" fi - echo "Stop." >&2 - exit 1 + die_p fi if [ -f "$tsdir/config.log" ]; then if ! head $tsdir/config.log | grep "$host" >/dev/null; then - echo "Please run a 'make distclean' first" >&2 - exit 1 + fatal "Please run a 'make distclean' first" + die_p fi fi $tsdir/configure --enable-maintainer-mode ${SILENT} \ --prefix=${w32root} \ --host=${host} --build=${build} \ - --with-gpg-error-prefix=${w32root} \ - --with-ksba-prefix=${w32root} \ - --with-libgcrypt-prefix=${w32root} \ - --with-libassuan-prefix=${w32root} \ - --with-zlib=${w32root} \ - --with-regex=${w32root} \ - --with-npth-prefix=${w32root} \ - --with-adns=${w32root} \ - ${extraoptions} --disable-g13 "$@" + ${configure_opts} ${extraoptions} "$@" rc=$? exit $rc fi @@ -199,14 +237,15 @@ fi # Used to cross-compile for AMD64 (for testing) if [ "$myhost" = "amd64" ]; then shift - if [ ! -f $tsdir/scripts/config.guess ]; then - echo "$tsdir/scripts/config.guess not found" >&2 + if [ ! -f $tsdir/build-aux/config.guess ]; then + echo "$tsdir/build-aux/config.guess not found" >&2 exit 1 fi - build=`$tsdir/scripts/config.guess` + build=`$tsdir/build-aux/config.guess` [ -z "$amd64root" ] && amd64root="$HOME/amd64root" info "Using $amd64root as standard install directory" + replace_sysroot toolprefixes="$amd64_toolprefixes x86_64-linux-gnu amd64-linux-gnu" @@ -235,12 +274,7 @@ if [ "$myhost" = "amd64" ]; then $tsdir/configure --enable-maintainer-mode ${SILENT} \ --prefix=${amd64root} \ --host=${host} --build=${build} \ - --with-gpg-error-prefix=${amd64root} \ - --with-ksba-prefix=${amd64root} \ - --with-libgcrypt-prefix=${amd64root} \ - --with-libassuan-prefix=${amd64root} \ - --with-zlib=/usr/x86_64-linux-gnu/usr \ - --with-pth-prefix=/usr/x86_64-linux-gnu/usr + ${configure_opts} ${extraoptions} "$@" rc=$? exit $rc fi @@ -260,12 +294,15 @@ q }' ${configure_ac}` automake_vers_num=`echo "$automake_vers" | cvtver` -gettext_vers=`sed -n '/^AM_GNU_GETTEXT_VERSION(/ { +if [ -d "${tsdir}/po" ]; then + gettext_vers=`sed -n '/^AM_GNU_GETTEXT_VERSION(/ { s/^.*\[\(.*\)])/\1/p q }' ${configure_ac}` -gettext_vers_num=`echo "$gettext_vers" | cvtver` - + gettext_vers_num=`echo "$gettext_vers" | cvtver` +else + gettext_vers="n/a" +fi if [ -z "$autoconf_vers" -o -z "$automake_vers" -o -z "$gettext_vers" ] then @@ -280,18 +317,20 @@ fi if check_version $AUTOMAKE $automake_vers_num $automake_vers; then check_version $ACLOCAL $automake_vers_num $autoconf_vers automake fi -if check_version $GETTEXT $gettext_vers_num $gettext_vers; then - check_version $MSGMERGE $gettext_vers_num $gettext_vers gettext +if [ "$gettext_vers" != "n/a" ]; then + if check_version $GETTEXT $gettext_vers_num $gettext_vers; then + check_version $MSGMERGE $gettext_vers_num $gettext_vers gettext + fi fi -if test "$DIE" = "yes"; then +if [ "$DIE" = "yes" ]; then cat < Date: Thu Jan 9 19:14:09 2014 +0100 Rename scripts/ to build-aux/ * scripts/: Rename to build-aux/ * Makefile.am: Adjust accordingly. * configure.ac (AC_CONFIG_AUX_DIR): Change to build-aux. diff --git a/Makefile.am b/Makefile.am index 08b5d32..7cf6d38 100644 --- a/Makefile.am +++ b/Makefile.am @@ -23,11 +23,12 @@ DISTCHECK_CONFIGURE_FLAGS = --enable-symcryptrun --enable-mailto --enable-gpgtar GITLOG_TO_CHANGELOG=gitlog-to-changelog -EXTRA_DIST = scripts/config.rpath scripts/potomo autogen.sh README.GIT \ - ChangeLog-2011 po/ChangeLog-2011 scripts/ChangeLog-2011 \ - scripts/gitlog-to-changelog \ - scripts/git-log-fix scripts/git-log-footer \ - scripts/speedo.mk +EXTRA_DIST = build-aux/config.rpath build-aux/potomo autogen.sh + ChangeLog-2011 po/ChangeLog-2011 build-aux/ChangeLog-2011 \ + build-aux/gitlog-to-changelog \ + build-aux/git-log-fix build-aux/git-log-footer \ + build-aux/speedo.mk README.GIT + DISTCLEANFILES = g10defs.h if BUILD_GPGSM @@ -101,12 +102,12 @@ dist-hook: gen-ChangeLog if HAVE_W32_SYSTEM install-data-hook: set -e; \ - for i in $$($(top_srcdir)/scripts/potomo \ + for i in $$($(top_srcdir)/build-aux/potomo \ --get-linguas $(top_srcdir)/po) ; do \ $(MKDIR_P) "$(DESTDIR)$(localedir)/$$i/LC_MESSAGES" || true; \ rm -f "$(DESTDIR)$(localedir)/$$i/LC_MESSAGES/gnupg2.mo" \ 2>/dev/null || true; \ - $(top_srcdir)/scripts/potomo $(top_srcdir)/po/$$i.po \ + $(top_srcdir)/build-aux/potomo $(top_srcdir)/po/$$i.po \ "$(DESTDIR)$(localedir)/$$i/LC_MESSAGES/gnupg2.mo" ; \ done endif @@ -118,9 +119,9 @@ gen-ChangeLog: if test -d $(top_srcdir)/.git; then \ (cd $(top_srcdir) && \ $(GITLOG_TO_CHANGELOG) --append-dot --tear-off \ - --amend=scripts/git-log-fix \ + --amend=build-aux/git-log-fix \ --since=$(gen_start_date) ) > $(distdir)/cl-t; \ - cat $(top_srcdir)/scripts/git-log-footer >> $(distdir)/cl-t; \ + cat $(top_srcdir)/build-aux/git-log-footer >> $(distdir)/cl-t; \ rm -f $(distdir)/ChangeLog; \ mv $(distdir)/cl-t $(distdir)/ChangeLog; \ fi diff --git a/scripts/ChangeLog-2011 b/build-aux/ChangeLog-2011 similarity index 100% rename from scripts/ChangeLog-2011 rename to build-aux/ChangeLog-2011 diff --git a/scripts/build-all.sh b/build-aux/build-all.sh similarity index 100% rename from scripts/build-all.sh rename to build-aux/build-all.sh diff --git a/scripts/compile b/build-aux/compile similarity index 100% rename from scripts/compile rename to build-aux/compile diff --git a/scripts/config.guess b/build-aux/config.guess similarity index 100% rename from scripts/config.guess rename to build-aux/config.guess diff --git a/scripts/config.rpath b/build-aux/config.rpath similarity index 100% rename from scripts/config.rpath rename to build-aux/config.rpath diff --git a/scripts/config.sub b/build-aux/config.sub similarity index 100% rename from scripts/config.sub rename to build-aux/config.sub diff --git a/scripts/depcomp b/build-aux/depcomp similarity index 100% rename from scripts/depcomp rename to build-aux/depcomp diff --git a/scripts/git-hooks/commit-msg b/build-aux/git-hooks/commit-msg similarity index 100% rename from scripts/git-hooks/commit-msg rename to build-aux/git-hooks/commit-msg diff --git a/scripts/git-log-fix b/build-aux/git-log-fix similarity index 100% rename from scripts/git-log-fix rename to build-aux/git-log-fix diff --git a/scripts/git-log-footer b/build-aux/git-log-footer similarity index 100% rename from scripts/git-log-footer rename to build-aux/git-log-footer diff --git a/scripts/gitlog-to-changelog b/build-aux/gitlog-to-changelog similarity index 100% rename from scripts/gitlog-to-changelog rename to build-aux/gitlog-to-changelog diff --git a/scripts/install-sh b/build-aux/install-sh similarity index 100% rename from scripts/install-sh rename to build-aux/install-sh diff --git a/scripts/mail-to-translators b/build-aux/mail-to-translators similarity index 95% rename from scripts/mail-to-translators rename to build-aux/mail-to-translators index c01e89e..6937b59 100755 --- a/scripts/mail-to-translators +++ b/build-aux/mail-to-translators @@ -13,12 +13,12 @@ for file in *.po; do if [ -z "$addr" ]; then addr=$(awk '/Last-Translator:/ { printf "%s", $0; exit 0}' $file | sed 's/.*\(<.*>\).*/\1/') fi - ll=$(basename $file .po) + ll=$(basename $file .po) if ! msgfmt -vc $file 2>&1| egrep -q 'fuzzy|untranslated|error'; then echo "$file: okay" >&2 continue; - fi + fi if ! echo "$addr" | grep -q @ ; then echo "$file: no translator known" >&2 @@ -40,7 +40,7 @@ Content-Type: multipart/mixed; boundary="=-=-=" Hi! We are preparing for a new 2.0 release of GnuPG and like you to ask to -update your translation. +update your translation. Please find attached the very latest version of the PO file for your GnuPG translation ($file). @@ -76,7 +76,7 @@ Content-Transfer-Encoding: base64 EOF -bzip2 <$file | mimencode +bzip2 <$file | mimencode echo "" echo "--=-=-=--" @@ -84,4 +84,3 @@ echo "" ) | $SENDMAIL -oi "$addr" done - diff --git a/scripts/mdate-sh b/build-aux/mdate-sh similarity index 100% rename from scripts/mdate-sh rename to build-aux/mdate-sh diff --git a/scripts/missing b/build-aux/missing similarity index 100% rename from scripts/missing rename to build-aux/missing diff --git a/scripts/mkinstalldirs b/build-aux/mkinstalldirs similarity index 100% rename from scripts/mkinstalldirs rename to build-aux/mkinstalldirs diff --git a/scripts/potomo b/build-aux/potomo similarity index 100% rename from scripts/potomo rename to build-aux/potomo diff --git a/scripts/speedo.mk b/build-aux/speedo.mk similarity index 100% rename from scripts/speedo.mk rename to build-aux/speedo.mk diff --git a/scripts/texinfo.tex b/build-aux/texinfo.tex similarity index 99% rename from scripts/texinfo.tex rename to build-aux/texinfo.tex index 5063065..a181898 100644 --- a/scripts/texinfo.tex +++ b/build-aux/texinfo.tex @@ -20,7 +20,7 @@ % General Public License for more details. % % You should have received a copy of the GNU General Public License -% along with this texinfo.tex file; see the file COPYING. If not, +% along with this texinfo.tex file; see the file COPYING. If not, % see . % % As a special exception, when this file is read by TeX when processing @@ -309,7 +309,7 @@ % We don't want .vr (or whatever) entries like this: % \entry{{\tt \indexbackslash }acronym}{32}{\code {\acronym}} % "\acronym" won't work when it's read back in; - % it needs to be + % it needs to be % {\code {{\tt \backslashcurfont }acronym} \shipout\vbox{% % Do this early so pdf references go to the beginning of the page. @@ -660,7 +660,7 @@ \def\?{?\spacefactor=\endofsentencespacefactor\space} % @frenchspacing on|off says whether to put extra space after punctuation. -% +% \def\onword{on} \def\offword{off} % @@ -1215,7 +1215,7 @@ where each line of input produces a line of output.} % that's what we do). % double active backslashes. -% +% {\catcode`\@=0 \catcode`\\=\active @gdef at activebackslashdouble{% @catcode`@\=@active @@ -1227,11 +1227,11 @@ where each line of input produces a line of output.} % us) handles it with this amazing macro to replace tokens, with minor % changes for Texinfo. It is included here under the GPL by permission % from the author, Heiko Oberdiek. -% +% % #1 is the tokens to replace. % #2 is the replacement. % #3 is the control sequence with the string. -% +% \def\HyPsdSubst#1#2#3{% \def\HyPsdReplace##1#1##2\END{% ##1% @@ -1459,7 +1459,7 @@ output) for that.)} % tried to figure out what each command should do in the context % of @url. for now, just make @/ a no-op, that's the only one % people have actually reported a problem with. - % + % \normalturnoffactive \def\@{@}% \let\/=\empty @@ -1851,7 +1851,7 @@ end % Definitions for a main text size of 11pt. This is the default in % Texinfo. -% +% \def\definetextfontsizexi{% % Text fonts (11.2pt, magstep1). \def\textnominalsize{11pt} @@ -1976,7 +1976,7 @@ end % section, chapter, etc., sizes following suit. This is for the GNU % Press printing of the Emacs 22 manual. Maybe other manuals in the % future. Used with @smallbook, which sets the leading to 12pt. -% +% \def\definetextfontsizex{% % Text fonts (10pt). \def\textnominalsize{10pt} @@ -2062,7 +2062,7 @@ end \setfont\secsf\sfbshape{12}{1000}{OT1} \let\secbf\secrm \setfont\secsc\scbshape{10}{\magstep1}{OT1} -\font\seci=cmmi12 +\font\seci=cmmi12 \font\secsy=cmsy10 scaled \magstep1 % Subsection fonts (10pt). @@ -2103,7 +2103,7 @@ end % We provide the user-level command % @fonttextsize 10 % (or 11) to redefine the text font size. pt is assumed. -% +% \def\xword{10} \def\xiword{11} % @@ -2113,7 +2113,7 @@ end % % Set \globaldefs so that documents can use this inside @tex, since % makeinfo 4.8 does not support it, but we need it nonetheless. - % + % \begingroup \globaldefs=1 \ifx\textsizearg\xword \definetextfontsizex \else \ifx\textsizearg\xiword \definetextfontsizexi @@ -2399,7 +2399,7 @@ end % each of the four underscores in __typeof__. This is undesirable in % some manuals, especially if they don't have long identifiers in % general. @allowcodebreaks provides a way to control this. -% +% \newif\ifallowcodebreaks \allowcodebreakstrue \def\keywordtrue{true} @@ -2530,7 +2530,7 @@ end % @acronym for "FBI", "NATO", and the like. % We print this one point size smaller, since it's intended for % all-uppercase. -% +% \def\acronym#1{\doacronym #1,,\finish} \def\doacronym#1,#2,#3\finish{% {\selectfonts\lsize #1}% @@ -2542,7 +2542,7 @@ end % @abbr for "Comput. J." and the like. % No font change, but don't do end-of-sentence spacing. -% +% \def\abbr#1{\doabbr #1,,\finish} \def\doabbr#1,#2,#3\finish{% {\plainfrenchspacing #1}% @@ -2561,43 +2561,43 @@ end % Theiling, which support regular, slanted, bold and bold slanted (and % "outlined" (blackboard board, sort of) versions, which we don't need). % It is available from http://www.ctan.org/tex-archive/fonts/eurosym. -% +% % Although only regular is the truly official Euro symbol, we ignore % that. The Euro is designed to be slightly taller than the regular % font height. -% +% % feymr - regular % feymo - slanted % feybr - bold % feybo - bold slanted -% +% % There is no good (free) typewriter version, to my knowledge. % A feymr10 euro is ~7.3pt wide, while a normal cmtt10 char is ~5.25pt wide. % Hmm. -% +% % Also doesn't work in math. Do we need to do math with euro symbols? % Hope not. -% -% +% +% \def\euro{{\eurofont e}} \def\eurofont{% % We set the font at each command, rather than predefining it in % \textfonts and the other font-switching commands, so that % installations which never need the symbol don't have to have the % font installed. - % + % % There is only one designed size (nominal 10pt), so we always scale % that to the current nominal size. - % + % % By the way, simply using "at 1em" works for cmr10 and the like, but % does not work for cmbx10 and other extended/shrunken fonts. - % + % \def\eurosize{\csname\curfontsize nominalsize\endcsname}% % - \ifx\curfontstyle\bfstylename + \ifx\curfontstyle\bfstylename % bold: \font\thiseurofont = \ifusingit{feybo10}{feybr10} at \eurosize - \else + \else % regular: \font\thiseurofont = \ifusingit{feymo10}{feymr10} at \eurosize \fi @@ -2621,7 +2621,7 @@ end % Laurent Siebenmann reports \Orb undefined with: % Textures 1.7.7 (preloaded format=plain 93.10.14) (68K) 16 APR 2004 02:38 % so we'll define it if necessary. -% +% \ifx\Orb\undefined \def\Orb{\mathhexbox20D} \fi @@ -2937,7 +2937,7 @@ end % cause the example and the item to crash together. So we use this % bizarre value of 10001 as a signal to \aboveenvbreak to insert % \parskip glue after all. Section titles are handled this way also. - % + % \penalty 10001 \endgroup \itemxneedsnegativevskipfalse @@ -3733,7 +3733,7 @@ end % processing continues to some further point. On the other hand, it % seems \endinput does not hurt in the printed index arg, since that % is still getting written without apparent harm. - % + % % Sample source (mac-idx3.tex, reported by Graham Percival to % help-texinfo, 22may06): % @macro funindex {WORD} @@ -3741,12 +3741,12 @@ end % @end macro % ... % @funindex commtest - % + % % The above is not enough to reproduce the bug, but it gives the flavor. - % + % % Sample whatsit resulting: % . at write3{\entry{xyz}{@folio }{@code {xyz at endinput }}} - % + % % So: \let\endinput = \empty % @@ -3982,11 +3982,11 @@ end % makeinfo does not expand macros in the argument to @deffn, which ends up % writing an index entry, and texindex isn't prepared for an index sort entry % that starts with \. - % + % % Since macro invocations are followed by braces, we can just redefine them % to take a single TeX argument. The case of a macro invocation that % goes to end-of-line is not handled. - % + % \macrolist } @@ -4114,7 +4114,7 @@ end % to re-insert the same penalty (values >10000 are used for various % signals); since we just inserted a non-discardable item, any % following glue (such as a \parskip) would be a breakpoint. For example: - % + % % @deffn deffn-whatever % @vindex index-whatever % Description. @@ -5096,11 +5096,11 @@ end % glue accumulate. (Not a breakpoint because it's preceded by a % discardable item.) \vskip-\parskip - % + % % This is purely so the last item on the list is a known \penalty > % 10000. This is so \startdefun can avoid allowing breakpoints after % section headings. Otherwise, it would insert a valid breakpoint between: - % + % % @section sec-whatever % @deffn def-whatever \penalty 10001 @@ -5158,7 +5158,7 @@ end % These characters do not print properly in the Computer Modern roman % fonts, so we must take special care. This is more or less redundant % with the Texinfo input format setup at the end of this file. -% +% \def\activecatcodes{% \catcode`\"=\active \catcode`\$=\active @@ -5759,8 +5759,8 @@ end % from cmtt (char 0x0d). The undirected quote is ugly, so don't make it % the default, but it works for pasting with more pdf viewers (at least % evince), the lilypond developers report. xpdf does work with the -% regular 0x27. -% +% regular 0x27. +% \def\codequoteright{% \expandafter\ifx\csname SETcodequoteundirected\endcsname\relax '% @@ -5772,7 +5772,7 @@ end % and a similar option for the left quote char vs. a grave accent. % Modern fonts display ASCII 0x60 as a grave accent, so some people like % the code environments to do likewise. -% +% \def\codequoteleft{% \expandafter\ifx\csname SETcodequotebacktick\endcsname\relax `% @@ -6301,7 +6301,7 @@ end % This does \let #1 = #2, with \csnames; that is, % \let \csname#1\endcsname = \csname#2\endcsname % (except of course we have to play expansion games). -% +% \def\cslet#1#2{% \expandafter\let \csname#1\expandafter\endcsname @@ -7483,7 +7483,7 @@ should work if nowhere else does.} \setnonasciicharscatcode\active \lattwochardefs % - \else \ifx \declaredencoding \latone + \else \ifx \declaredencoding \latone \setnonasciicharscatcode\active \latonechardefs % @@ -7495,7 +7495,7 @@ should work if nowhere else does.} \setnonasciicharscatcode\active \utfeightchardefs % - \else + \else \message{Unknown document encoding #1, ignoring.}% % \fi % utfeight @@ -7507,7 +7507,7 @@ should work if nowhere else does.} % A message to be logged when using a character that isn't available % the default font encoding (OT1). -% +% \def\missingcharmsg#1{\message{Character missing in OT1 encoding: #1.}} % Take account of \c (plain) vs. \, (Texinfo) difference. @@ -7520,21 +7520,21 @@ should work if nowhere else does.} % % Latin1 (ISO-8859-1) character definitions. \def\latonechardefs{% - \gdef^^a0{~} + \gdef^^a0{~} \gdef^^a1{\exclamdown} - \gdef^^a2{\missingcharmsg{CENT SIGN}} + \gdef^^a2{\missingcharmsg{CENT SIGN}} \gdef^^a3{{\pounds}} \gdef^^a4{\missingcharmsg{CURRENCY SIGN}} \gdef^^a5{\missingcharmsg{YEN SIGN}} - \gdef^^a6{\missingcharmsg{BROKEN BAR}} + \gdef^^a6{\missingcharmsg{BROKEN BAR}} \gdef^^a7{\S} - \gdef^^a8{\"{}} - \gdef^^a9{\copyright} + \gdef^^a8{\"{}} + \gdef^^a9{\copyright} \gdef^^aa{\ordf} - \gdef^^ab{\missingcharmsg{LEFT-POINTING DOUBLE ANGLE QUOTATION MARK}} + \gdef^^ab{\missingcharmsg{LEFT-POINTING DOUBLE ANGLE QUOTATION MARK}} \gdef^^ac{$\lnot$} - \gdef^^ad{\-} - \gdef^^ae{\registeredsymbol} + \gdef^^ad{\-} + \gdef^^ae{\registeredsymbol} \gdef^^af{\={}} % \gdef^^b0{\textdegree} @@ -7561,7 +7561,7 @@ should work if nowhere else does.} \gdef^^c2{\^A} \gdef^^c3{\~A} \gdef^^c4{\"A} - \gdef^^c5{\ringaccent A} + \gdef^^c5{\ringaccent A} \gdef^^c6{\AE} \gdef^^c7{\cedilla C} \gdef^^c8{\`E} @@ -7702,7 +7702,7 @@ should work if nowhere else does.} \gdef^^d6{\"O} \gdef^^d7{$\times$} \gdef^^d8{\v R} - \gdef^^d9{\ringaccent U} + \gdef^^d9{\ringaccent U} \gdef^^da{\'U} \gdef^^db{\H U} \gdef^^dc{\"U} @@ -7746,11 +7746,11 @@ should work if nowhere else does.} } % UTF-8 character definitions. -% +% % This code to support UTF-8 is based on LaTeX's utf8.def, with some % changes for Texinfo conventions. It is included here under the GPL by % permission from Frank Mittelbach and the LaTeX team. -% +% \newcount\countUTFx \newcount\countUTFy \newcount\countUTFz @@ -8576,7 +8576,7 @@ should work if nowhere else does.} % Same as @turnoffactive except outputs \ as {\tt\char`\\} instead of % the literal character `\'. -% +% @def at normalturnoffactive{% @let\=@normalbackslash @let"=@normaldoublequote diff --git a/configure.ac b/configure.ac index 8bca728..45481cc 100644 --- a/configure.ac +++ b/configure.ac @@ -63,7 +63,7 @@ PACKAGE=$PACKAGE_NAME PACKAGE_GT=${PACKAGE_NAME}2 VERSION=$PACKAGE_VERSION -AC_CONFIG_AUX_DIR([scripts]) +AC_CONFIG_AUX_DIR([build-aux]) AC_CONFIG_SRCDIR([sm/gpgsm.c]) AC_CONFIG_HEADER([config.h]) # Note: For automake 1.13 add the option ----------------------------------------------------------------------- Summary of changes: Makefile.am | 19 +-- autogen.rc | 43 ++++++ autogen.sh | 200 +++++++++++++++++---------- {scripts => build-aux}/ChangeLog-2011 | 0 {scripts => build-aux}/build-all.sh | 0 {scripts => build-aux}/compile | 0 {scripts => build-aux}/config.guess | 0 {scripts => build-aux}/config.rpath | 0 {scripts => build-aux}/config.sub | 0 {scripts => build-aux}/depcomp | 0 {scripts => build-aux}/git-hooks/commit-msg | 0 {scripts => build-aux}/git-log-fix | 0 {scripts => build-aux}/git-log-footer | 0 {scripts => build-aux}/gitlog-to-changelog | 0 {scripts => build-aux}/install-sh | 0 {scripts => build-aux}/mail-to-translators | 9 +- {scripts => build-aux}/mdate-sh | 0 {scripts => build-aux}/missing | 0 {scripts => build-aux}/mkinstalldirs | 0 {scripts => build-aux}/potomo | 0 {scripts => build-aux}/speedo.mk | 0 {scripts => build-aux}/texinfo.tex | 116 ++++++++-------- configure.ac | 2 +- 23 files changed, 240 insertions(+), 149 deletions(-) create mode 100644 autogen.rc rename {scripts => build-aux}/ChangeLog-2011 (100%) rename {scripts => build-aux}/build-all.sh (100%) rename {scripts => build-aux}/compile (100%) rename {scripts => build-aux}/config.guess (100%) rename {scripts => build-aux}/config.rpath (100%) rename {scripts => build-aux}/config.sub (100%) rename {scripts => build-aux}/depcomp (100%) rename {scripts => build-aux}/git-hooks/commit-msg (100%) rename {scripts => build-aux}/git-log-fix (100%) rename {scripts => build-aux}/git-log-footer (100%) rename {scripts => build-aux}/gitlog-to-changelog (100%) rename {scripts => build-aux}/install-sh (100%) rename {scripts => build-aux}/mail-to-translators (95%) rename {scripts => build-aux}/mdate-sh (100%) rename {scripts => build-aux}/missing (100%) rename {scripts => build-aux}/mkinstalldirs (100%) rename {scripts => build-aux}/potomo (100%) rename {scripts => build-aux}/speedo.mk (100%) rename {scripts => build-aux}/texinfo.tex (99%) hooks/post-receive -- The GNU Privacy Guard http://git.gnupg.org From cvs at cvs.gnupg.org Fri Jan 10 15:17:02 2014 From: cvs at cvs.gnupg.org (by Werner Koch) Date: Fri, 10 Jan 2014 15:17:02 +0100 Subject: [git] GPG-ERROR - branch, master, updated. libgpg-error-1.12-9-gc1871fd Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Error codes used by GnuPG et al.". The branch, master has been updated via c1871fddf85cdddc33c1b35d5f1c8bae76388ee5 (commit) via e3ff40a78e9e95e1296b66f9c0d3df905c8af0d3 (commit) via 69c15393d1dac28e08c3b84b1aea286f12327847 (commit) from 0b192cff772bd416dc85b8140b9eb0d52e4175dd (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit c1871fddf85cdddc33c1b35d5f1c8bae76388ee5 Author: Werner Koch Date: Thu Jan 9 19:14:09 2014 +0100 po: Update de.po. diff --git a/po/de.po b/po/de.po index 64dd594..45be3f6 100644 --- a/po/de.po +++ b/po/de.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: libgpg-error-1.9\n" "Report-Msgid-Bugs-To: translations at gnupg.org\n" -"PO-Revision-Date: 2013-06-24 06:35+0200\n" +"PO-Revision-Date: 2014-01-10 15:13+0100\n" "Last-Translator: Werner Koch \n" "Language-Team: none\n" "Language: \n" @@ -675,6 +675,9 @@ msgstr "Defekter ?ffentlicher Schl?ssel" msgid "Broken secret key" msgstr "Defekter geheimer Schl?ssel" +msgid "Invalid MAC algorithm" +msgstr "Ung?ltige MAC-Methode" + msgid "Operation fully cancelled" msgstr "Verarbeitung wurde vollst?ndig abgebrochen" commit e3ff40a78e9e95e1296b66f9c0d3df905c8af0d3 Author: Werner Koch Date: Thu Jan 9 19:14:09 2014 +0100 Use the generic autogen.sh script. * Makefile.am (EXTRA_DIST): Add autogen.rc remove config.rpath. * autogen.rc: New. * autogen.sh: Update from current GnuPG. -- Note that config.rpath is automatically distributed by automake. diff --git a/Makefile.am b/Makefile.am index acb192e..9cab484 100644 --- a/Makefile.am +++ b/Makefile.am @@ -22,7 +22,7 @@ AUTOMAKE_OPTIONS = dist-bzip2 # (A suitable gitlog-to-changelog script can be found in GnuPG master.) GITLOG_TO_CHANGELOG=gitlog-to-changelog -EXTRA_DIST = autogen.sh config.rpath libgpg-error.spec.in \ +EXTRA_DIST = autogen.sh autogen.rc libgpg-error.spec.in \ COPYING COPYING.LIB potomo doc/HACKING ChangeLog-2011 \ po/ChangeLog-2011 m4/ChangeLog-2011 contrib/ChangeLog-2011 \ build-aux/git-log-footer build-aux/git-log-fix @@ -71,4 +71,3 @@ endif stowinstall: $(MAKE) $(AM_MAKEFLAGS) install prefix=/usr/local/stow/libgpg-error - diff --git a/autogen.rc b/autogen.rc new file mode 100644 index 0000000..a9cf145 --- /dev/null +++ b/autogen.rc @@ -0,0 +1,21 @@ +# autogen.sh configuration for libgpg-error -*- sh -*- + +case "$myhost:$myhostsub" in + w32:ce) + extraoptions= + ;; + w32:64) + extraoptions= + ;; + w32:) + extraoptions= + ;; +esac + +case "$myhost" in + w32) + configure_opts= + ;; +esac + +final_info="./configure --enable-maintainer-mode && make" diff --git a/autogen.sh b/autogen.sh index 8256fd2..471193c 100755 --- a/autogen.sh +++ b/autogen.sh @@ -1,7 +1,6 @@ #! /bin/sh -# Run this to generate all the initial makefiles, etc. -# -# Copyright (C) 2003 g10 Code GmbH +# autogen.sh +# Copyright (C) 2003, 2014 g10 Code GmbH # # This file is free software; as a special exception the author gives # unlimited permission to copy and/or distribute it, with or without @@ -10,6 +9,13 @@ # This program 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. +# +# This is a generic script to create the configure script and handle cross +# build environments. It requires the presence of a autogen.rc file to +# configure it for the respective package. It is maintained as part of +# GnuPG and source copied by other packages. +# +# Version: 2014-01-10 configure_ac="configure.ac" @@ -18,7 +24,7 @@ cvtver () { } check_version () { - if [ `("$1" --version || echo "0") | cvtver` -ge "$2" ]; then + if [ $(( `("$1" --version || echo "0") | cvtver` >= $2 )) = 1 ]; then return 0 fi echo "**Error**: "\`$1\'" not installed or too old." >&2 @@ -28,14 +34,86 @@ check_version () { return 1 } +fatal () { + echo "autogen.sh:" "$*" >&2 + DIE=yes +} + +info () { + if [ -z "${SILENT}" ]; then + echo "autogen.sh:" "$*" + fi +} + +die_p () { + if [ "$DIE" = "yes" ]; then + echo "autogen.sh: Stop." >&2 + exit 1 + fi +} + +replace_sysroot () { + configure_opts=$(echo $configure_opts | sed "s#@SYSROOT@#${w32root}#g") + extraoptions=$(echo $extraoptions | sed "s#@SYSROOT@#${w32root}#g") +} + +# Allow to override the default tool names +AUTOCONF=${AUTOCONF_PREFIX}${AUTOCONF:-autoconf}${AUTOCONF_SUFFIX} +AUTOHEADER=${AUTOCONF_PREFIX}${AUTOHEADER:-autoheader}${AUTOCONF_SUFFIX} + +AUTOMAKE=${AUTOMAKE_PREFIX}${AUTOMAKE:-automake}${AUTOMAKE_SUFFIX} +ACLOCAL=${AUTOMAKE_PREFIX}${ACLOCAL:-aclocal}${AUTOMAKE_SUFFIX} + +GETTEXT=${GETTEXT_PREFIX}${GETTEXT:-gettext}${GETTEXT_SUFFIX} +MSGMERGE=${GETTEXT_PREFIX}${MSGMERGE:-msgmerge}${GETTEXT_SUFFIX} + DIE=no FORCE= -if test "$1" = "--force"; then +SILENT= +tmp=$(dirname "$0") +tsdir=$(cd "${tmp}"; pwd) + +if [ -n "${AUTOGEN_SH_SILENT}" ]; then + SILENT=" --silent" +fi +if test x"$1" = x"--help"; then + echo "usage: ./autogen.sh [--silent] [--force] [--build-TYPE] [ARGS]" + exit 0 +fi +if test x"$1" = x"--silent"; then + SILENT=" --silent" + shift +fi +if test x"$1" = x"--force"; then FORCE=" --force" shift fi -# Begin list of optional variables sourced from ~/.gnupg-autogen.rc + +# Reject unsafe characters in $HOME, $tsdir and cwd. We consider spaces +# as unsafe because it is too easy to get scripts wrong in this regard. +am_lf=' +' +case `pwd` in + *[\;\\\"\#\$\&\'\`$am_lf\ \ ]*) + fatal "unsafe working directory name" ;; +esac +case $tsdir in + *[\;\\\"\#\$\&\'\`$am_lf\ \ ]*) + fatal "unsafe source directory: \`$tsdir'" ;; +esac +case $HOME in + *[\;\\\"\#\$\&\'\`$am_lf\ \ ]*) + fatal "unsafe home directory: \`$HOME'" ;; +esac +die_p + + +# List of variables sourced from autogen.rc. The strings '@SYSROOT@' in +# these variables are replaced by the actual system root. +configure_opts= +extraoptions= +# List of optional variables sourced from autogen.rc and ~/.gnupg-autogen.rc w32_toolprefixes= w32_extraoptions= w32ce_toolprefixes= @@ -51,66 +129,81 @@ amd64_toolprefixes= #w64root= #amd64root= -if [ -f "$HOME/.gnupg-autogen.rc" ]; then - echo "sourcing extra definitions from $HOME/.gnupg-autogen.rc" - . "$HOME/.gnupg-autogen.rc" -fi - # Convenience option to use certain configure options for some hosts. myhost="" myhostsub="" case "$1" in --build-w32) myhost="w32" + shift ;; --build-w32ce) myhost="w32" myhostsub="ce" + shift ;; --build-w64) myhost="w32" myhostsub="64" + shift + ;; + --build-amd64) + myhost="amd64" + shift ;; --build*) - echo "**Error**: invalid build option $1" >&2 - exit 1 + fatal "**Error**: invalid build option $1" + shift ;; *) ;; esac +die_p +# Source our configuration +if [ -f "${tsdir}/autogen.rc" ]; then + . "${tsdir}/autogen.rc" +fi + +# Source optional site specific configuration +if [ -f "$HOME/.gnupg-autogen.rc" ]; then + info "sourcing extra definitions from $HOME/.gnupg-autogen.rc" + . "$HOME/.gnupg-autogen.rc" +fi -# ***** W32 build script ******* -# Used to cross-compile for Windows. +# ****************** +# W32 build script +# ****************** if [ "$myhost" = "w32" ]; then - tmp=`dirname $0` - tsdir=`cd "$tmp"; pwd` - shift - if [ ! -f $tsdir/config.guess ]; then - echo "$tsdir/config.guess not found" >&2 + if [ ! -f "$tsdir/build-aux/config.guess" ]; then + fatal "$tsdir/build-aux/config.guess not found" exit 1 fi - build=`$tsdir/config.guess` + build=`$tsdir/build-aux/config.guess` case $myhostsub in ce) w32root="$w32ce_root" [ -z "$w32root" ] && w32root="$HOME/w32ce_root" - toolprefixes="arm-mingw32ce" + toolprefixes="$w32ce_toolprefixes arm-mingw32ce" + extraoptions="$extraoptions $w32ce_extraoptions" ;; 64) w32root="$w64root" [ -z "$w32root" ] && w32root="$HOME/w64root" toolprefixes="$w64_toolprefixes x86_64-w64-mingw32" + extraoptions="$extraoptions $w64_extraoptions" ;; *) [ -z "$w32root" ] && w32root="$HOME/w32root" toolprefixes="$w32_toolprefixes i686-w64-mingw32 i586-mingw32msvc" toolprefixes="$toolprefixes i386-mingw32msvc mingw32" + extraoptions="$extraoptions $w32_extraoptions" ;; esac - echo "Using $w32root as standard install directory" >&2 + info "Using $w32root as standard install directory" + replace_sysroot # Locate the cross compiler crossbindir= @@ -122,48 +215,49 @@ if [ "$myhost" = "w32" ]; then fi done if [ -z "$crossbindir" ]; then - echo "Cross compiler kit not installed" >&2 + fatal "cross compiler kit not installed" if [ -z "$myhostsub" ]; then - echo "Under Debian GNU/Linux, you may install it using" >&2 - echo " apt-get install mingw32 mingw32-runtime mingw32-binutils" >&2 + info "Under Debian GNU/Linux, you may install it using" + info " apt-get install mingw32 mingw32-runtime mingw32-binutils" fi - echo "Stop." >&2 - exit 1 + die_p fi if [ -f "$tsdir/config.log" ]; then if ! head $tsdir/config.log | grep "$host" >/dev/null; then - echo "Pease run a 'make distclean' first" >&2 - exit 1 + fatal "Please run a 'make distclean' first" + die_p fi fi - $tsdir/configure --enable-maintainer-mode --prefix=${w32root} \ - --host=${host} --build=${build} "$@" - - exit $? + $tsdir/configure --enable-maintainer-mode ${SILENT} \ + --prefix=${w32root} \ + --host=${host} --build=${build} \ + ${configure_opts} ${extraoptions} "$@" + rc=$? + exit $rc fi # ***** end W32 build script ******* - # ***** AMD64 cross build script ******* # Used to cross-compile for AMD64 (for testing) -if test "$1" = "--build-amd64"; then - tmp=`dirname $0` - tsdir=`cd "$tmp"; pwd` +if [ "$myhost" = "amd64" ]; then shift - if [ ! -f $tsdir/config.guess ]; then - echo "$tsdir/config.guess not found" >&2 + if [ ! -f $tsdir/build-aux/config.guess ]; then + echo "$tsdir/build-aux/config.guess not found" >&2 exit 1 fi - build=`$tsdir/config.guess` + build=`$tsdir/build-aux/config.guess` [ -z "$amd64root" ] && amd64root="$HOME/amd64root" - echo "Using $amd64root as standard install directory" >&2 + info "Using $amd64root as standard install directory" + replace_sysroot + + toolprefixes="$amd64_toolprefixes x86_64-linux-gnu amd64-linux-gnu" # Locate the cross compiler crossbindir= - for host in x86_64-linux-gnu amd64-linux-gnu; do + for host in $toolprefixes ; do if ${host}-gcc --version >/dev/null 2>&1 ; then crossbindir=/usr/${host}/bin conf_CC="CC=${host}-gcc" @@ -183,15 +277,16 @@ if test "$1" = "--build-amd64"; then fi fi - $tsdir/configure --enable-maintainer-mode --prefix=${amd64root} \ - --host=${host} --build=${build} + $tsdir/configure --enable-maintainer-mode ${SILENT} \ + --prefix=${amd64root} \ + --host=${host} --build=${build} \ + ${configure_opts} ${extraoptions} "$@" rc=$? exit $rc fi # ***** end AMD64 cross build script ******* - # Grep the required versions from configure.ac autoconf_vers=`sed -n '/^AC_PREREQ(/ { s/^.*(\(.*\))/\1/p @@ -205,12 +300,15 @@ q }' ${configure_ac}` automake_vers_num=`echo "$automake_vers" | cvtver` -gettext_vers=`sed -n '/^AM_GNU_GETTEXT_VERSION(/ { -s/^.*(\(.*\))/\1/p +if [ -d "${tsdir}/po" ]; then + gettext_vers=`sed -n '/^AM_GNU_GETTEXT_VERSION(/ { +s/^.*\[\(.*\)])/\1/p q }' ${configure_ac}` -gettext_vers_num=`echo "$gettext_vers" | cvtver` - + gettext_vers_num=`echo "$gettext_vers" | cvtver` +else + gettext_vers="n/a" +fi if [ -z "$autoconf_vers" -o -z "$automake_vers" -o -z "$gettext_vers" ] then @@ -218,16 +316,6 @@ then exit 1 fi -# Allow to override the default tool names -AUTOCONF=${AUTOCONF_PREFIX}${AUTOCONF:-autoconf}${AUTOCONF_SUFFIX} -AUTOHEADER=${AUTOCONF_PREFIX}${AUTOHEADER:-autoheader}${AUTOCONF_SUFFIX} - -AUTOMAKE=${AUTOMAKE_PREFIX}${AUTOMAKE:-automake}${AUTOMAKE_SUFFIX} -ACLOCAL=${AUTOMAKE_PREFIX}${ACLOCAL:-aclocal}${AUTOMAKE_SUFFIX} - -GETTEXT=${GETTEXT_PREFIX}${GETTEXT:-gettext}${GETTEXT_SUFFIX} -MSGMERGE=${GETTEXT_PREFIX}${MSGMERGE:-msgmerge}${GETTEXT_SUFFIX} - if check_version $AUTOCONF $autoconf_vers_num $autoconf_vers ; then check_version $AUTOHEADER $autoconf_vers_num $autoconf_vers autoconf @@ -235,51 +323,71 @@ fi if check_version $AUTOMAKE $automake_vers_num $automake_vers; then check_version $ACLOCAL $automake_vers_num $autoconf_vers automake fi -if check_version $GETTEXT $gettext_vers_num $gettext_vers; then - check_version $MSGMERGE $gettext_vers_num $gettext_vers gettext +if [ "$gettext_vers" != "n/a" ]; then + if check_version $GETTEXT $gettext_vers_num $gettext_vers; then + check_version $MSGMERGE $gettext_vers_num $gettext_vers gettext + fi fi -if test "$DIE" = "yes"; then +if [ "$DIE" = "yes" ]; then cat <&2 + [ -z "${SILENT}" ] && cat <&2 - git config --add filter.cleanpo.clean \ + + if [ "$gettext_vers" != "n/a" ]; then + tmp=$(git config --get filter.cleanpo.clean) + if [ "$tmp" != \ + "awk '/^\"POT-Creation-Date:/&&!s{s=1;next};!/^#: /{print}'" ] + then + info "*** Adding GIT filter.cleanpo.clean configuration." + git config --add filter.cleanpo.clean \ "awk '/^\"POT-Creation-Date:/&&!s{s=1;next};!/^#: /{print}'" + fi + fi + if [ -f build-aux/git-hooks/commit-msg -a ! -f .git/hooks/commit-msg ] ; then + [ -z "${SILENT}" ] && cat < Date: Thu Jan 9 19:14:09 2014 +0100 Move helper scripts to build-aux. * compile, config.guess, config.rpath, config.sub * depcomp, install-sh, ltmain.sh, missing: Move to build-aux/. * configure.ac (AC_CONFIG_AUX_DIR): New. diff --git a/compile b/build-aux/compile similarity index 100% rename from compile rename to build-aux/compile diff --git a/config.guess b/build-aux/config.guess similarity index 100% rename from config.guess rename to build-aux/config.guess diff --git a/config.rpath b/build-aux/config.rpath similarity index 100% rename from config.rpath rename to build-aux/config.rpath diff --git a/config.sub b/build-aux/config.sub similarity index 100% rename from config.sub rename to build-aux/config.sub diff --git a/depcomp b/build-aux/depcomp similarity index 100% rename from depcomp rename to build-aux/depcomp diff --git a/install-sh b/build-aux/install-sh similarity index 100% rename from install-sh rename to build-aux/install-sh diff --git a/ltmain.sh b/build-aux/ltmain.sh similarity index 99% rename from ltmain.sh rename to build-aux/ltmain.sh index 07bf696..f8c3614 100644 --- a/ltmain.sh +++ b/build-aux/ltmain.sh @@ -9675,4 +9675,3 @@ build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` # sh-indentation:2 # End: # vi:sw=2 - diff --git a/missing b/build-aux/missing similarity index 100% rename from missing rename to build-aux/missing diff --git a/configure.ac b/configure.ac index 04e259b..73de716 100644 --- a/configure.ac +++ b/configure.ac @@ -64,11 +64,13 @@ VERSION_NUMBER=m4_esyscmd(printf "0x%02x%02x00" mym4_version_major \ mym4_version_minor) AC_SUBST(VERSION_NUMBER) +AC_CONFIG_AUX_DIR([build-aux]) AM_INIT_AUTOMAKE AM_MAINTAINER_MODE AC_CONFIG_SRCDIR([src/err-sources.h.in]) AC_CONFIG_HEADER([config.h]) AC_CONFIG_MACRO_DIR([m4]) +AM_SILENT_RULES # We need to know about the host architecture to avoid spurious # warnings. ----------------------------------------------------------------------- Summary of changes: Makefile.am | 3 +- autogen.rc | 21 +++ autogen.sh | 268 ++++++++++++++++++++++---------- compile => build-aux/compile | 0 config.guess => build-aux/config.guess | 0 config.rpath => build-aux/config.rpath | 0 config.sub => build-aux/config.sub | 0 depcomp => build-aux/depcomp | 0 install-sh => build-aux/install-sh | 0 ltmain.sh => build-aux/ltmain.sh | 1 - missing => build-aux/missing | 0 configure.ac | 2 + po/de.po | 5 +- 13 files changed, 216 insertions(+), 84 deletions(-) create mode 100644 autogen.rc rename compile => build-aux/compile (100%) rename config.guess => build-aux/config.guess (100%) rename config.rpath => build-aux/config.rpath (100%) rename config.sub => build-aux/config.sub (100%) rename depcomp => build-aux/depcomp (100%) rename install-sh => build-aux/install-sh (100%) rename ltmain.sh => build-aux/ltmain.sh (99%) rename missing => build-aux/missing (100%) hooks/post-receive -- Error codes used by GnuPG et al. http://git.gnupg.org From cvs at cvs.gnupg.org Fri Jan 10 15:19:18 2014 From: cvs at cvs.gnupg.org (by Werner Koch) Date: Fri, 10 Jan 2014 15:19:18 +0100 Subject: [git] GnuPG - branch, master, updated. gnupg-2.1.0beta3-284-g1dbf4a7 Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The GNU Privacy Guard". The branch, master has been updated via 1dbf4a7573acf60cb3cfb8b7365c103080138345 (commit) via aedfa95bcc49156f2bc6ae5d0f385705d4fbdd32 (commit) from e7973d36d88178b4b0a977e3fcc0d62600777618 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 1dbf4a7573acf60cb3cfb8b7365c103080138345 Author: Werner Koch Date: Thu Jan 9 19:14:09 2014 +0100 speedo: Minor improvements. -- diff --git a/build-aux/speedo.mk b/build-aux/speedo.mk index 4148002..f18ca44 100644 --- a/build-aux/speedo.mk +++ b/build-aux/speedo.mk @@ -43,13 +43,19 @@ # +# Set this to "git" or "release". +WHAT=release -# -------- +# Set target to "native" or "w32" +TARGETOS=native + +# Number of parallel make jobs +MAKE_J=3 # The packages that should be built. The order is also the build order. speedo_spkgs = libgpg-error npth libgcrypt libassuan libksba gnupg gpgme gpa -# version numbers of the released packages +# Version numbers of the released packages # Fixme: Take the version numbers from gnupg-doc/web/swdb.mac libgpg_error_ver = 1.12 npth_ver = 0.91 @@ -64,6 +70,9 @@ gpa_ver = 0.9.5 #gitrep = git://git.gnupg.org gitrep = ${HOME}/s +# The tarball directory +pkgrep = ftp://ftp.gnupg.org/gcrypt + # For each package, the following variables can be defined: # @@ -87,15 +96,6 @@ gitrep = ${HOME}/s # Note that you can override the defaults in this file in a local file # "config.mk" -# Set this to "git" or "release". -WHAT=release - -# Set target to "native" or "w32" -TARGETOS=native - -# Number of parallel make jobs -MAKE_J=3 - ifeq ($(WHAT),git) speedo_pkg_libgpg_error_git = $(gitrep)/libgpg-error speedo_pkg_libgpg_error_gitref = master @@ -114,7 +114,6 @@ ifeq ($(WHAT),git) speedo_pkg_gpa_git = $(gitrep)/gpa speedo_pkg_gpa_gitref = master else - pkgrep = ftp://ftp.gnupg.org/gcrypt speedo_pkg_libgpg_error_tar = \ $(pkgrep)/libgpg-error/libgpg-error-$(libgpg_error_ver).tar.bz2 speedo_pkg_npth_tar = \ @@ -248,13 +247,13 @@ $(stampdir)/stamp-$(1)-00-unpack: $(stampdir)/stamp-directories @echo "speedo: /*" @echo "speedo: * $(1)" @echo "speedo: */" - @(cd $(sdir); \ - $(call SETVARS,$(1)); \ + @(set -e; cd $(sdir); \ + $(call SETVARS,$(1)); \ if [ -n "$$$${git}" ]; then \ echo "speedo: unpacking $(1) from $$$${git}:$$$${gitref}"; \ - git clone -q -b "$$$${gitref}" "$$$${git}" "$$$${pkg}"; \ - cd "$$$${pkg}" && \ - AUTOGEN_SH_SILENT=1 ./autogen.sh; \ + git clone -b "$$$${gitref}" "$$$${git}" "$$$${pkg}"; \ + cd "$$$${pkg}"; \ + AUTOGEN_SH_SILENT=1 ./autogen.sh; \ elif [ -n "$$$${tar}" ]; then \ echo "speedo: unpacking $(1) from $$$${tar}"; \ case "$$$${tar}" in \ @@ -283,8 +282,8 @@ $(stampdir)/stamp-$(1)-01-configure: $(stampdir)/stamp-$(1)-00-unpack if [ -n "$(speedo_autogen_buildopt)" ]; then \ eval AUTOGEN_SH_SILENT=1 w32root="$(idir)" \ "$$$${pkgsdir}/autogen.sh" \ - $(speedo_autogen_buildopt) --silent \ - $$$${pkgcfg}; \ + $(speedo_autogen_buildopt) \ + $$$${pkgcfg}; \ else \ eval "$$$${pkgsdir}/configure" \ --silent \ @@ -318,10 +317,11 @@ $(stampdir)/stamp-final-$(1): $(stampdir)/stamp-$(1)-03-install clean-$(1): @echo "speedo: uninstalling $(1)" @($(call SETVARS,$(1)); \ - (cd "$$$${pkgbdir}"; \ - $(MAKE) --no-print-directory $$$${pkgmkargs_inst} uninstall V=0); \ - rm -fR "$$$${pkgsdir}" "$$$${pkgbdir}") - @rm -f $(stampdir)/stamp-final-$(1) $(stampdir)/stamp-$(1)-* + (cd "$$$${pkgbdir}" 2>/dev/null && \ + $(MAKE) --no-print-directory \ + $$$${pkgmkargs_inst} uninstall V=0 ) || true;\ + rm -fR "$$$${pkgsdir}" "$$$${pkgbdir}" || true) + -rm -f $(stampdir)/stamp-final-$(1) $(stampdir)/stamp-$(1)-* .PHONY : report-$(1) report-$(1): commit aedfa95bcc49156f2bc6ae5d0f385705d4fbdd32 Author: Werner Koch Date: Thu Jan 9 19:14:09 2014 +0100 autogen.sh: Add rule for 64 bit windows. diff --git a/autogen.sh b/autogen.sh index ea3d5fc..471193c 100755 --- a/autogen.sh +++ b/autogen.sh @@ -189,6 +189,12 @@ if [ "$myhost" = "w32" ]; then toolprefixes="$w32ce_toolprefixes arm-mingw32ce" extraoptions="$extraoptions $w32ce_extraoptions" ;; + 64) + w32root="$w64root" + [ -z "$w32root" ] && w32root="$HOME/w64root" + toolprefixes="$w64_toolprefixes x86_64-w64-mingw32" + extraoptions="$extraoptions $w64_extraoptions" + ;; *) [ -z "$w32root" ] && w32root="$HOME/w32root" toolprefixes="$w32_toolprefixes i686-w64-mingw32 i586-mingw32msvc" ----------------------------------------------------------------------- Summary of changes: autogen.sh | 6 ++++++ build-aux/speedo.mk | 46 +++++++++++++++++++++++----------------------- 2 files changed, 29 insertions(+), 23 deletions(-) hooks/post-receive -- The GNU Privacy Guard http://git.gnupg.org From cvs at cvs.gnupg.org Fri Jan 10 15:43:27 2014 From: cvs at cvs.gnupg.org (by Werner Koch) Date: Fri, 10 Jan 2014 15:43:27 +0100 Subject: [git] GCRYPT - branch, master, updated. libgcrypt-1.6.0-17-gb0ac1f9 Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The GNU crypto library". The branch, master has been updated via b0ac1f9b143aa15855914ba93fef900288d45c9c (commit) via df9b4eabf52faee6f289a4bc62219684442ae383 (commit) from 4b7db51ad5d1bf98fd08ca3048f258059eca61a4 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit b0ac1f9b143aa15855914ba93fef900288d45c9c Author: Werner Koch Date: Thu Jan 9 19:14:09 2014 +0100 Use the generic autogen.sh script. * autogen.rc: New. * Makefile.am (EXTRA_DIST): Add it. * autogen.sh: Update from current GnuPG. Signed-off-by: Werner Koch diff --git a/Makefile.am b/Makefile.am index 8458dd0..937bdaf 100644 --- a/Makefile.am +++ b/Makefile.am @@ -28,7 +28,7 @@ GITLOG_TO_CHANGELOG=gitlog-to-changelog DIST_SUBDIRS = m4 compat mpi cipher random src doc tests SUBDIRS = compat mpi cipher random src doc tests -EXTRA_DIST = autogen.sh README.GIT LICENSES \ +EXTRA_DIST = autogen.sh autogen.rc README.GIT LICENSES \ ChangeLog-2011 build-aux/ChangeLog-2011 doc/ChangeLog-2011 \ m4/ChangeLog-2011 cipher/ChangeLog-2011 src/ChangeLog-2011 \ random/ChangeLog-2011 tests/ChangeLog-2011 mpi/ChangeLog-2011 \ diff --git a/autogen.rc b/autogen.rc new file mode 100644 index 0000000..09a9b9c --- /dev/null +++ b/autogen.rc @@ -0,0 +1,17 @@ +# autogen.sh configuration for Libgcrypt -*- sh -*- + +case "$myhost" in + w32) + configure_opts=" + --with-gpg-error-prefix=@SYSROOT@ + " + ;; + + amd64) + configure_opts=" + --with-gpg-error-prefix=@SYSROOT@ + " + ;; +esac + +final_info="./configure --enable-maintainer-mode && make" diff --git a/autogen.sh b/autogen.sh index 841c2c2..471193c 100755 --- a/autogen.sh +++ b/autogen.sh @@ -1,7 +1,6 @@ #! /bin/sh -# Run this to generate all the initial makefiles, etc. -# -# Copyright (C) 2003 g10 Code GmbH +# autogen.sh +# Copyright (C) 2003, 2014 g10 Code GmbH # # This file is free software; as a special exception the author gives # unlimited permission to copy and/or distribute it, with or without @@ -10,6 +9,13 @@ # This program 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. +# +# This is a generic script to create the configure script and handle cross +# build environments. It requires the presence of a autogen.rc file to +# configure it for the respective package. It is maintained as part of +# GnuPG and source copied by other packages. +# +# Version: 2014-01-10 configure_ac="configure.ac" @@ -18,7 +24,7 @@ cvtver () { } check_version () { - if [ `("$1" --version || echo "0") | cvtver` -ge "$2" ]; then + if [ $(( `("$1" --version || echo "0") | cvtver` >= $2 )) = 1 ]; then return 0 fi echo "**Error**: "\`$1\'" not installed or too old." >&2 @@ -28,89 +34,176 @@ check_version () { return 1 } +fatal () { + echo "autogen.sh:" "$*" >&2 + DIE=yes +} + +info () { + if [ -z "${SILENT}" ]; then + echo "autogen.sh:" "$*" + fi +} + +die_p () { + if [ "$DIE" = "yes" ]; then + echo "autogen.sh: Stop." >&2 + exit 1 + fi +} + +replace_sysroot () { + configure_opts=$(echo $configure_opts | sed "s#@SYSROOT@#${w32root}#g") + extraoptions=$(echo $extraoptions | sed "s#@SYSROOT@#${w32root}#g") +} + +# Allow to override the default tool names +AUTOCONF=${AUTOCONF_PREFIX}${AUTOCONF:-autoconf}${AUTOCONF_SUFFIX} +AUTOHEADER=${AUTOCONF_PREFIX}${AUTOHEADER:-autoheader}${AUTOCONF_SUFFIX} + +AUTOMAKE=${AUTOMAKE_PREFIX}${AUTOMAKE:-automake}${AUTOMAKE_SUFFIX} +ACLOCAL=${AUTOMAKE_PREFIX}${ACLOCAL:-aclocal}${AUTOMAKE_SUFFIX} + +GETTEXT=${GETTEXT_PREFIX}${GETTEXT:-gettext}${GETTEXT_SUFFIX} +MSGMERGE=${GETTEXT_PREFIX}${MSGMERGE:-msgmerge}${GETTEXT_SUFFIX} DIE=no FORCE= +SILENT= +tmp=$(dirname "$0") +tsdir=$(cd "${tmp}"; pwd) + +if [ -n "${AUTOGEN_SH_SILENT}" ]; then + SILENT=" --silent" +fi +if test x"$1" = x"--help"; then + echo "usage: ./autogen.sh [--silent] [--force] [--build-TYPE] [ARGS]" + exit 0 +fi +if test x"$1" = x"--silent"; then + SILENT=" --silent" + shift +fi if test x"$1" = x"--force"; then FORCE=" --force" shift fi -# Begin list of optional variables sourced from ~/.gnupg-autogen.rc + +# Reject unsafe characters in $HOME, $tsdir and cwd. We consider spaces +# as unsafe because it is too easy to get scripts wrong in this regard. +am_lf=' +' +case `pwd` in + *[\;\\\"\#\$\&\'\`$am_lf\ \ ]*) + fatal "unsafe working directory name" ;; +esac +case $tsdir in + *[\;\\\"\#\$\&\'\`$am_lf\ \ ]*) + fatal "unsafe source directory: \`$tsdir'" ;; +esac +case $HOME in + *[\;\\\"\#\$\&\'\`$am_lf\ \ ]*) + fatal "unsafe home directory: \`$HOME'" ;; +esac +die_p + + +# List of variables sourced from autogen.rc. The strings '@SYSROOT@' in +# these variables are replaced by the actual system root. +configure_opts= +extraoptions= +# List of optional variables sourced from autogen.rc and ~/.gnupg-autogen.rc w32_toolprefixes= w32_extraoptions= w32ce_toolprefixes= w32ce_extraoptions= +w64_toolprefixes= +w64_extraoptions= amd64_toolprefixes= # End list of optional variables sourced from ~/.gnupg-autogen.rc # What follows are variables which are sourced but default to # environment variables or lacking them hardcoded values. #w32root= #w32ce_root= +#w64root= #amd64root= -if [ -f "$HOME/.gnupg-autogen.rc" ]; then - echo "sourcing extra definitions from $HOME/.gnupg-autogen.rc" - . "$HOME/.gnupg-autogen.rc" -fi - # Convenience option to use certain configure options for some hosts. myhost="" myhostsub="" case "$1" in --build-w32) myhost="w32" + shift ;; --build-w32ce) myhost="w32" myhostsub="ce" + shift ;; --build-w64) myhost="w32" myhostsub="64" + shift ;; --build-amd64) myhost="amd64" + shift ;; --build*) - echo "**Error**: invalid build option $1" >&2 - exit 1 + fatal "**Error**: invalid build option $1" + shift ;; - *) + *) ;; esac +die_p + + +# Source our configuration +if [ -f "${tsdir}/autogen.rc" ]; then + . "${tsdir}/autogen.rc" +fi +# Source optional site specific configuration +if [ -f "$HOME/.gnupg-autogen.rc" ]; then + info "sourcing extra definitions from $HOME/.gnupg-autogen.rc" + . "$HOME/.gnupg-autogen.rc" +fi -# ***** W32 build script ******* -# Used to cross-compile for Windows. +# ****************** +# W32 build script +# ****************** if [ "$myhost" = "w32" ]; then - tmp=`dirname $0` - tsdir=`cd "$tmp"; pwd` - shift - if [ ! -f $tsdir/config.guess ]; then - echo "$tsdir/config.guess not found" >&2 + if [ ! -f "$tsdir/build-aux/config.guess" ]; then + fatal "$tsdir/build-aux/config.guess not found" exit 1 fi - build=`$tsdir/config.guess` + build=`$tsdir/build-aux/config.guess` case $myhostsub in ce) w32root="$w32ce_root" [ -z "$w32root" ] && w32root="$HOME/w32ce_root" - toolprefixes="arm-mingw32ce" + toolprefixes="$w32ce_toolprefixes arm-mingw32ce" + extraoptions="$extraoptions $w32ce_extraoptions" ;; 64) w32root="$w64root" [ -z "$w32root" ] && w32root="$HOME/w64root" - toolprefixes="$amd64_toolprefixes amd64-mingw32msvc" + toolprefixes="$w64_toolprefixes x86_64-w64-mingw32" + extraoptions="$extraoptions $w64_extraoptions" ;; *) [ -z "$w32root" ] && w32root="$HOME/w32root" toolprefixes="$w32_toolprefixes i686-w64-mingw32 i586-mingw32msvc" toolprefixes="$toolprefixes i386-mingw32msvc mingw32" + extraoptions="$extraoptions $w32_extraoptions" ;; esac - echo "Using $w32root as standard install directory" >&2 + info "Using $w32root as standard install directory" + replace_sysroot # Locate the cross compiler crossbindir= @@ -122,48 +215,49 @@ if [ "$myhost" = "w32" ]; then fi done if [ -z "$crossbindir" ]; then - echo "Cross compiler kit not installed" >&2 - if [ -z "$sub" ]; then - echo "Under Debian GNU/Linux, you may install it using" >&2 - echo " apt-get install mingw32 mingw32-runtime mingw32-binutils" >&2 + fatal "cross compiler kit not installed" + if [ -z "$myhostsub" ]; then + info "Under Debian GNU/Linux, you may install it using" + info " apt-get install mingw32 mingw32-runtime mingw32-binutils" fi - echo "Stop." >&2 - exit 1 + die_p fi if [ -f "$tsdir/config.log" ]; then if ! head $tsdir/config.log | grep "$host" >/dev/null; then - echo "Pease run a 'make distclean' first" >&2 - exit 1 + fatal "Please run a 'make distclean' first" + die_p fi fi - $tsdir/configure --enable-maintainer-mode --prefix=${w32root} \ - --host=${host} --build=${build} \ - --with-gpg-error-prefix=${w32root} - exit $? + $tsdir/configure --enable-maintainer-mode ${SILENT} \ + --prefix=${w32root} \ + --host=${host} --build=${build} \ + ${configure_opts} ${extraoptions} "$@" + rc=$? + exit $rc fi # ***** end W32 build script ******* - # ***** AMD64 cross build script ******* # Used to cross-compile for AMD64 (for testing) if [ "$myhost" = "amd64" ]; then - tmp=`dirname $0` - tsdir=`cd "$tmp"; pwd` shift - if [ ! -f $tsdir/config.guess ]; then - echo "$tsdir/config.guess not found" >&2 + if [ ! -f $tsdir/build-aux/config.guess ]; then + echo "$tsdir/build-aux/config.guess not found" >&2 exit 1 fi - build=`$tsdir/config.guess` + build=`$tsdir/build-aux/config.guess` [ -z "$amd64root" ] && amd64root="$HOME/amd64root" - echo "Using $amd64root as standard install directory" >&2 + info "Using $amd64root as standard install directory" + replace_sysroot + + toolprefixes="$amd64_toolprefixes x86_64-linux-gnu amd64-linux-gnu" # Locate the cross compiler crossbindir= - for host in x86_64-linux-gnu amd64-linux-gnu; do + for host in $toolprefixes ; do if ${host}-gcc --version >/dev/null 2>&1 ; then crossbindir=/usr/${host}/bin conf_CC="CC=${host}-gcc" @@ -183,15 +277,16 @@ if [ "$myhost" = "amd64" ]; then fi fi - $tsdir/configure --enable-maintainer-mode --prefix=${amd64root} \ + $tsdir/configure --enable-maintainer-mode ${SILENT} \ + --prefix=${amd64root} \ --host=${host} --build=${build} \ - --with-gpg-error-prefix=${amd64root} - + ${configure_opts} ${extraoptions} "$@" rc=$? exit $rc fi # ***** end AMD64 cross build script ******* + # Grep the required versions from configure.ac autoconf_vers=`sed -n '/^AC_PREREQ(/ { s/^.*(\(.*\))/\1/p @@ -205,29 +300,22 @@ q }' ${configure_ac}` automake_vers_num=`echo "$automake_vers" | cvtver` -#gettext_vers=`sed -n '/^AM_GNU_GETTEXT_VERSION(/ { -#s/^.*(\(.*\))/\1/p -#q -#}' ${configure_ac}` -#gettext_vers_num=`echo "$gettext_vers" | cvtver` - +if [ -d "${tsdir}/po" ]; then + gettext_vers=`sed -n '/^AM_GNU_GETTEXT_VERSION(/ { +s/^.*\[\(.*\)])/\1/p +q +}' ${configure_ac}` + gettext_vers_num=`echo "$gettext_vers" | cvtver` +else + gettext_vers="n/a" +fi -if [ -z "$autoconf_vers" -o -z "$automake_vers" ] +if [ -z "$autoconf_vers" -o -z "$automake_vers" -o -z "$gettext_vers" ] then echo "**Error**: version information not found in "\`${configure_ac}\'"." >&2 exit 1 fi -# Allow to override the default tool names -AUTOCONF=${AUTOCONF_PREFIX}${AUTOCONF:-autoconf}${AUTOCONF_SUFFIX} -AUTOHEADER=${AUTOCONF_PREFIX}${AUTOHEADER:-autoheader}${AUTOCONF_SUFFIX} - -AUTOMAKE=${AUTOMAKE_PREFIX}${AUTOMAKE:-automake}${AUTOMAKE_SUFFIX} -ACLOCAL=${AUTOMAKE_PREFIX}${ACLOCAL:-aclocal}${AUTOMAKE_SUFFIX} - -#GETTEXT=${GETTEXT_PREFIX}${GETTEXT:-gettext}${GETTEXT_SUFFIX} -#MSGMERGE=${GETTEXT_PREFIX}${MSGMERGE:-msgmerge}${GETTEXT_SUFFIX} - if check_version $AUTOCONF $autoconf_vers_num $autoconf_vers ; then check_version $AUTOHEADER $autoconf_vers_num $autoconf_vers autoconf @@ -235,45 +323,71 @@ fi if check_version $AUTOMAKE $automake_vers_num $automake_vers; then check_version $ACLOCAL $automake_vers_num $autoconf_vers automake fi -#if check_version $GETTEXT $gettext_vers_num $gettext_vers; then -# check_version $MSGMERGE $gettext_vers_num $gettext_vers gettext -#fi +if [ "$gettext_vers" != "n/a" ]; then + if check_version $GETTEXT $gettext_vers_num $gettext_vers; then + check_version $MSGMERGE $gettext_vers_num $gettext_vers gettext + fi +fi -if test "$DIE" = "yes"; then +if [ "$DIE" = "yes" ]; then cat <&2 + [ -z "${SILENT}" ] && cat < Date: Thu Jan 9 19:14:09 2014 +0100 Move all helper scripts to build-aux/ * scripts/: Rename to build-aux/. * compile, config.guess, config.rpath, config.sub * depcomp, doc/mdate-sh, doc/texinfo.tex * install-sh, ltmain.sh, missing: Move to build-aux/. * Makefile.am (EXTRA_DIST): Adjust. * configure.ac (AC_CONFIG_AUX_DIR): New. (AM_SILENT_RULES): New. Signed-off-by: Werner Koch diff --git a/Makefile.am b/Makefile.am index 7fb7b50..8458dd0 100644 --- a/Makefile.am +++ b/Makefile.am @@ -27,11 +27,12 @@ GITLOG_TO_CHANGELOG=gitlog-to-changelog DIST_SUBDIRS = m4 compat mpi cipher random src doc tests SUBDIRS = compat mpi cipher random src doc tests -EXTRA_DIST = autogen.sh README.GIT LICENSES \ - ChangeLog-2011 scripts/ChangeLog-2011 doc/ChangeLog-2011 \ - m4/ChangeLog-2011 cipher/ChangeLog-2011 src/ChangeLog-2011 \ + +EXTRA_DIST = autogen.sh README.GIT LICENSES \ + ChangeLog-2011 build-aux/ChangeLog-2011 doc/ChangeLog-2011 \ + m4/ChangeLog-2011 cipher/ChangeLog-2011 src/ChangeLog-2011 \ random/ChangeLog-2011 tests/ChangeLog-2011 mpi/ChangeLog-2011 \ - scripts/git-log-footer scripts/git-log-fix + build-aux/git-log-footer build-aux/git-log-fix DISTCLEANFILES = @@ -59,9 +60,9 @@ gen-ChangeLog: if test -d $(top_srcdir)/.git; then \ (cd $(top_srcdir) && \ $(GITLOG_TO_CHANGELOG) --append-dot --tear-off \ - --amend=scripts/git-log-fix \ + --amend=build-aux/git-log-fix \ --since=$(gen_start_date) ) > $(distdir)/cl-t; \ - cat $(top_srcdir)/scripts/git-log-footer >> $(distdir)/cl-t; \ + cat $(top_srcdir)/build-aux/git-log-footer >> $(distdir)/cl-t;\ rm -f $(distdir)/ChangeLog; \ mv $(distdir)/cl-t $(distdir)/ChangeLog; \ fi diff --git a/scripts/ChangeLog-2011 b/build-aux/ChangeLog-2011 similarity index 100% rename from scripts/ChangeLog-2011 rename to build-aux/ChangeLog-2011 diff --git a/compile b/build-aux/compile similarity index 100% rename from compile rename to build-aux/compile diff --git a/config.guess b/build-aux/config.guess similarity index 100% rename from config.guess rename to build-aux/config.guess diff --git a/config.rpath b/build-aux/config.rpath similarity index 100% rename from config.rpath rename to build-aux/config.rpath diff --git a/config.sub b/build-aux/config.sub similarity index 100% rename from config.sub rename to build-aux/config.sub diff --git a/scripts/db2any b/build-aux/db2any similarity index 99% rename from scripts/db2any rename to build-aux/db2any index 96606f8..a240aaa 100755 --- a/scripts/db2any +++ b/build-aux/db2any @@ -438,7 +438,7 @@ render_texinfo () { sgml2xml -x lower $input > $tmpxml [ $verbose = yes ] && echo "running docbook2texi on '$tmpxml' ..." >&2 docbook2texi $tmpxml | sed 's,--,---,' >$output - rm $tmpxml + rm $tmpxml [ $verbose = yes ] && echo "texinfo '$output' created" >&2 } diff --git a/depcomp b/build-aux/depcomp similarity index 100% rename from depcomp rename to build-aux/depcomp diff --git a/scripts/distfiles b/build-aux/distfiles similarity index 100% rename from scripts/distfiles rename to build-aux/distfiles diff --git a/scripts/git-log-fix b/build-aux/git-log-fix similarity index 100% rename from scripts/git-log-fix rename to build-aux/git-log-fix diff --git a/scripts/git-log-footer b/build-aux/git-log-footer similarity index 100% rename from scripts/git-log-footer rename to build-aux/git-log-footer diff --git a/install-sh b/build-aux/install-sh similarity index 100% rename from install-sh rename to build-aux/install-sh diff --git a/ltmain.sh b/build-aux/ltmain.sh similarity index 99% rename from ltmain.sh rename to build-aux/ltmain.sh index 24e3fd3..859599a 100644 --- a/ltmain.sh +++ b/build-aux/ltmain.sh @@ -9662,4 +9662,3 @@ build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` # sh-indentation:2 # End: # vi:sw=2 - diff --git a/doc/mdate-sh b/build-aux/mdate-sh similarity index 100% rename from doc/mdate-sh rename to build-aux/mdate-sh diff --git a/missing b/build-aux/missing similarity index 100% rename from missing rename to build-aux/missing diff --git a/doc/texinfo.tex b/build-aux/texinfo.tex similarity index 99% rename from doc/texinfo.tex rename to build-aux/texinfo.tex index 8083622..8f99418 100644 --- a/doc/texinfo.tex +++ b/build-aux/texinfo.tex @@ -310,7 +310,7 @@ % We don't want .vr (or whatever) entries like this: % \entry{{\tt \indexbackslash }acronym}{32}{\code {\acronym}} % "\acronym" won't work when it's read back in; - % it needs to be + % it needs to be % {\code {{\tt \backslashcurfont }acronym} \shipout\vbox{% % Do this early so pdf references go to the beginning of the page. @@ -661,7 +661,7 @@ \def\?{?\spacefactor=\endofsentencespacefactor\space} % @frenchspacing on|off says whether to put extra space after punctuation. -% +% \def\onword{on} \def\offword{off} % @@ -1216,7 +1216,7 @@ where each line of input produces a line of output.} % that's what we do). % double active backslashes. -% +% {\catcode`\@=0 \catcode`\\=\active @gdef at activebackslashdouble{% @catcode`@\=@active @@ -1227,11 +1227,11 @@ where each line of input produces a line of output.} % not active characters. hyperref.dtx (which has the same problem as % us) handles it with this amazing macro to replace tokens. I've % tinkered with it a little for texinfo, but it's definitely from there. -% +% % #1 is the tokens to replace. % #2 is the replacement. % #3 is the control sequence with the string. -% +% \def\HyPsdSubst#1#2#3{% \def\HyPsdReplace##1#1##2\END{% ##1% @@ -1420,7 +1420,7 @@ where each line of input produces a line of output.} % tried to figure out what each command should do in the context % of @url. for now, just make @/ a no-op, that's the only one % people have actually reported a problem with. - % + % \normalturnoffactive \def\@{@}% \let\/=\empty @@ -1547,7 +1547,7 @@ where each line of input produces a line of output.} % Definitions for a main text size of 11pt. This is the default in % Texinfo. -% +% \def\definetextfontsizexi{ % Text fonts (11.2pt, magstep1). \def\textnominalsize{11pt} @@ -1672,7 +1672,7 @@ where each line of input produces a line of output.} % section, chapter, etc., sizes following suit. This is for the GNU % Press printing of the Emacs 22 manual. Maybe other manuals in the % future. Used with @smallbook, which sets the leading to 12pt. -% +% \def\definetextfontsizex{% % Text fonts (10pt). \def\textnominalsize{10pt} @@ -1758,7 +1758,7 @@ where each line of input produces a line of output.} \setfont\secsf\sfbshape{12}{1000} \let\secbf\secrm \setfont\secsc\scbshape{10}{\magstep1} -\font\seci=cmmi12 +\font\seci=cmmi12 \font\secsy=cmsy10 scaled \magstep1 % Subsection fonts (10pt). @@ -1799,7 +1799,7 @@ where each line of input produces a line of output.} % We provide the user-level command % @fonttextsize 10 % (or 11) to redefine the text font size. pt is assumed. -% +% \def\xword{10} \def\xiword{11} % @@ -1809,7 +1809,7 @@ where each line of input produces a line of output.} % % Set \globaldefs so that documents can use this inside @tex, since % makeinfo 4.8 does not support it, but we need it nonetheless. - % + % \begingroup \globaldefs=1 \ifx\textsizearg\xword \definetextfontsizex \else \ifx\textsizearg\xiword \definetextfontsizexi @@ -2094,7 +2094,7 @@ where each line of input produces a line of output.} % each of the four underscores in __typeof__. This is undesirable in % some manuals, especially if they don't have long identifiers in % general. @allowcodebreaks provides a way to control this. -% +% \newif\ifallowcodebreaks \allowcodebreakstrue \def\keywordtrue{true} @@ -2225,7 +2225,7 @@ where each line of input produces a line of output.} % @acronym for "FBI", "NATO", and the like. % We print this one point size smaller, since it's intended for % all-uppercase. -% +% \def\acronym#1{\doacronym #1,,\finish} \def\doacronym#1,#2,#3\finish{% {\selectfonts\lsize #1}% @@ -2237,7 +2237,7 @@ where each line of input produces a line of output.} % @abbr for "Comput. J." and the like. % No font change, but don't do end-of-sentence spacing. -% +% \def\abbr#1{\doabbr #1,,\finish} \def\doabbr#1,#2,#3\finish{% {\plainfrenchspacing #1}% @@ -2256,43 +2256,43 @@ where each line of input produces a line of output.} % Theiling, which support regular, slanted, bold and bold slanted (and % "outlined" (blackboard board, sort of) versions, which we don't need). % It is available from http://www.ctan.org/tex-archive/fonts/eurosym. -% +% % Although only regular is the truly official Euro symbol, we ignore % that. The Euro is designed to be slightly taller than the regular % font height. -% +% % feymr - regular % feymo - slanted % feybr - bold % feybo - bold slanted -% +% % There is no good (free) typewriter version, to my knowledge. % A feymr10 euro is ~7.3pt wide, while a normal cmtt10 char is ~5.25pt wide. % Hmm. -% +% % Also doesn't work in math. Do we need to do math with euro symbols? % Hope not. -% -% +% +% \def\euro{{\eurofont e}} \def\eurofont{% % We set the font at each command, rather than predefining it in % \textfonts and the other font-switching commands, so that % installations which never need the symbol don't have to have the % font installed. - % + % % There is only one designed size (nominal 10pt), so we always scale % that to the current nominal size. - % + % % By the way, simply using "at 1em" works for cmr10 and the like, but % does not work for cmbx10 and other extended/shrunken fonts. - % + % \def\eurosize{\csname\curfontsize nominalsize\endcsname}% % - \ifx\curfontstyle\bfstylename + \ifx\curfontstyle\bfstylename % bold: \font\thiseurofont = \ifusingit{feybo10}{feybr10} at \eurosize - \else + \else % regular: \font\thiseurofont = \ifusingit{feymo10}{feymr10} at \eurosize \fi @@ -2316,7 +2316,7 @@ where each line of input produces a line of output.} % Laurent Siebenmann reports \Orb undefined with: % Textures 1.7.7 (preloaded format=plain 93.10.14) (68K) 16 APR 2004 02:38 % so we'll define it if necessary. -% +% \ifx\Orb\undefined \def\Orb{\mathhexbox20D} \fi @@ -2632,7 +2632,7 @@ where each line of input produces a line of output.} % cause the example and the item to crash together. So we use this % bizarre value of 10001 as a signal to \aboveenvbreak to insert % \parskip glue after all. Section titles are handled this way also. - % + % \penalty 10001 \endgroup \itemxneedsnegativevskipfalse @@ -3428,7 +3428,7 @@ where each line of input produces a line of output.} % processing continues to some further point. On the other hand, it % seems \endinput does not hurt in the printed index arg, since that % is still getting written without apparent harm. - % + % % Sample source (mac-idx3.tex, reported by Graham Percival to % help-texinfo, 22may06): % @macro funindex {WORD} @@ -3436,12 +3436,12 @@ where each line of input produces a line of output.} % @end macro % ... % @funindex commtest - % + % % The above is not enough to reproduce the bug, but it gives the flavor. - % + % % Sample whatsit resulting: % . at write3{\entry{xyz}{@folio }{@code {xyz at endinput }}} - % + % % So: \let\endinput = \empty % @@ -3677,11 +3677,11 @@ where each line of input produces a line of output.} % makeinfo does not expand macros in the argument to @deffn, which ends up % writing an index entry, and texindex isn't prepared for an index sort entry % that starts with \. - % + % % Since macro invocations are followed by braces, we can just redefine them % to take a single TeX argument. The case of a macro invocation that % goes to end-of-line is not handled. - % + % \macrolist } @@ -3807,7 +3807,7 @@ where each line of input produces a line of output.} % to re-insert the same penalty (values >10000 are used for various % signals); since we just inserted a non-discardable item, any % following glue (such as a \parskip) would be a breakpoint. For example: - % + % % @deffn deffn-whatever % @vindex index-whatever % Description. @@ -4759,11 +4759,11 @@ where each line of input produces a line of output.} % glue accumulate. (Not a breakpoint because it's preceded by a % discardable item.) \vskip-\parskip - % + % % This is purely so the last item on the list is a known \penalty > % 10000. This is so \startdefun can avoid allowing breakpoints after % section headings. Otherwise, it would insert a valid breakpoint between: - % + % % @section sec-whatever % @deffn def-whatever \penalty 10001 @@ -4821,7 +4821,7 @@ where each line of input produces a line of output.} % These characters do not print properly in the Computer Modern roman % fonts, so we must take special care. This is more or less redundant % with the Texinfo input format setup at the end of this file. -% +% \def\activecatcodes{% \catcode`\"=\active \catcode`\$=\active @@ -5416,8 +5416,8 @@ where each line of input produces a line of output.} % from cmtt (char 0x0d). The undirected quote is ugly, so don't make it % the default, but it works for pasting with more pdf viewers (at least % evince), the lilypond developers report. xpdf does work with the -% regular 0x27. -% +% regular 0x27. +% \def\codequoteright{% \expandafter\ifx\csname SETcodequoteundirected\endcsname\relax '% @@ -5429,7 +5429,7 @@ where each line of input produces a line of output.} % and a similar option for the left quote char vs. a grave accent. % Modern fonts display ASCII 0x60 as a grave accent, so some people like % the code environments to do likewise. -% +% \def\codequoteleft{% \expandafter\ifx\csname SETcodequotebacktick\endcsname\relax `% @@ -5572,7 +5572,7 @@ where each line of input produces a line of output.} % by \defargscommonending, instead of 10000, since the sectioning % commands also insert a nobreak penalty, and we don't want to allow % a break between a section heading and a defun. - % + % \ifnum\lastpenalty=10002 \penalty2000 \fi % % Similarly, after a section heading, do not allow a break. @@ -5950,7 +5950,7 @@ where each line of input produces a line of output.} % This does \let #1 = #2, with \csnames; that is, % \let \csname#1\endcsname = \csname#2\endcsname % (except of course we have to play expansion games). -% +% \def\cslet#1#2{% \expandafter\let \csname#1\expandafter\endcsname @@ -7420,7 +7420,7 @@ should work if nowhere else does.} % Same as @turnoffactive except outputs \ as {\tt\char`\\} instead of % the literal character `\'. -% +% @def at normalturnoffactive{% @let\=@normalbackslash @let"=@normaldoublequote diff --git a/configure.ac b/configure.ac index 1715161..05cdaf8 100644 --- a/configure.ac +++ b/configure.ac @@ -72,6 +72,7 @@ NEED_GPG_ERROR_VERSION=1.11 PACKAGE=$PACKAGE_NAME VERSION=$PACKAGE_VERSION +AC_CONFIG_AUX_DIR([build-aux]) AC_CONFIG_SRCDIR([src/libgcrypt.vers]) AM_INIT_AUTOMAKE AC_CONFIG_HEADER(config.h) @@ -79,6 +80,7 @@ AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_LIBOBJ_DIR([compat]) AC_CANONICAL_HOST AM_MAINTAINER_MODE +AM_SILENT_RULES AH_TOP([ #ifndef _GCRYPT_CONFIG_H_INCLUDED diff --git a/doc/gcrypt.texi b/doc/gcrypt.texi index dfff1b1..cef6318 100644 --- a/doc/gcrypt.texi +++ b/doc/gcrypt.texi @@ -2798,9 +2798,11 @@ supported parameters are: @table @code @item nbits -This is always required to specify the length of the key. The argument -is a string with a number in C-notation. The value should be a multiple -of 8. +This is always required to specify the length of the key. The +argument is a string with a number in C-notation. The value should be +a multiple of 8. Note that the S-expression syntax requires that a +number is prefixed with its string length; thus the @code{4:} in the +above example. @item curve @var{name} For ECC a named curve may be used instead of giving the number of ----------------------------------------------------------------------- Summary of changes: Makefile.am | 13 +- autogen.rc | 17 ++ autogen.sh | 276 ++++++++++++++++++++++---------- {scripts => build-aux}/ChangeLog-2011 | 0 compile => build-aux/compile | 0 config.guess => build-aux/config.guess | 0 config.rpath => build-aux/config.rpath | 0 config.sub => build-aux/config.sub | 0 {scripts => build-aux}/db2any | 2 +- depcomp => build-aux/depcomp | 0 {scripts => build-aux}/distfiles | 0 {scripts => build-aux}/git-log-fix | 0 {scripts => build-aux}/git-log-footer | 0 install-sh => build-aux/install-sh | 0 ltmain.sh => build-aux/ltmain.sh | 1 - {doc => build-aux}/mdate-sh | 0 missing => build-aux/missing | 0 {doc => build-aux}/texinfo.tex | 86 +++++----- configure.ac | 2 + doc/gcrypt.texi | 8 +- 20 files changed, 270 insertions(+), 135 deletions(-) create mode 100644 autogen.rc rename {scripts => build-aux}/ChangeLog-2011 (100%) rename compile => build-aux/compile (100%) rename config.guess => build-aux/config.guess (100%) rename config.rpath => build-aux/config.rpath (100%) rename config.sub => build-aux/config.sub (100%) rename {scripts => build-aux}/db2any (99%) rename depcomp => build-aux/depcomp (100%) rename {scripts => build-aux}/distfiles (100%) rename {scripts => build-aux}/git-log-fix (100%) rename {scripts => build-aux}/git-log-footer (100%) rename install-sh => build-aux/install-sh (100%) rename ltmain.sh => build-aux/ltmain.sh (99%) rename {doc => build-aux}/mdate-sh (100%) rename missing => build-aux/missing (100%) rename {doc => build-aux}/texinfo.tex (99%) hooks/post-receive -- The GNU crypto library http://git.gnupg.org From cvs at cvs.gnupg.org Fri Jan 10 15:50:00 2014 From: cvs at cvs.gnupg.org (by Werner Koch) Date: Fri, 10 Jan 2014 15:50:00 +0100 Subject: [git] GCRYPT - branch, LIBGCRYPT-1-6-BRANCH, updated. libgcrypt-1.6.0-3-g79c9615 Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The GNU crypto library". The branch, LIBGCRYPT-1-6-BRANCH has been updated via 79c961592c09409a49e10d860882c81d51163ee3 (commit) via 14bcfb8b8389ac221a84a5fd8866d9d4a8052953 (commit) from 93919d63c887bdef31f94aeccac94f108fe129d3 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 79c961592c09409a49e10d860882c81d51163ee3 Author: Werner Koch Date: Thu Jan 9 19:14:09 2014 +0100 Use the generic autogen.sh script. * autogen.rc: New. * Makefile.am (EXTRA_DIST): Add it. * autogen.sh: Update from current GnuPG. Signed-off-by: Werner Koch (cherry picked from commit b0ac1f9b143aa15855914ba93fef900288d45c9c) diff --git a/Makefile.am b/Makefile.am index 8458dd0..937bdaf 100644 --- a/Makefile.am +++ b/Makefile.am @@ -28,7 +28,7 @@ GITLOG_TO_CHANGELOG=gitlog-to-changelog DIST_SUBDIRS = m4 compat mpi cipher random src doc tests SUBDIRS = compat mpi cipher random src doc tests -EXTRA_DIST = autogen.sh README.GIT LICENSES \ +EXTRA_DIST = autogen.sh autogen.rc README.GIT LICENSES \ ChangeLog-2011 build-aux/ChangeLog-2011 doc/ChangeLog-2011 \ m4/ChangeLog-2011 cipher/ChangeLog-2011 src/ChangeLog-2011 \ random/ChangeLog-2011 tests/ChangeLog-2011 mpi/ChangeLog-2011 \ diff --git a/autogen.rc b/autogen.rc new file mode 100644 index 0000000..09a9b9c --- /dev/null +++ b/autogen.rc @@ -0,0 +1,17 @@ +# autogen.sh configuration for Libgcrypt -*- sh -*- + +case "$myhost" in + w32) + configure_opts=" + --with-gpg-error-prefix=@SYSROOT@ + " + ;; + + amd64) + configure_opts=" + --with-gpg-error-prefix=@SYSROOT@ + " + ;; +esac + +final_info="./configure --enable-maintainer-mode && make" diff --git a/autogen.sh b/autogen.sh index 841c2c2..471193c 100755 --- a/autogen.sh +++ b/autogen.sh @@ -1,7 +1,6 @@ #! /bin/sh -# Run this to generate all the initial makefiles, etc. -# -# Copyright (C) 2003 g10 Code GmbH +# autogen.sh +# Copyright (C) 2003, 2014 g10 Code GmbH # # This file is free software; as a special exception the author gives # unlimited permission to copy and/or distribute it, with or without @@ -10,6 +9,13 @@ # This program 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. +# +# This is a generic script to create the configure script and handle cross +# build environments. It requires the presence of a autogen.rc file to +# configure it for the respective package. It is maintained as part of +# GnuPG and source copied by other packages. +# +# Version: 2014-01-10 configure_ac="configure.ac" @@ -18,7 +24,7 @@ cvtver () { } check_version () { - if [ `("$1" --version || echo "0") | cvtver` -ge "$2" ]; then + if [ $(( `("$1" --version || echo "0") | cvtver` >= $2 )) = 1 ]; then return 0 fi echo "**Error**: "\`$1\'" not installed or too old." >&2 @@ -28,89 +34,176 @@ check_version () { return 1 } +fatal () { + echo "autogen.sh:" "$*" >&2 + DIE=yes +} + +info () { + if [ -z "${SILENT}" ]; then + echo "autogen.sh:" "$*" + fi +} + +die_p () { + if [ "$DIE" = "yes" ]; then + echo "autogen.sh: Stop." >&2 + exit 1 + fi +} + +replace_sysroot () { + configure_opts=$(echo $configure_opts | sed "s#@SYSROOT@#${w32root}#g") + extraoptions=$(echo $extraoptions | sed "s#@SYSROOT@#${w32root}#g") +} + +# Allow to override the default tool names +AUTOCONF=${AUTOCONF_PREFIX}${AUTOCONF:-autoconf}${AUTOCONF_SUFFIX} +AUTOHEADER=${AUTOCONF_PREFIX}${AUTOHEADER:-autoheader}${AUTOCONF_SUFFIX} + +AUTOMAKE=${AUTOMAKE_PREFIX}${AUTOMAKE:-automake}${AUTOMAKE_SUFFIX} +ACLOCAL=${AUTOMAKE_PREFIX}${ACLOCAL:-aclocal}${AUTOMAKE_SUFFIX} + +GETTEXT=${GETTEXT_PREFIX}${GETTEXT:-gettext}${GETTEXT_SUFFIX} +MSGMERGE=${GETTEXT_PREFIX}${MSGMERGE:-msgmerge}${GETTEXT_SUFFIX} DIE=no FORCE= +SILENT= +tmp=$(dirname "$0") +tsdir=$(cd "${tmp}"; pwd) + +if [ -n "${AUTOGEN_SH_SILENT}" ]; then + SILENT=" --silent" +fi +if test x"$1" = x"--help"; then + echo "usage: ./autogen.sh [--silent] [--force] [--build-TYPE] [ARGS]" + exit 0 +fi +if test x"$1" = x"--silent"; then + SILENT=" --silent" + shift +fi if test x"$1" = x"--force"; then FORCE=" --force" shift fi -# Begin list of optional variables sourced from ~/.gnupg-autogen.rc + +# Reject unsafe characters in $HOME, $tsdir and cwd. We consider spaces +# as unsafe because it is too easy to get scripts wrong in this regard. +am_lf=' +' +case `pwd` in + *[\;\\\"\#\$\&\'\`$am_lf\ \ ]*) + fatal "unsafe working directory name" ;; +esac +case $tsdir in + *[\;\\\"\#\$\&\'\`$am_lf\ \ ]*) + fatal "unsafe source directory: \`$tsdir'" ;; +esac +case $HOME in + *[\;\\\"\#\$\&\'\`$am_lf\ \ ]*) + fatal "unsafe home directory: \`$HOME'" ;; +esac +die_p + + +# List of variables sourced from autogen.rc. The strings '@SYSROOT@' in +# these variables are replaced by the actual system root. +configure_opts= +extraoptions= +# List of optional variables sourced from autogen.rc and ~/.gnupg-autogen.rc w32_toolprefixes= w32_extraoptions= w32ce_toolprefixes= w32ce_extraoptions= +w64_toolprefixes= +w64_extraoptions= amd64_toolprefixes= # End list of optional variables sourced from ~/.gnupg-autogen.rc # What follows are variables which are sourced but default to # environment variables or lacking them hardcoded values. #w32root= #w32ce_root= +#w64root= #amd64root= -if [ -f "$HOME/.gnupg-autogen.rc" ]; then - echo "sourcing extra definitions from $HOME/.gnupg-autogen.rc" - . "$HOME/.gnupg-autogen.rc" -fi - # Convenience option to use certain configure options for some hosts. myhost="" myhostsub="" case "$1" in --build-w32) myhost="w32" + shift ;; --build-w32ce) myhost="w32" myhostsub="ce" + shift ;; --build-w64) myhost="w32" myhostsub="64" + shift ;; --build-amd64) myhost="amd64" + shift ;; --build*) - echo "**Error**: invalid build option $1" >&2 - exit 1 + fatal "**Error**: invalid build option $1" + shift ;; - *) + *) ;; esac +die_p + + +# Source our configuration +if [ -f "${tsdir}/autogen.rc" ]; then + . "${tsdir}/autogen.rc" +fi +# Source optional site specific configuration +if [ -f "$HOME/.gnupg-autogen.rc" ]; then + info "sourcing extra definitions from $HOME/.gnupg-autogen.rc" + . "$HOME/.gnupg-autogen.rc" +fi -# ***** W32 build script ******* -# Used to cross-compile for Windows. +# ****************** +# W32 build script +# ****************** if [ "$myhost" = "w32" ]; then - tmp=`dirname $0` - tsdir=`cd "$tmp"; pwd` - shift - if [ ! -f $tsdir/config.guess ]; then - echo "$tsdir/config.guess not found" >&2 + if [ ! -f "$tsdir/build-aux/config.guess" ]; then + fatal "$tsdir/build-aux/config.guess not found" exit 1 fi - build=`$tsdir/config.guess` + build=`$tsdir/build-aux/config.guess` case $myhostsub in ce) w32root="$w32ce_root" [ -z "$w32root" ] && w32root="$HOME/w32ce_root" - toolprefixes="arm-mingw32ce" + toolprefixes="$w32ce_toolprefixes arm-mingw32ce" + extraoptions="$extraoptions $w32ce_extraoptions" ;; 64) w32root="$w64root" [ -z "$w32root" ] && w32root="$HOME/w64root" - toolprefixes="$amd64_toolprefixes amd64-mingw32msvc" + toolprefixes="$w64_toolprefixes x86_64-w64-mingw32" + extraoptions="$extraoptions $w64_extraoptions" ;; *) [ -z "$w32root" ] && w32root="$HOME/w32root" toolprefixes="$w32_toolprefixes i686-w64-mingw32 i586-mingw32msvc" toolprefixes="$toolprefixes i386-mingw32msvc mingw32" + extraoptions="$extraoptions $w32_extraoptions" ;; esac - echo "Using $w32root as standard install directory" >&2 + info "Using $w32root as standard install directory" + replace_sysroot # Locate the cross compiler crossbindir= @@ -122,48 +215,49 @@ if [ "$myhost" = "w32" ]; then fi done if [ -z "$crossbindir" ]; then - echo "Cross compiler kit not installed" >&2 - if [ -z "$sub" ]; then - echo "Under Debian GNU/Linux, you may install it using" >&2 - echo " apt-get install mingw32 mingw32-runtime mingw32-binutils" >&2 + fatal "cross compiler kit not installed" + if [ -z "$myhostsub" ]; then + info "Under Debian GNU/Linux, you may install it using" + info " apt-get install mingw32 mingw32-runtime mingw32-binutils" fi - echo "Stop." >&2 - exit 1 + die_p fi if [ -f "$tsdir/config.log" ]; then if ! head $tsdir/config.log | grep "$host" >/dev/null; then - echo "Pease run a 'make distclean' first" >&2 - exit 1 + fatal "Please run a 'make distclean' first" + die_p fi fi - $tsdir/configure --enable-maintainer-mode --prefix=${w32root} \ - --host=${host} --build=${build} \ - --with-gpg-error-prefix=${w32root} - exit $? + $tsdir/configure --enable-maintainer-mode ${SILENT} \ + --prefix=${w32root} \ + --host=${host} --build=${build} \ + ${configure_opts} ${extraoptions} "$@" + rc=$? + exit $rc fi # ***** end W32 build script ******* - # ***** AMD64 cross build script ******* # Used to cross-compile for AMD64 (for testing) if [ "$myhost" = "amd64" ]; then - tmp=`dirname $0` - tsdir=`cd "$tmp"; pwd` shift - if [ ! -f $tsdir/config.guess ]; then - echo "$tsdir/config.guess not found" >&2 + if [ ! -f $tsdir/build-aux/config.guess ]; then + echo "$tsdir/build-aux/config.guess not found" >&2 exit 1 fi - build=`$tsdir/config.guess` + build=`$tsdir/build-aux/config.guess` [ -z "$amd64root" ] && amd64root="$HOME/amd64root" - echo "Using $amd64root as standard install directory" >&2 + info "Using $amd64root as standard install directory" + replace_sysroot + + toolprefixes="$amd64_toolprefixes x86_64-linux-gnu amd64-linux-gnu" # Locate the cross compiler crossbindir= - for host in x86_64-linux-gnu amd64-linux-gnu; do + for host in $toolprefixes ; do if ${host}-gcc --version >/dev/null 2>&1 ; then crossbindir=/usr/${host}/bin conf_CC="CC=${host}-gcc" @@ -183,15 +277,16 @@ if [ "$myhost" = "amd64" ]; then fi fi - $tsdir/configure --enable-maintainer-mode --prefix=${amd64root} \ + $tsdir/configure --enable-maintainer-mode ${SILENT} \ + --prefix=${amd64root} \ --host=${host} --build=${build} \ - --with-gpg-error-prefix=${amd64root} - + ${configure_opts} ${extraoptions} "$@" rc=$? exit $rc fi # ***** end AMD64 cross build script ******* + # Grep the required versions from configure.ac autoconf_vers=`sed -n '/^AC_PREREQ(/ { s/^.*(\(.*\))/\1/p @@ -205,29 +300,22 @@ q }' ${configure_ac}` automake_vers_num=`echo "$automake_vers" | cvtver` -#gettext_vers=`sed -n '/^AM_GNU_GETTEXT_VERSION(/ { -#s/^.*(\(.*\))/\1/p -#q -#}' ${configure_ac}` -#gettext_vers_num=`echo "$gettext_vers" | cvtver` - +if [ -d "${tsdir}/po" ]; then + gettext_vers=`sed -n '/^AM_GNU_GETTEXT_VERSION(/ { +s/^.*\[\(.*\)])/\1/p +q +}' ${configure_ac}` + gettext_vers_num=`echo "$gettext_vers" | cvtver` +else + gettext_vers="n/a" +fi -if [ -z "$autoconf_vers" -o -z "$automake_vers" ] +if [ -z "$autoconf_vers" -o -z "$automake_vers" -o -z "$gettext_vers" ] then echo "**Error**: version information not found in "\`${configure_ac}\'"." >&2 exit 1 fi -# Allow to override the default tool names -AUTOCONF=${AUTOCONF_PREFIX}${AUTOCONF:-autoconf}${AUTOCONF_SUFFIX} -AUTOHEADER=${AUTOCONF_PREFIX}${AUTOHEADER:-autoheader}${AUTOCONF_SUFFIX} - -AUTOMAKE=${AUTOMAKE_PREFIX}${AUTOMAKE:-automake}${AUTOMAKE_SUFFIX} -ACLOCAL=${AUTOMAKE_PREFIX}${ACLOCAL:-aclocal}${AUTOMAKE_SUFFIX} - -#GETTEXT=${GETTEXT_PREFIX}${GETTEXT:-gettext}${GETTEXT_SUFFIX} -#MSGMERGE=${GETTEXT_PREFIX}${MSGMERGE:-msgmerge}${GETTEXT_SUFFIX} - if check_version $AUTOCONF $autoconf_vers_num $autoconf_vers ; then check_version $AUTOHEADER $autoconf_vers_num $autoconf_vers autoconf @@ -235,45 +323,71 @@ fi if check_version $AUTOMAKE $automake_vers_num $automake_vers; then check_version $ACLOCAL $automake_vers_num $autoconf_vers automake fi -#if check_version $GETTEXT $gettext_vers_num $gettext_vers; then -# check_version $MSGMERGE $gettext_vers_num $gettext_vers gettext -#fi +if [ "$gettext_vers" != "n/a" ]; then + if check_version $GETTEXT $gettext_vers_num $gettext_vers; then + check_version $MSGMERGE $gettext_vers_num $gettext_vers gettext + fi +fi -if test "$DIE" = "yes"; then +if [ "$DIE" = "yes" ]; then cat <&2 + [ -z "${SILENT}" ] && cat < Date: Thu Jan 9 19:14:09 2014 +0100 Move all helper scripts to build-aux/ * scripts/: Rename to build-aux/. * compile, config.guess, config.rpath, config.sub * depcomp, doc/mdate-sh, doc/texinfo.tex * install-sh, ltmain.sh, missing: Move to build-aux/. * Makefile.am (EXTRA_DIST): Adjust. * configure.ac (AC_CONFIG_AUX_DIR): New. (AM_SILENT_RULES): New. Signed-off-by: Werner Koch (cherry picked from commit df9b4eabf52faee6f289a4bc62219684442ae383) diff --git a/Makefile.am b/Makefile.am index 7fb7b50..8458dd0 100644 --- a/Makefile.am +++ b/Makefile.am @@ -27,11 +27,12 @@ GITLOG_TO_CHANGELOG=gitlog-to-changelog DIST_SUBDIRS = m4 compat mpi cipher random src doc tests SUBDIRS = compat mpi cipher random src doc tests -EXTRA_DIST = autogen.sh README.GIT LICENSES \ - ChangeLog-2011 scripts/ChangeLog-2011 doc/ChangeLog-2011 \ - m4/ChangeLog-2011 cipher/ChangeLog-2011 src/ChangeLog-2011 \ + +EXTRA_DIST = autogen.sh README.GIT LICENSES \ + ChangeLog-2011 build-aux/ChangeLog-2011 doc/ChangeLog-2011 \ + m4/ChangeLog-2011 cipher/ChangeLog-2011 src/ChangeLog-2011 \ random/ChangeLog-2011 tests/ChangeLog-2011 mpi/ChangeLog-2011 \ - scripts/git-log-footer scripts/git-log-fix + build-aux/git-log-footer build-aux/git-log-fix DISTCLEANFILES = @@ -59,9 +60,9 @@ gen-ChangeLog: if test -d $(top_srcdir)/.git; then \ (cd $(top_srcdir) && \ $(GITLOG_TO_CHANGELOG) --append-dot --tear-off \ - --amend=scripts/git-log-fix \ + --amend=build-aux/git-log-fix \ --since=$(gen_start_date) ) > $(distdir)/cl-t; \ - cat $(top_srcdir)/scripts/git-log-footer >> $(distdir)/cl-t; \ + cat $(top_srcdir)/build-aux/git-log-footer >> $(distdir)/cl-t;\ rm -f $(distdir)/ChangeLog; \ mv $(distdir)/cl-t $(distdir)/ChangeLog; \ fi diff --git a/scripts/ChangeLog-2011 b/build-aux/ChangeLog-2011 similarity index 100% rename from scripts/ChangeLog-2011 rename to build-aux/ChangeLog-2011 diff --git a/compile b/build-aux/compile similarity index 100% rename from compile rename to build-aux/compile diff --git a/config.guess b/build-aux/config.guess similarity index 100% rename from config.guess rename to build-aux/config.guess diff --git a/config.rpath b/build-aux/config.rpath similarity index 100% rename from config.rpath rename to build-aux/config.rpath diff --git a/config.sub b/build-aux/config.sub similarity index 100% rename from config.sub rename to build-aux/config.sub diff --git a/scripts/db2any b/build-aux/db2any similarity index 99% rename from scripts/db2any rename to build-aux/db2any index 96606f8..a240aaa 100755 --- a/scripts/db2any +++ b/build-aux/db2any @@ -438,7 +438,7 @@ render_texinfo () { sgml2xml -x lower $input > $tmpxml [ $verbose = yes ] && echo "running docbook2texi on '$tmpxml' ..." >&2 docbook2texi $tmpxml | sed 's,--,---,' >$output - rm $tmpxml + rm $tmpxml [ $verbose = yes ] && echo "texinfo '$output' created" >&2 } diff --git a/depcomp b/build-aux/depcomp similarity index 100% rename from depcomp rename to build-aux/depcomp diff --git a/scripts/distfiles b/build-aux/distfiles similarity index 100% rename from scripts/distfiles rename to build-aux/distfiles diff --git a/scripts/git-log-fix b/build-aux/git-log-fix similarity index 100% rename from scripts/git-log-fix rename to build-aux/git-log-fix diff --git a/scripts/git-log-footer b/build-aux/git-log-footer similarity index 100% rename from scripts/git-log-footer rename to build-aux/git-log-footer diff --git a/install-sh b/build-aux/install-sh similarity index 100% rename from install-sh rename to build-aux/install-sh diff --git a/ltmain.sh b/build-aux/ltmain.sh similarity index 99% rename from ltmain.sh rename to build-aux/ltmain.sh index 24e3fd3..859599a 100644 --- a/ltmain.sh +++ b/build-aux/ltmain.sh @@ -9662,4 +9662,3 @@ build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` # sh-indentation:2 # End: # vi:sw=2 - diff --git a/doc/mdate-sh b/build-aux/mdate-sh similarity index 100% rename from doc/mdate-sh rename to build-aux/mdate-sh diff --git a/missing b/build-aux/missing similarity index 100% rename from missing rename to build-aux/missing diff --git a/doc/texinfo.tex b/build-aux/texinfo.tex similarity index 99% rename from doc/texinfo.tex rename to build-aux/texinfo.tex index 8083622..8f99418 100644 --- a/doc/texinfo.tex +++ b/build-aux/texinfo.tex @@ -310,7 +310,7 @@ % We don't want .vr (or whatever) entries like this: % \entry{{\tt \indexbackslash }acronym}{32}{\code {\acronym}} % "\acronym" won't work when it's read back in; - % it needs to be + % it needs to be % {\code {{\tt \backslashcurfont }acronym} \shipout\vbox{% % Do this early so pdf references go to the beginning of the page. @@ -661,7 +661,7 @@ \def\?{?\spacefactor=\endofsentencespacefactor\space} % @frenchspacing on|off says whether to put extra space after punctuation. -% +% \def\onword{on} \def\offword{off} % @@ -1216,7 +1216,7 @@ where each line of input produces a line of output.} % that's what we do). % double active backslashes. -% +% {\catcode`\@=0 \catcode`\\=\active @gdef at activebackslashdouble{% @catcode`@\=@active @@ -1227,11 +1227,11 @@ where each line of input produces a line of output.} % not active characters. hyperref.dtx (which has the same problem as % us) handles it with this amazing macro to replace tokens. I've % tinkered with it a little for texinfo, but it's definitely from there. -% +% % #1 is the tokens to replace. % #2 is the replacement. % #3 is the control sequence with the string. -% +% \def\HyPsdSubst#1#2#3{% \def\HyPsdReplace##1#1##2\END{% ##1% @@ -1420,7 +1420,7 @@ where each line of input produces a line of output.} % tried to figure out what each command should do in the context % of @url. for now, just make @/ a no-op, that's the only one % people have actually reported a problem with. - % + % \normalturnoffactive \def\@{@}% \let\/=\empty @@ -1547,7 +1547,7 @@ where each line of input produces a line of output.} % Definitions for a main text size of 11pt. This is the default in % Texinfo. -% +% \def\definetextfontsizexi{ % Text fonts (11.2pt, magstep1). \def\textnominalsize{11pt} @@ -1672,7 +1672,7 @@ where each line of input produces a line of output.} % section, chapter, etc., sizes following suit. This is for the GNU % Press printing of the Emacs 22 manual. Maybe other manuals in the % future. Used with @smallbook, which sets the leading to 12pt. -% +% \def\definetextfontsizex{% % Text fonts (10pt). \def\textnominalsize{10pt} @@ -1758,7 +1758,7 @@ where each line of input produces a line of output.} \setfont\secsf\sfbshape{12}{1000} \let\secbf\secrm \setfont\secsc\scbshape{10}{\magstep1} -\font\seci=cmmi12 +\font\seci=cmmi12 \font\secsy=cmsy10 scaled \magstep1 % Subsection fonts (10pt). @@ -1799,7 +1799,7 @@ where each line of input produces a line of output.} % We provide the user-level command % @fonttextsize 10 % (or 11) to redefine the text font size. pt is assumed. -% +% \def\xword{10} \def\xiword{11} % @@ -1809,7 +1809,7 @@ where each line of input produces a line of output.} % % Set \globaldefs so that documents can use this inside @tex, since % makeinfo 4.8 does not support it, but we need it nonetheless. - % + % \begingroup \globaldefs=1 \ifx\textsizearg\xword \definetextfontsizex \else \ifx\textsizearg\xiword \definetextfontsizexi @@ -2094,7 +2094,7 @@ where each line of input produces a line of output.} % each of the four underscores in __typeof__. This is undesirable in % some manuals, especially if they don't have long identifiers in % general. @allowcodebreaks provides a way to control this. -% +% \newif\ifallowcodebreaks \allowcodebreakstrue \def\keywordtrue{true} @@ -2225,7 +2225,7 @@ where each line of input produces a line of output.} % @acronym for "FBI", "NATO", and the like. % We print this one point size smaller, since it's intended for % all-uppercase. -% +% \def\acronym#1{\doacronym #1,,\finish} \def\doacronym#1,#2,#3\finish{% {\selectfonts\lsize #1}% @@ -2237,7 +2237,7 @@ where each line of input produces a line of output.} % @abbr for "Comput. J." and the like. % No font change, but don't do end-of-sentence spacing. -% +% \def\abbr#1{\doabbr #1,,\finish} \def\doabbr#1,#2,#3\finish{% {\plainfrenchspacing #1}% @@ -2256,43 +2256,43 @@ where each line of input produces a line of output.} % Theiling, which support regular, slanted, bold and bold slanted (and % "outlined" (blackboard board, sort of) versions, which we don't need). % It is available from http://www.ctan.org/tex-archive/fonts/eurosym. -% +% % Although only regular is the truly official Euro symbol, we ignore % that. The Euro is designed to be slightly taller than the regular % font height. -% +% % feymr - regular % feymo - slanted % feybr - bold % feybo - bold slanted -% +% % There is no good (free) typewriter version, to my knowledge. % A feymr10 euro is ~7.3pt wide, while a normal cmtt10 char is ~5.25pt wide. % Hmm. -% +% % Also doesn't work in math. Do we need to do math with euro symbols? % Hope not. -% -% +% +% \def\euro{{\eurofont e}} \def\eurofont{% % We set the font at each command, rather than predefining it in % \textfonts and the other font-switching commands, so that % installations which never need the symbol don't have to have the % font installed. - % + % % There is only one designed size (nominal 10pt), so we always scale % that to the current nominal size. - % + % % By the way, simply using "at 1em" works for cmr10 and the like, but % does not work for cmbx10 and other extended/shrunken fonts. - % + % \def\eurosize{\csname\curfontsize nominalsize\endcsname}% % - \ifx\curfontstyle\bfstylename + \ifx\curfontstyle\bfstylename % bold: \font\thiseurofont = \ifusingit{feybo10}{feybr10} at \eurosize - \else + \else % regular: \font\thiseurofont = \ifusingit{feymo10}{feymr10} at \eurosize \fi @@ -2316,7 +2316,7 @@ where each line of input produces a line of output.} % Laurent Siebenmann reports \Orb undefined with: % Textures 1.7.7 (preloaded format=plain 93.10.14) (68K) 16 APR 2004 02:38 % so we'll define it if necessary. -% +% \ifx\Orb\undefined \def\Orb{\mathhexbox20D} \fi @@ -2632,7 +2632,7 @@ where each line of input produces a line of output.} % cause the example and the item to crash together. So we use this % bizarre value of 10001 as a signal to \aboveenvbreak to insert % \parskip glue after all. Section titles are handled this way also. - % + % \penalty 10001 \endgroup \itemxneedsnegativevskipfalse @@ -3428,7 +3428,7 @@ where each line of input produces a line of output.} % processing continues to some further point. On the other hand, it % seems \endinput does not hurt in the printed index arg, since that % is still getting written without apparent harm. - % + % % Sample source (mac-idx3.tex, reported by Graham Percival to % help-texinfo, 22may06): % @macro funindex {WORD} @@ -3436,12 +3436,12 @@ where each line of input produces a line of output.} % @end macro % ... % @funindex commtest - % + % % The above is not enough to reproduce the bug, but it gives the flavor. - % + % % Sample whatsit resulting: % . at write3{\entry{xyz}{@folio }{@code {xyz at endinput }}} - % + % % So: \let\endinput = \empty % @@ -3677,11 +3677,11 @@ where each line of input produces a line of output.} % makeinfo does not expand macros in the argument to @deffn, which ends up % writing an index entry, and texindex isn't prepared for an index sort entry % that starts with \. - % + % % Since macro invocations are followed by braces, we can just redefine them % to take a single TeX argument. The case of a macro invocation that % goes to end-of-line is not handled. - % + % \macrolist } @@ -3807,7 +3807,7 @@ where each line of input produces a line of output.} % to re-insert the same penalty (values >10000 are used for various % signals); since we just inserted a non-discardable item, any % following glue (such as a \parskip) would be a breakpoint. For example: - % + % % @deffn deffn-whatever % @vindex index-whatever % Description. @@ -4759,11 +4759,11 @@ where each line of input produces a line of output.} % glue accumulate. (Not a breakpoint because it's preceded by a % discardable item.) \vskip-\parskip - % + % % This is purely so the last item on the list is a known \penalty > % 10000. This is so \startdefun can avoid allowing breakpoints after % section headings. Otherwise, it would insert a valid breakpoint between: - % + % % @section sec-whatever % @deffn def-whatever \penalty 10001 @@ -4821,7 +4821,7 @@ where each line of input produces a line of output.} % These characters do not print properly in the Computer Modern roman % fonts, so we must take special care. This is more or less redundant % with the Texinfo input format setup at the end of this file. -% +% \def\activecatcodes{% \catcode`\"=\active \catcode`\$=\active @@ -5416,8 +5416,8 @@ where each line of input produces a line of output.} % from cmtt (char 0x0d). The undirected quote is ugly, so don't make it % the default, but it works for pasting with more pdf viewers (at least % evince), the lilypond developers report. xpdf does work with the -% regular 0x27. -% +% regular 0x27. +% \def\codequoteright{% \expandafter\ifx\csname SETcodequoteundirected\endcsname\relax '% @@ -5429,7 +5429,7 @@ where each line of input produces a line of output.} % and a similar option for the left quote char vs. a grave accent. % Modern fonts display ASCII 0x60 as a grave accent, so some people like % the code environments to do likewise. -% +% \def\codequoteleft{% \expandafter\ifx\csname SETcodequotebacktick\endcsname\relax `% @@ -5572,7 +5572,7 @@ where each line of input produces a line of output.} % by \defargscommonending, instead of 10000, since the sectioning % commands also insert a nobreak penalty, and we don't want to allow % a break between a section heading and a defun. - % + % \ifnum\lastpenalty=10002 \penalty2000 \fi % % Similarly, after a section heading, do not allow a break. @@ -5950,7 +5950,7 @@ where each line of input produces a line of output.} % This does \let #1 = #2, with \csnames; that is, % \let \csname#1\endcsname = \csname#2\endcsname % (except of course we have to play expansion games). -% +% \def\cslet#1#2{% \expandafter\let \csname#1\expandafter\endcsname @@ -7420,7 +7420,7 @@ should work if nowhere else does.} % Same as @turnoffactive except outputs \ as {\tt\char`\\} instead of % the literal character `\'. -% +% @def at normalturnoffactive{% @let\=@normalbackslash @let"=@normaldoublequote diff --git a/configure.ac b/configure.ac index c99765c..a47e13e 100644 --- a/configure.ac +++ b/configure.ac @@ -72,6 +72,7 @@ NEED_GPG_ERROR_VERSION=1.11 PACKAGE=$PACKAGE_NAME VERSION=$PACKAGE_VERSION +AC_CONFIG_AUX_DIR([build-aux]) AC_CONFIG_SRCDIR([src/libgcrypt.vers]) AM_INIT_AUTOMAKE AC_CONFIG_HEADER(config.h) @@ -79,6 +80,7 @@ AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_LIBOBJ_DIR([compat]) AC_CANONICAL_HOST AM_MAINTAINER_MODE +AM_SILENT_RULES AH_TOP([ #ifndef _GCRYPT_CONFIG_H_INCLUDED diff --git a/doc/gcrypt.texi b/doc/gcrypt.texi index dc42950..38af0c6 100644 --- a/doc/gcrypt.texi +++ b/doc/gcrypt.texi @@ -2798,9 +2798,11 @@ supported parameters are: @table @code @item nbits -This is always required to specify the length of the key. The argument -is a string with a number in C-notation. The value should be a multiple -of 8. +This is always required to specify the length of the key. The +argument is a string with a number in C-notation. The value should be +a multiple of 8. Note that the S-expression syntax requires that a +number is prefixed with its string length; thus the @code{4:} in the +above example. @item curve @var{name} For ECC a named curve may be used instead of giving the number of ----------------------------------------------------------------------- Summary of changes: Makefile.am | 13 +- autogen.rc | 17 ++ autogen.sh | 276 ++++++++++++++++++++++---------- {scripts => build-aux}/ChangeLog-2011 | 0 compile => build-aux/compile | 0 config.guess => build-aux/config.guess | 0 config.rpath => build-aux/config.rpath | 0 config.sub => build-aux/config.sub | 0 {scripts => build-aux}/db2any | 2 +- depcomp => build-aux/depcomp | 0 {scripts => build-aux}/distfiles | 0 {scripts => build-aux}/git-log-fix | 0 {scripts => build-aux}/git-log-footer | 0 install-sh => build-aux/install-sh | 0 ltmain.sh => build-aux/ltmain.sh | 1 - {doc => build-aux}/mdate-sh | 0 missing => build-aux/missing | 0 {doc => build-aux}/texinfo.tex | 86 +++++----- configure.ac | 2 + doc/gcrypt.texi | 8 +- 20 files changed, 270 insertions(+), 135 deletions(-) create mode 100644 autogen.rc rename {scripts => build-aux}/ChangeLog-2011 (100%) rename compile => build-aux/compile (100%) rename config.guess => build-aux/config.guess (100%) rename config.rpath => build-aux/config.rpath (100%) rename config.sub => build-aux/config.sub (100%) rename {scripts => build-aux}/db2any (99%) rename depcomp => build-aux/depcomp (100%) rename {scripts => build-aux}/distfiles (100%) rename {scripts => build-aux}/git-log-fix (100%) rename {scripts => build-aux}/git-log-footer (100%) rename install-sh => build-aux/install-sh (100%) rename ltmain.sh => build-aux/ltmain.sh (99%) rename {doc => build-aux}/mdate-sh (100%) rename missing => build-aux/missing (100%) rename {doc => build-aux}/texinfo.tex (99%) hooks/post-receive -- The GNU crypto library http://git.gnupg.org From cvs at cvs.gnupg.org Fri Jan 10 17:33:31 2014 From: cvs at cvs.gnupg.org (by Werner Koch) Date: Fri, 10 Jan 2014 17:33:31 +0100 Subject: [git] Assuan - branch, master, updated. libassuan-2.1.1-5-ga5a6aea Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "IPC library used by GnuPG". The branch, master has been updated via a5a6aea1ef063b9c6801b5f5ff482b7599ec4b2e (commit) via a9c9aaca70c770cf5f9d05ce2417343490e45627 (commit) from e78abe490ff6806f8083b23075ae036e5894513a (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit a5a6aea1ef063b9c6801b5f5ff482b7599ec4b2e Author: Werner Koch Date: Thu Jan 9 19:14:09 2014 +0100 Use the generic autogen.sh script. * autogen.rc: New. * Makefile.am (EXTRA_DIST): Add it. * autogen.sh: Update from GnuPG. diff --git a/Makefile.am b/Makefile.am index 8ab5547..15b1533 100644 --- a/Makefile.am +++ b/Makefile.am @@ -24,7 +24,7 @@ AUTOMAKE_OPTIONS = dist-bzip2 no-dist-gzip # (A suitable gitlog-to-changelog script can be found in GnuPG master.) GITLOG_TO_CHANGELOG=gitlog-to-changelog -EXTRA_DIST = autogen.sh README.GIT \ +EXTRA_DIST = autogen.sh autogen.rc README.GIT \ ChangeLog-2011 doc/ChangeLog-2011 src/ChangeLog-2011 \ tests/ChangeLog-2011 contrib/ChangeLog-2011 \ build-aux/git-log-footer build-aux/git-log-fix diff --git a/autogen.rc b/autogen.rc new file mode 100644 index 0000000..37e4321 --- /dev/null +++ b/autogen.rc @@ -0,0 +1,17 @@ +# autogen.sh configuration for Libassuan -*- sh -*- + +case "$myhost" in + w32) + configure_opts=" + --with-gpg-error-prefix=@SYSROOT@ + " + ;; + + amd64) + configure_opts=" + --with-gpg-error-prefix=@SYSROOT@ + " + ;; +esac + +final_info="./configure --enable-maintainer-mode && make" diff --git a/autogen.sh b/autogen.sh index 3e12b86..471193c 100755 --- a/autogen.sh +++ b/autogen.sh @@ -1,7 +1,6 @@ #! /bin/sh -# Run this to generate all the initial makefiles, etc. -# -# Copyright (C) 2003 g10 Code GmbH +# autogen.sh +# Copyright (C) 2003, 2014 g10 Code GmbH # # This file is free software; as a special exception the author gives # unlimited permission to copy and/or distribute it, with or without @@ -10,6 +9,13 @@ # This program 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. +# +# This is a generic script to create the configure script and handle cross +# build environments. It requires the presence of a autogen.rc file to +# configure it for the respective package. It is maintained as part of +# GnuPG and source copied by other packages. +# +# Version: 2014-01-10 configure_ac="configure.ac" @@ -18,7 +24,7 @@ cvtver () { } check_version () { - if [ `("$1" --version || echo "0") | cvtver` -ge "$2" ]; then + if [ $(( `("$1" --version || echo "0") | cvtver` >= $2 )) = 1 ]; then return 0 fi echo "**Error**: "\`$1\'" not installed or too old." >&2 @@ -28,15 +34,86 @@ check_version () { return 1 } +fatal () { + echo "autogen.sh:" "$*" >&2 + DIE=yes +} + +info () { + if [ -z "${SILENT}" ]; then + echo "autogen.sh:" "$*" + fi +} + +die_p () { + if [ "$DIE" = "yes" ]; then + echo "autogen.sh: Stop." >&2 + exit 1 + fi +} + +replace_sysroot () { + configure_opts=$(echo $configure_opts | sed "s#@SYSROOT@#${w32root}#g") + extraoptions=$(echo $extraoptions | sed "s#@SYSROOT@#${w32root}#g") +} + +# Allow to override the default tool names +AUTOCONF=${AUTOCONF_PREFIX}${AUTOCONF:-autoconf}${AUTOCONF_SUFFIX} +AUTOHEADER=${AUTOCONF_PREFIX}${AUTOHEADER:-autoheader}${AUTOCONF_SUFFIX} + +AUTOMAKE=${AUTOMAKE_PREFIX}${AUTOMAKE:-automake}${AUTOMAKE_SUFFIX} +ACLOCAL=${AUTOMAKE_PREFIX}${ACLOCAL:-aclocal}${AUTOMAKE_SUFFIX} + +GETTEXT=${GETTEXT_PREFIX}${GETTEXT:-gettext}${GETTEXT_SUFFIX} +MSGMERGE=${GETTEXT_PREFIX}${MSGMERGE:-msgmerge}${GETTEXT_SUFFIX} DIE=no FORCE= +SILENT= +tmp=$(dirname "$0") +tsdir=$(cd "${tmp}"; pwd) + +if [ -n "${AUTOGEN_SH_SILENT}" ]; then + SILENT=" --silent" +fi +if test x"$1" = x"--help"; then + echo "usage: ./autogen.sh [--silent] [--force] [--build-TYPE] [ARGS]" + exit 0 +fi +if test x"$1" = x"--silent"; then + SILENT=" --silent" + shift +fi if test x"$1" = x"--force"; then FORCE=" --force" shift fi -# Begin list of optional variables sourced from ~/.gnupg-autogen.rc + +# Reject unsafe characters in $HOME, $tsdir and cwd. We consider spaces +# as unsafe because it is too easy to get scripts wrong in this regard. +am_lf=' +' +case `pwd` in + *[\;\\\"\#\$\&\'\`$am_lf\ \ ]*) + fatal "unsafe working directory name" ;; +esac +case $tsdir in + *[\;\\\"\#\$\&\'\`$am_lf\ \ ]*) + fatal "unsafe source directory: \`$tsdir'" ;; +esac +case $HOME in + *[\;\\\"\#\$\&\'\`$am_lf\ \ ]*) + fatal "unsafe home directory: \`$HOME'" ;; +esac +die_p + + +# List of variables sourced from autogen.rc. The strings '@SYSROOT@' in +# these variables are replaced by the actual system root. +configure_opts= +extraoptions= +# List of optional variables sourced from autogen.rc and ~/.gnupg-autogen.rc w32_toolprefixes= w32_extraoptions= w32ce_toolprefixes= @@ -52,69 +129,83 @@ amd64_toolprefixes= #w64root= #amd64root= -if [ -f "$HOME/.gnupg-autogen.rc" ]; then - echo "sourcing extra definitions from $HOME/.gnupg-autogen.rc" - . "$HOME/.gnupg-autogen.rc" -fi - # Convenience option to use certain configure options for some hosts. myhost="" myhostsub="" case "$1" in --build-w32) myhost="w32" + shift ;; --build-w32ce) myhost="w32" myhostsub="ce" + shift ;; --build-w64) myhost="w32" myhostsub="64" + shift ;; --build-amd64) myhost="amd64" + shift ;; --build*) - echo "**Error**: invalid build option $1" >&2 - exit 1 + fatal "**Error**: invalid build option $1" + shift ;; *) ;; esac +die_p + +# Source our configuration +if [ -f "${tsdir}/autogen.rc" ]; then + . "${tsdir}/autogen.rc" +fi + +# Source optional site specific configuration +if [ -f "$HOME/.gnupg-autogen.rc" ]; then + info "sourcing extra definitions from $HOME/.gnupg-autogen.rc" + . "$HOME/.gnupg-autogen.rc" +fi -# ***** W32 build script ******* -# Used to cross-compile for Windows. +# ****************** +# W32 build script +# ****************** if [ "$myhost" = "w32" ]; then - tmp=`dirname $0` - tsdir=`cd "$tmp"; pwd` - shift - if [ ! -f $tsdir/config.guess ]; then - echo "$tsdir/config.guess not found" >&2 + if [ ! -f "$tsdir/build-aux/config.guess" ]; then + fatal "$tsdir/build-aux/config.guess not found" exit 1 fi - build=`$tsdir/config.guess` + build=`$tsdir/build-aux/config.guess` case $myhostsub in ce) w32root="$w32ce_root" [ -z "$w32root" ] && w32root="$HOME/w32ce_root" - toolprefixes="arm-mingw32ce" + toolprefixes="$w32ce_toolprefixes arm-mingw32ce" + extraoptions="$extraoptions $w32ce_extraoptions" ;; 64) w32root="$w64root" [ -z "$w32root" ] && w32root="$HOME/w64root" toolprefixes="$w64_toolprefixes x86_64-w64-mingw32" + extraoptions="$extraoptions $w64_extraoptions" ;; *) [ -z "$w32root" ] && w32root="$HOME/w32root" toolprefixes="$w32_toolprefixes i686-w64-mingw32 i586-mingw32msvc" toolprefixes="$toolprefixes i386-mingw32msvc mingw32" + extraoptions="$extraoptions $w32_extraoptions" ;; esac - echo "Using $w32root as standard install directory" >&2 + info "Using $w32root as standard install directory" + replace_sysroot + # Locate the cross compiler crossbindir= for host in $toolprefixes; do if ${host}-gcc --version >/dev/null 2>&1 ; then @@ -124,49 +215,49 @@ if [ "$myhost" = "w32" ]; then fi done if [ -z "$crossbindir" ]; then - echo "Cross compiler kit not installed" >&2 + fatal "cross compiler kit not installed" if [ -z "$myhostsub" ]; then - echo "Under Debian GNU/Linux, you may install it using" >&2 - echo " apt-get install mingw32 mingw32-runtime mingw32-binutils" >&2 + info "Under Debian GNU/Linux, you may install it using" + info " apt-get install mingw32 mingw32-runtime mingw32-binutils" fi - echo "Stop." >&2 - exit 1 + die_p fi if [ -f "$tsdir/config.log" ]; then if ! head $tsdir/config.log | grep "$host" >/dev/null; then - echo "Pease run a 'make distclean' first" >&2 - exit 1 + fatal "Please run a 'make distclean' first" + die_p fi fi - $tsdir/configure --enable-maintainer-mode --prefix=${w32root} \ - --host=${host} --build=${build} \ - --with-gpg-error-prefix=${w32root} "$@" - - exit $? + $tsdir/configure --enable-maintainer-mode ${SILENT} \ + --prefix=${w32root} \ + --host=${host} --build=${build} \ + ${configure_opts} ${extraoptions} "$@" + rc=$? + exit $rc fi # ***** end W32 build script ******* - # ***** AMD64 cross build script ******* # Used to cross-compile for AMD64 (for testing) if [ "$myhost" = "amd64" ]; then - tmp=`dirname $0` - tsdir=`cd "$tmp"; pwd` shift - if [ ! -f $tsdir/config.guess ]; then - echo "$tsdir/config.guess not found" >&2 + if [ ! -f $tsdir/build-aux/config.guess ]; then + echo "$tsdir/build-aux/config.guess not found" >&2 exit 1 fi - build=`$tsdir/config.guess` + build=`$tsdir/build-aux/config.guess` [ -z "$amd64root" ] && amd64root="$HOME/amd64root" - echo "Using $amd64root as standard install directory" >&2 + info "Using $amd64root as standard install directory" + replace_sysroot + + toolprefixes="$amd64_toolprefixes x86_64-linux-gnu amd64-linux-gnu" # Locate the cross compiler crossbindir= - for host in x86_64-linux-gnu amd64-linux-gnu; do + for host in $toolprefixes ; do if ${host}-gcc --version >/dev/null 2>&1 ; then crossbindir=/usr/${host}/bin conf_CC="CC=${host}-gcc" @@ -186,15 +277,16 @@ if [ "$myhost" = "amd64" ]; then fi fi - $tsdir/configure --enable-maintainer-mode --prefix=${amd64root} \ - --host=${host} --build=${build} + $tsdir/configure --enable-maintainer-mode ${SILENT} \ + --prefix=${amd64root} \ + --host=${host} --build=${build} \ + ${configure_opts} ${extraoptions} "$@" rc=$? exit $rc fi # ***** end AMD64 cross build script ******* - # Grep the required versions from configure.ac autoconf_vers=`sed -n '/^AC_PREREQ(/ { s/^.*(\(.*\))/\1/p @@ -208,29 +300,22 @@ q }' ${configure_ac}` automake_vers_num=`echo "$automake_vers" | cvtver` -#gettext_vers=`sed -n '/^AM_GNU_GETTEXT_VERSION(/ { -#s/^.*(\(.*\))/\1/p -#q -#}' ${configure_ac}` -#gettext_vers_num=`echo "$gettext_vers" | cvtver` - +if [ -d "${tsdir}/po" ]; then + gettext_vers=`sed -n '/^AM_GNU_GETTEXT_VERSION(/ { +s/^.*\[\(.*\)])/\1/p +q +}' ${configure_ac}` + gettext_vers_num=`echo "$gettext_vers" | cvtver` +else + gettext_vers="n/a" +fi -if [ -z "$autoconf_vers" -o -z "$automake_vers" ] +if [ -z "$autoconf_vers" -o -z "$automake_vers" -o -z "$gettext_vers" ] then echo "**Error**: version information not found in "\`${configure_ac}\'"." >&2 exit 1 fi -# Allow to override the default tool names -AUTOCONF=${AUTOCONF_PREFIX}${AUTOCONF:-autoconf}${AUTOCONF_SUFFIX} -AUTOHEADER=${AUTOCONF_PREFIX}${AUTOHEADER:-autoheader}${AUTOCONF_SUFFIX} - -AUTOMAKE=${AUTOMAKE_PREFIX}${AUTOMAKE:-automake}${AUTOMAKE_SUFFIX} -ACLOCAL=${AUTOMAKE_PREFIX}${ACLOCAL:-aclocal}${AUTOMAKE_SUFFIX} - -#GETTEXT=${GETTEXT_PREFIX}${GETTEXT:-gettext}${GETTEXT_SUFFIX} -#MSGMERGE=${GETTEXT_PREFIX}${MSGMERGE:-msgmerge}${GETTEXT_SUFFIX} - if check_version $AUTOCONF $autoconf_vers_num $autoconf_vers ; then check_version $AUTOHEADER $autoconf_vers_num $autoconf_vers autoconf @@ -238,52 +323,71 @@ fi if check_version $AUTOMAKE $automake_vers_num $automake_vers; then check_version $ACLOCAL $automake_vers_num $autoconf_vers automake fi -#if check_version $GETTEXT $gettext_vers_num $gettext_vers; then -# check_version $MSGMERGE $gettext_vers_num $gettext_vers gettext -#fi +if [ "$gettext_vers" != "n/a" ]; then + if check_version $GETTEXT $gettext_vers_num $gettext_vers; then + check_version $MSGMERGE $gettext_vers_num $gettext_vers gettext + fi +fi -if test "$DIE" = "yes"; then +if [ "$DIE" = "yes" ]; then cat <&2 + [ -z "${SILENT}" ] && cat <&2 + [ -z "${SILENT}" ] && cat < Date: Thu Jan 9 19:14:09 2014 +0100 Move helper scripts to build-aux. * compile, config.guess, config.rpath, config.sub, depcomp, ltmain.sh * doc/mdate-sh, doc/texinfo.tex, install-sh, missing: Move to build-aux/. * Makefile.am (EXTRA_DIST): Remove config.rpath - it is implicitly distributed. * configure.ac (AC_CONFIG_AUX_DIR): New. (AM_SILENT_RULES): New. diff --git a/Makefile.am b/Makefile.am index 7b328f1..8ab5547 100644 --- a/Makefile.am +++ b/Makefile.am @@ -24,7 +24,7 @@ AUTOMAKE_OPTIONS = dist-bzip2 no-dist-gzip # (A suitable gitlog-to-changelog script can be found in GnuPG master.) GITLOG_TO_CHANGELOG=gitlog-to-changelog -EXTRA_DIST = config.rpath autogen.sh README.GIT \ +EXTRA_DIST = autogen.sh README.GIT \ ChangeLog-2011 doc/ChangeLog-2011 src/ChangeLog-2011 \ tests/ChangeLog-2011 contrib/ChangeLog-2011 \ build-aux/git-log-footer build-aux/git-log-fix diff --git a/compile b/build-aux/compile similarity index 100% rename from compile rename to build-aux/compile diff --git a/config.guess b/build-aux/config.guess similarity index 100% rename from config.guess rename to build-aux/config.guess diff --git a/config.rpath b/build-aux/config.rpath similarity index 100% rename from config.rpath rename to build-aux/config.rpath diff --git a/config.sub b/build-aux/config.sub similarity index 100% rename from config.sub rename to build-aux/config.sub diff --git a/depcomp b/build-aux/depcomp similarity index 100% rename from depcomp rename to build-aux/depcomp diff --git a/install-sh b/build-aux/install-sh similarity index 100% rename from install-sh rename to build-aux/install-sh diff --git a/ltmain.sh b/build-aux/ltmain.sh similarity index 99% rename from ltmain.sh rename to build-aux/ltmain.sh index 07bf696..f8c3614 100755 --- a/ltmain.sh +++ b/build-aux/ltmain.sh @@ -9675,4 +9675,3 @@ build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` # sh-indentation:2 # End: # vi:sw=2 - diff --git a/doc/mdate-sh b/build-aux/mdate-sh similarity index 100% rename from doc/mdate-sh rename to build-aux/mdate-sh diff --git a/missing b/build-aux/missing similarity index 100% rename from missing rename to build-aux/missing diff --git a/doc/texinfo.tex b/build-aux/texinfo.tex similarity index 99% rename from doc/texinfo.tex rename to build-aux/texinfo.tex index 60148b7..13ee0e4 100644 --- a/doc/texinfo.tex +++ b/build-aux/texinfo.tex @@ -20,7 +20,7 @@ % General Public License for more details. % % You should have received a copy of the GNU General Public License -% along with this texinfo.tex file; see the file COPYING. If not, +% along with this texinfo.tex file; see the file COPYING. If not, % see . % % As a special exception, when this file is read by TeX when processing @@ -1932,7 +1932,7 @@ where each line of input produces a line of output.} % @acronym for "FBI", "NATO", and the like. % We print this one point size smaller, since it's intended for % all-uppercase. -% +% \def\acronym#1{\doacronym #1,,\finish} \def\doacronym#1,#2,#3\finish{% {\selectfonts\lsize #1}% @@ -1944,7 +1944,7 @@ where each line of input produces a line of output.} % @abbr for "Comput. J." and the like. % No font change, but don't do end-of-sentence spacing. -% +% \def\abbr#1{\doabbr #1,,\finish} \def\doabbr#1,#2,#3\finish{% {\frenchspacing #1}% @@ -1971,7 +1971,7 @@ where each line of input produces a line of output.} % Laurent Siebenmann reports \Orb undefined with: % Textures 1.7.7 (preloaded format=plain 93.10.14) (68K) 16 APR 2004 02:38 % so we'll define it if necessary. -% +% \ifx\Orb\undefined \def\Orb{\mathhexbox20D} \fi @@ -2287,7 +2287,7 @@ where each line of input produces a line of output.} % cause the example and the item to crash together. So we use this % bizarre value of 10001 as a signal to \aboveenvbreak to insert % \parskip glue after all. Section titles are handled this way also. - % + % \penalty 10001 \endgroup \itemxneedsnegativevskipfalse @@ -3437,7 +3437,7 @@ where each line of input produces a line of output.} % to re-insert the same penalty (values >10000 are used for various % signals); since we just inserted a non-discardable item, any % following glue (such as a \parskip) would be a breakpoint. For example: - % + % % @deffn deffn-whatever % @vindex index-whatever % Description. @@ -4377,11 +4377,11 @@ where each line of input produces a line of output.} % glue accumulate. (Not a breakpoint because it's preceded by a % discardable item.) \vskip-\parskip - % + % % This is purely so the last item on the list is a known \penalty > % 10000. This is so \startdefun can avoid allowing breakpoints after % section headings. Otherwise, it would insert a valid breakpoint between: - % + % % @section sec-whatever % @deffn def-whatever \penalty 10001 @@ -5129,7 +5129,7 @@ where each line of input produces a line of output.} % by \defargscommonending, instead of 10000, since the sectioning % commands also insert a nobreak penalty, and we don't want to allow % a break between a section heading and a defun. - % + % \ifnum\lastpenalty=10002 \penalty2000 \fi % % Similarly, after a section heading, do not allow a break. @@ -5497,7 +5497,7 @@ where each line of input produces a line of output.} % This does \let #1 = #2, with \csnames; that is, % \let \csname#1\endcsname = \csname#2\endcsname % (except of course we have to play expansion games). -% +% \def\cslet#1#2{% \expandafter\let \csname#1\expandafter\endcsname @@ -5750,11 +5750,11 @@ where each line of input produces a line of output.} % is the best we can do for now. makeinfo does not expand macros in the % argument to @deffn, which ends up writing an index entry, and texindex % isn't prepared for an index sort entry that starts with \. -% +% % Since macro invocations are followed by braces, we can just redefine them % to take a single TeX argument. The case of a macro invocation that % goes to end-of-line is not handled. -% +% \def\emptyusermacros{\begingroup \def\do##1{\let\noexpand##1=\noexpand\asis}% \edef\next{\macrolist}\expandafter\endgroup\next} diff --git a/configure.ac b/configure.ac index de2347f..2e3b197 100644 --- a/configure.ac +++ b/configure.ac @@ -70,12 +70,14 @@ AC_SUBST(LIBASSUAN_LT_REVISION) PACKAGE=$PACKAGE_NAME VERSION=$PACKAGE_VERSION +AC_CONFIG_AUX_DIR([build-aux]) AM_INIT_AUTOMAKE AM_MAINTAINER_MODE AC_CONFIG_SRCDIR(src/assuan.h.in) AC_CONFIG_MACRO_DIR(m4) AM_CONFIG_HEADER(config.h) AC_CANONICAL_HOST +AM_SILENT_RULES AB_INIT AC_GNU_SOURCE ----------------------------------------------------------------------- Summary of changes: Makefile.am | 2 +- autogen.rc | 17 ++ autogen.sh | 264 ++++++++++++++++++++++---------- compile => build-aux/compile | 0 config.guess => build-aux/config.guess | 0 config.rpath => build-aux/config.rpath | 0 config.sub => build-aux/config.sub | 0 depcomp => build-aux/depcomp | 0 install-sh => build-aux/install-sh | 0 ltmain.sh => build-aux/ltmain.sh | 1 - {doc => build-aux}/mdate-sh | 0 missing => build-aux/missing | 0 {doc => build-aux}/texinfo.tex | 24 +-- configure.ac | 2 + 14 files changed, 216 insertions(+), 94 deletions(-) create mode 100644 autogen.rc rename compile => build-aux/compile (100%) rename config.guess => build-aux/config.guess (100%) rename config.rpath => build-aux/config.rpath (100%) rename config.sub => build-aux/config.sub (100%) rename depcomp => build-aux/depcomp (100%) rename install-sh => build-aux/install-sh (100%) rename ltmain.sh => build-aux/ltmain.sh (99%) rename {doc => build-aux}/mdate-sh (100%) rename missing => build-aux/missing (100%) rename {doc => build-aux}/texinfo.tex (99%) hooks/post-receive -- IPC library used by GnuPG http://git.gnupg.org From cvs at cvs.gnupg.org Fri Jan 10 17:34:36 2014 From: cvs at cvs.gnupg.org (by Werner Koch) Date: Fri, 10 Jan 2014 17:34:36 +0100 Subject: [git] KSBA - branch, master, updated. libksba-1.3.0-10-gf73e671 Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "KSBA is a library to access X.509 certificates and CMS data.". The branch, master has been updated via f73e671406eefa96aba98f609cb68a9caae6bb7a (commit) via 3943ea7f7dd739dc2c259b76a569a46259d47c43 (commit) from 629c1f0b16b12418711516de3bef5298ab45fe12 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit f73e671406eefa96aba98f609cb68a9caae6bb7a Author: Werner Koch Date: Thu Jan 9 19:14:09 2014 +0100 Remove cruft. * autogen.rc: Remove cruft. diff --git a/autogen.rc b/autogen.rc index 0fb2b6f..850d4e7 100644 --- a/autogen.rc +++ b/autogen.rc @@ -5,7 +5,7 @@ case "$myhost:$myhostsub" in extraoptions= ;; w32:) - extraoptions="--enable-gpgtar" + extraoptions= ;; esac commit 3943ea7f7dd739dc2c259b76a569a46259d47c43 Author: Werner Koch Date: Thu Jan 9 19:14:09 2014 +0100 Use the generic autogen.sh script. * Makefile.am (EXTRA_DIST): Add autogen.rc. * autogen.rc: New. * autogen.sh: Update from current GnuPG. * ltmain.sh: Move to build-aux/. * compile: Ditto. * config.guess: Ditto. * config.sub: Ditto. * depcomp: Ditto. * doc/mdate-sh: Ditto. * doc/texinfo.tex: Ditto. * install-sh: Ditto. * missing: Ditto. * ylwrap: Ditto. * configure.ac (AC_CONFIG_AUX_DIR): New. diff --git a/Makefile.am b/Makefile.am index 5f9f9de..c797e4f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -24,7 +24,8 @@ AUTOMAKE_OPTIONS = dist-bzip2 no-dist-gzip # (A suitable gitlog-to-changelog script can be found in GnuPG master.) GITLOG_TO_CHANGELOG=gitlog-to-changelog -EXTRA_DIST = autogen.sh COPYING.GPLv2 COPYING.GPLv3 COPYING.LGPLv3 \ +EXTRA_DIST = autogen.sh autogen.rc \ + COPYING.GPLv2 COPYING.GPLv3 COPYING.LGPLv3 \ ChangeLog-2011 doc/ChangeLog-2011 src/ChangeLog-2011 \ tests/ChangeLog-2011 \ build-aux/git-log-footer build-aux/git-log-fix diff --git a/autogen.rc b/autogen.rc new file mode 100644 index 0000000..0fb2b6f --- /dev/null +++ b/autogen.rc @@ -0,0 +1,29 @@ +# autogen.sh configuration for GnuPG -*- sh -*- + +case "$myhost:$myhostsub" in + w32:ce) + extraoptions= + ;; + w32:) + extraoptions="--enable-gpgtar" + ;; +esac + +case "$myhost" in + w32) + configure_opts=" + --with-gpg-error-prefix=@SYSROOT@ + " + ;; + + amd64) + configure_opts=" + --with-gpg-error-prefix=@SYSROOT@ + " + ;; +esac + + +extra_aclocal_flags="-I gl/m4" + +final_info="./configure --enable-maintainer-mode && make" diff --git a/autogen.sh b/autogen.sh index 8f6c953..ea3d5fc 100755 --- a/autogen.sh +++ b/autogen.sh @@ -1,7 +1,6 @@ #! /bin/sh -# Run this to generate all the initial makefiles, etc. -# -# Copyright (C) 2003 g10 Code GmbH +# autogen.sh +# Copyright (C) 2003, 2014 g10 Code GmbH # # This file is free software; as a special exception the author gives # unlimited permission to copy and/or distribute it, with or without @@ -10,6 +9,13 @@ # This program 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. +# +# This is a generic script to create the configure script and handle cross +# build environments. It requires the presence of a autogen.rc file to +# configure it for the respective package. It is maintained as part of +# GnuPG and source copied by other packages. +# +# Version: 2014-01-10 configure_ac="configure.ac" @@ -18,7 +24,7 @@ cvtver () { } check_version () { - if [ `("$1" --version || echo "0") | cvtver` -ge "$2" ]; then + if [ $(( `("$1" --version || echo "0") | cvtver` >= $2 )) = 1 ]; then return 0 fi echo "**Error**: "\`$1\'" not installed or too old." >&2 @@ -28,85 +34,172 @@ check_version () { return 1 } +fatal () { + echo "autogen.sh:" "$*" >&2 + DIE=yes +} + +info () { + if [ -z "${SILENT}" ]; then + echo "autogen.sh:" "$*" + fi +} + +die_p () { + if [ "$DIE" = "yes" ]; then + echo "autogen.sh: Stop." >&2 + exit 1 + fi +} + +replace_sysroot () { + configure_opts=$(echo $configure_opts | sed "s#@SYSROOT@#${w32root}#g") + extraoptions=$(echo $extraoptions | sed "s#@SYSROOT@#${w32root}#g") +} + +# Allow to override the default tool names +AUTOCONF=${AUTOCONF_PREFIX}${AUTOCONF:-autoconf}${AUTOCONF_SUFFIX} +AUTOHEADER=${AUTOCONF_PREFIX}${AUTOHEADER:-autoheader}${AUTOCONF_SUFFIX} + +AUTOMAKE=${AUTOMAKE_PREFIX}${AUTOMAKE:-automake}${AUTOMAKE_SUFFIX} +ACLOCAL=${AUTOMAKE_PREFIX}${ACLOCAL:-aclocal}${AUTOMAKE_SUFFIX} + +GETTEXT=${GETTEXT_PREFIX}${GETTEXT:-gettext}${GETTEXT_SUFFIX} +MSGMERGE=${GETTEXT_PREFIX}${MSGMERGE:-msgmerge}${GETTEXT_SUFFIX} + DIE=no FORCE= +SILENT= +tmp=$(dirname "$0") +tsdir=$(cd "${tmp}"; pwd) + +if [ -n "${AUTOGEN_SH_SILENT}" ]; then + SILENT=" --silent" +fi +if test x"$1" = x"--help"; then + echo "usage: ./autogen.sh [--silent] [--force] [--build-TYPE] [ARGS]" + exit 0 +fi +if test x"$1" = x"--silent"; then + SILENT=" --silent" + shift +fi if test x"$1" = x"--force"; then FORCE=" --force" shift fi -# Begin list of optional variables sourced from ~/.gnupg-autogen.rc + +# Reject unsafe characters in $HOME, $tsdir and cwd. We consider spaces +# as unsafe because it is too easy to get scripts wrong in this regard. +am_lf=' +' +case `pwd` in + *[\;\\\"\#\$\&\'\`$am_lf\ \ ]*) + fatal "unsafe working directory name" ;; +esac +case $tsdir in + *[\;\\\"\#\$\&\'\`$am_lf\ \ ]*) + fatal "unsafe source directory: \`$tsdir'" ;; +esac +case $HOME in + *[\;\\\"\#\$\&\'\`$am_lf\ \ ]*) + fatal "unsafe home directory: \`$HOME'" ;; +esac +die_p + + +# List of variables sourced from autogen.rc. The strings '@SYSROOT@' in +# these variables are replaced by the actual system root. +configure_opts= +extraoptions= +# List of optional variables sourced from autogen.rc and ~/.gnupg-autogen.rc w32_toolprefixes= w32_extraoptions= w32ce_toolprefixes= w32ce_extraoptions= +w64_toolprefixes= +w64_extraoptions= amd64_toolprefixes= # End list of optional variables sourced from ~/.gnupg-autogen.rc # What follows are variables which are sourced but default to # environment variables or lacking them hardcoded values. #w32root= #w32ce_root= +#w64root= #amd64root= -if [ -f "$HOME/.gnupg-autogen.rc" ]; then - echo "sourcing extra definitions from $HOME/.gnupg-autogen.rc" - . "$HOME/.gnupg-autogen.rc" -fi - # Convenience option to use certain configure options for some hosts. myhost="" myhostsub="" case "$1" in --build-w32) myhost="w32" + shift ;; --build-w32ce) myhost="w32" myhostsub="ce" + shift ;; --build-w64) myhost="w32" myhostsub="64" + shift + ;; + --build-amd64) + myhost="amd64" + shift ;; --build*) - echo "**Error**: invalid build option $1" >&2 - exit 1 + fatal "**Error**: invalid build option $1" + shift ;; *) ;; esac +die_p + + +# Source our configuration +if [ -f "${tsdir}/autogen.rc" ]; then + . "${tsdir}/autogen.rc" +fi +# Source optional site specific configuration +if [ -f "$HOME/.gnupg-autogen.rc" ]; then + info "sourcing extra definitions from $HOME/.gnupg-autogen.rc" + . "$HOME/.gnupg-autogen.rc" +fi -# ***** W32 build script ******* -# Used to cross-compile for Windows. +# ****************** +# W32 build script +# ****************** if [ "$myhost" = "w32" ]; then - tmp=`dirname $0` - tsdir=`cd "$tmp"; pwd` - shift - if [ ! -f $tsdir/config.guess ]; then - echo "$tsdir/config.guess not found" >&2 + if [ ! -f "$tsdir/build-aux/config.guess" ]; then + fatal "$tsdir/build-aux/config.guess not found" exit 1 fi - build=`$tsdir/config.guess` + build=`$tsdir/build-aux/config.guess` case $myhostsub in ce) w32root="$w32ce_root" [ -z "$w32root" ] && w32root="$HOME/w32ce_root" - toolprefixes="arm-mingw32ce" - ;; - 64) - w32root="$w64root" - [ -z "$w32root" ] && w32root="$HOME/w64root" - toolprefixes="amd64-mingw32msvc" + toolprefixes="$w32ce_toolprefixes arm-mingw32ce" + extraoptions="$extraoptions $w32ce_extraoptions" ;; *) [ -z "$w32root" ] && w32root="$HOME/w32root" - toolprefixes="i586-mingw32msvc i386-mingw32msvc i686-w64-mingw32" + toolprefixes="$w32_toolprefixes i686-w64-mingw32 i586-mingw32msvc" + toolprefixes="$toolprefixes i386-mingw32msvc mingw32" + extraoptions="$extraoptions $w32_extraoptions" ;; esac - echo "Using $w32root as standard install directory" >&2 + info "Using $w32root as standard install directory" + replace_sysroot + # Locate the cross compiler crossbindir= for host in $toolprefixes; do if ${host}-gcc --version >/dev/null 2>&1 ; then @@ -116,50 +209,49 @@ if [ "$myhost" = "w32" ]; then fi done if [ -z "$crossbindir" ]; then - echo "Cross compiler kit not installed" >&2 - if [ -z "$sub" ]; then - echo "Under Debian GNU/Linux, you may install it using" >&2 - echo " apt-get install mingw32 mingw32-runtime mingw32-binutils" >&2 + fatal "cross compiler kit not installed" + if [ -z "$myhostsub" ]; then + info "Under Debian GNU/Linux, you may install it using" + info " apt-get install mingw32 mingw32-runtime mingw32-binutils" fi - echo "Stop." >&2 - exit 1 + die_p fi - if [ -f "$tsdir/config.log" ]; then if ! head $tsdir/config.log | grep "$host" >/dev/null; then - echo "Pease run a 'make distclean' first" >&2 - exit 1 + fatal "Please run a 'make distclean' first" + die_p fi fi - $tsdir/configure --enable-maintainer-mode --prefix=${w32root} \ - --host=${host} --build=${build} \ - --with-gpg-error-prefix=${w32root} "$@" - - exit $? + $tsdir/configure --enable-maintainer-mode ${SILENT} \ + --prefix=${w32root} \ + --host=${host} --build=${build} \ + ${configure_opts} ${extraoptions} "$@" + rc=$? + exit $rc fi # ***** end W32 build script ******* - # ***** AMD64 cross build script ******* # Used to cross-compile for AMD64 (for testing) -if test "$1" = "--build-amd64"; then - tmp=`dirname $0` - tsdir=`cd "$tmp"; pwd` +if [ "$myhost" = "amd64" ]; then shift - if [ ! -f $tsdir/config.guess ]; then - echo "$tsdir/config.guess not found" >&2 + if [ ! -f $tsdir/build-aux/config.guess ]; then + echo "$tsdir/build-aux/config.guess not found" >&2 exit 1 fi - build=`$tsdir/config.guess` + build=`$tsdir/build-aux/config.guess` [ -z "$amd64root" ] && amd64root="$HOME/amd64root" - echo "Using $amd64root as standard install directory" >&2 + info "Using $amd64root as standard install directory" + replace_sysroot + + toolprefixes="$amd64_toolprefixes x86_64-linux-gnu amd64-linux-gnu" # Locate the cross compiler crossbindir= - for host in x86_64-linux-gnu amd64-linux-gnu; do + for host in $toolprefixes ; do if ${host}-gcc --version >/dev/null 2>&1 ; then crossbindir=/usr/${host}/bin conf_CC="CC=${host}-gcc" @@ -179,18 +271,16 @@ if test "$1" = "--build-amd64"; then fi fi - $tsdir/configure --enable-maintainer-mode --prefix=${amd64root} \ + $tsdir/configure --enable-maintainer-mode ${SILENT} \ + --prefix=${amd64root} \ --host=${host} --build=${build} \ - --with-gpg-error-prefix=${amd64root} - + ${configure_opts} ${extraoptions} "$@" rc=$? exit $rc fi # ***** end AMD64 cross build script ******* - - # Grep the required versions from configure.ac autoconf_vers=`sed -n '/^AC_PREREQ(/ { s/^.*(\(.*\))/\1/p @@ -204,31 +294,22 @@ q }' ${configure_ac}` automake_vers_num=`echo "$automake_vers" | cvtver` -#gettext_vers=`sed -n '/^AM_GNU_GETTEXT_VERSION(/ { -#s/^.*(\(.*\))/\1/p -#q -#}' ${configure_ac}` -#gettext_vers_num=`echo "$gettext_vers" | cvtver` - +if [ -d "${tsdir}/po" ]; then + gettext_vers=`sed -n '/^AM_GNU_GETTEXT_VERSION(/ { +s/^.*\[\(.*\)])/\1/p +q +}' ${configure_ac}` + gettext_vers_num=`echo "$gettext_vers" | cvtver` +else + gettext_vers="n/a" +fi -if [ -z "$autoconf_vers" -o -z "$automake_vers" ] +if [ -z "$autoconf_vers" -o -z "$automake_vers" -o -z "$gettext_vers" ] then echo "**Error**: version information not found in "\`${configure_ac}\'"." >&2 exit 1 fi -# Allow to override the default tool names -AUTOCONF=${AUTOCONF_PREFIX}${AUTOCONF:-autoconf}${AUTOCONF_SUFFIX} -AUTOHEADER=${AUTOCONF_PREFIX}${AUTOHEADER:-autoheader}${AUTOCONF_SUFFIX} - -AUTOMAKE=${AUTOMAKE_PREFIX}${AUTOMAKE:-automake}${AUTOMAKE_SUFFIX} -ACLOCAL=${AUTOMAKE_PREFIX}${ACLOCAL:-aclocal}${AUTOMAKE_SUFFIX} - -#GETTEXT=${GETTEXT_PREFIX}${GETTEXT:-gettext}${GETTEXT_SUFFIX} -#MSGMERGE=${GETTEXT_PREFIX}${MSGMERGE:-msgmerge}${GETTEXT_SUFFIX} - -DIE=no - if check_version $AUTOCONF $autoconf_vers_num $autoconf_vers ; then check_version $AUTOHEADER $autoconf_vers_num $autoconf_vers autoconf @@ -236,51 +317,71 @@ fi if check_version $AUTOMAKE $automake_vers_num $automake_vers; then check_version $ACLOCAL $automake_vers_num $autoconf_vers automake fi -#if check_version $GETTEXT $gettext_vers_num $gettext_vers; then -# check_version $MSGMERGE $gettext_vers_num $gettext_vers gettext -#fi +if [ "$gettext_vers" != "n/a" ]; then + if check_version $GETTEXT $gettext_vers_num $gettext_vers; then + check_version $MSGMERGE $gettext_vers_num $gettext_vers gettext + fi +fi -if test "$DIE" = "yes"; then +if [ "$DIE" = "yes" ]; then cat <&2 + [ -z "${SILENT}" ] && cat <&2 + [ -z "${SILENT}" ] && cat <10000 are used for various % signals); since we just inserted a non-discardable item, any % following glue (such as a \parskip) would be a breakpoint. For example: - % + % % @deffn deffn-whatever % @vindex index-whatever % Description. @@ -5368,11 +5368,11 @@ end % glue accumulate. (Not a breakpoint because it's preceded by a % discardable item.) \vskip-\parskip - % + % % This is purely so the last item on the list is a known \penalty > % 10000. This is so \startdefun can avoid allowing breakpoints after % section headings. Otherwise, it would insert a valid breakpoint between: - % + % % @section sec-whatever % @deffn def-whatever \penalty 10001 @@ -5430,7 +5430,7 @@ end % These characters do not print properly in the Computer Modern roman % fonts, so we must take special care. This is more or less redundant % with the Texinfo input format setup at the end of this file. -% +% \def\activecatcodes{% \catcode`\"=\active \catcode`\$=\active @@ -5480,7 +5480,7 @@ end % redefined for the two-volume lispref. We always output on % \jobname.toc even if this is redefined. -% +% \def\tocreadfilename{\jobname.toc} % Normal (long) toc. @@ -6035,8 +6035,8 @@ end % from cmtt (char 0x0d). The undirected quote is ugly, so don't make it % the default, but it works for pasting with more pdf viewers (at least % evince), the lilypond developers report. xpdf does work with the -% regular 0x27. -% +% regular 0x27. +% \def\codequoteright{% \expandafter\ifx\csname SETtxicodequoteundirected\endcsname\relax \expandafter\ifx\csname SETcodequoteundirected\endcsname\relax @@ -6048,7 +6048,7 @@ end % and a similar option for the left quote char vs. a grave accent. % Modern fonts display ASCII 0x60 as a grave accent, so some people like % the code environments to do likewise. -% +% \def\codequoteleft{% \expandafter\ifx\csname SETtxicodequotebacktick\endcsname\relax \expandafter\ifx\csname SETcodequotebacktick\endcsname\relax @@ -6579,7 +6579,7 @@ end % This does \let #1 = #2, with \csnames; that is, % \let \csname#1\endcsname = \csname#2\endcsname % (except of course we have to play expansion games). -% +% \def\cslet#1#2{% \expandafter\let \csname#1\expandafter\endcsname @@ -7737,7 +7737,7 @@ end % % If they passed de_DE, and txi-de_DE.tex doesn't exist, % try txi-de.tex. -% +% \def\documentlanguagetrywithoutunderscore#1_#2\finish{% \openin 1 txi-#1.tex \ifeof 1 @@ -7793,7 +7793,7 @@ should work if nowhere else does.} \setnonasciicharscatcode\active \lattwochardefs % - \else \ifx \declaredencoding \latone + \else \ifx \declaredencoding \latone \setnonasciicharscatcode\active \latonechardefs % @@ -7805,7 +7805,7 @@ should work if nowhere else does.} \setnonasciicharscatcode\active \utfeightchardefs % - \else + \else \message{Unknown document encoding #1, ignoring.}% % \fi % utfeight @@ -7817,7 +7817,7 @@ should work if nowhere else does.} % A message to be logged when using a character that isn't available % the default font encoding (OT1). -% +% \def\missingcharmsg#1{\message{Character missing in OT1 encoding: #1.}} % Take account of \c (plain) vs. \, (Texinfo) difference. @@ -7830,21 +7830,21 @@ should work if nowhere else does.} % % Latin1 (ISO-8859-1) character definitions. \def\latonechardefs{% - \gdef^^a0{~} + \gdef^^a0{~} \gdef^^a1{\exclamdown} - \gdef^^a2{\missingcharmsg{CENT SIGN}} + \gdef^^a2{\missingcharmsg{CENT SIGN}} \gdef^^a3{{\pounds}} \gdef^^a4{\missingcharmsg{CURRENCY SIGN}} \gdef^^a5{\missingcharmsg{YEN SIGN}} - \gdef^^a6{\missingcharmsg{BROKEN BAR}} + \gdef^^a6{\missingcharmsg{BROKEN BAR}} \gdef^^a7{\S} - \gdef^^a8{\"{}} - \gdef^^a9{\copyright} + \gdef^^a8{\"{}} + \gdef^^a9{\copyright} \gdef^^aa{\ordf} - \gdef^^ab{\missingcharmsg{LEFT-POINTING DOUBLE ANGLE QUOTATION MARK}} + \gdef^^ab{\missingcharmsg{LEFT-POINTING DOUBLE ANGLE QUOTATION MARK}} \gdef^^ac{$\lnot$} - \gdef^^ad{\-} - \gdef^^ae{\registeredsymbol} + \gdef^^ad{\-} + \gdef^^ae{\registeredsymbol} \gdef^^af{\={}} % \gdef^^b0{\textdegree} @@ -7871,7 +7871,7 @@ should work if nowhere else does.} \gdef^^c2{\^A} \gdef^^c3{\~A} \gdef^^c4{\"A} - \gdef^^c5{\ringaccent A} + \gdef^^c5{\ringaccent A} \gdef^^c6{\AE} \gdef^^c7{\cedilla C} \gdef^^c8{\`E} @@ -8012,7 +8012,7 @@ should work if nowhere else does.} \gdef^^d6{\"O} \gdef^^d7{$\times$} \gdef^^d8{\v R} - \gdef^^d9{\ringaccent U} + \gdef^^d9{\ringaccent U} \gdef^^da{\'U} \gdef^^db{\H U} \gdef^^dc{\"U} @@ -8056,11 +8056,11 @@ should work if nowhere else does.} } % UTF-8 character definitions. -% +% % This code to support UTF-8 is based on LaTeX's utf8.def, with some % changes for Texinfo conventions. It is included here under the GPL by % permission from Frank Mittelbach and the LaTeX team. -% +% \newcount\countUTFx \newcount\countUTFy \newcount\countUTFz @@ -8900,7 +8900,7 @@ should work if nowhere else does.} % Same as @turnoffactive except outputs \ as {\tt\char`\\} instead of % the literal character `\'. -% +% @def at normalturnoffactive{% @let\=@normalbackslash @let"=@normaldoublequote diff --git a/ylwrap b/build-aux/ylwrap similarity index 97% rename from ylwrap rename to build-aux/ylwrap index 7278b6a..279f306 100755 --- a/ylwrap +++ b/build-aux/ylwrap @@ -135,19 +135,19 @@ if test $ret -eq 0; then # Handle y_tab.c and y_tab.h output by DOS if test $y_tab_nodot = "yes"; then if test $from = "y.tab.c"; then - from="y_tab.c" + from="y_tab.c" else - if test $from = "y.tab.h"; then - from="y_tab.h" - fi + if test $from = "y.tab.h"; then + from="y_tab.h" + fi fi fi if test -f "$from"; then # If $2 is an absolute path name, then just use that, # otherwise prepend `../'. case "$2" in - [\\/]* | ?:[\\/]*) target="$2";; - *) target="../$2";; + [\\/]* | ?:[\\/]*) target="$2";; + *) target="../$2";; esac # We do not want to overwrite a header file if it hasn't diff --git a/configure.ac b/configure.ac index 2c5cd7e..cc24bbf 100644 --- a/configure.ac +++ b/configure.ac @@ -64,6 +64,7 @@ NEED_GPG_ERROR_VERSION=1.8 PACKAGE=$PACKAGE_NAME VERSION=$PACKAGE_VERSION +AC_CONFIG_AUX_DIR([build-aux]) AC_CONFIG_SRCDIR([src/ksba.h]) AM_INIT_AUTOMAKE($PACKAGE, $VERSION) AM_CONFIG_HEADER(config.h) ----------------------------------------------------------------------- Summary of changes: Makefile.am | 3 +- autogen.rc | 29 ++++ autogen.sh | 287 +++++++++++++++++++++----------- compile => build-aux/compile | 0 config.guess => build-aux/config.guess | 0 config.sub => build-aux/config.sub | 0 depcomp => build-aux/depcomp | 0 install-sh => build-aux/install-sh | 0 ltmain.sh => build-aux/ltmain.sh | 1 - {doc => build-aux}/mdate-sh | 0 missing => build-aux/missing | 0 {doc => build-aux}/texinfo.tex | 118 ++++++------- ylwrap => build-aux/ylwrap | 12 +- configure.ac | 1 + 14 files changed, 291 insertions(+), 160 deletions(-) create mode 100644 autogen.rc rename compile => build-aux/compile (100%) rename config.guess => build-aux/config.guess (100%) rename config.sub => build-aux/config.sub (100%) rename depcomp => build-aux/depcomp (100%) rename install-sh => build-aux/install-sh (100%) rename ltmain.sh => build-aux/ltmain.sh (99%) rename {doc => build-aux}/mdate-sh (100%) rename missing => build-aux/missing (100%) rename {doc => build-aux}/texinfo.tex (99%) rename ylwrap => build-aux/ylwrap (97%) hooks/post-receive -- KSBA is a library to access X.509 certificates and CMS data. http://git.gnupg.org From cvs at cvs.gnupg.org Fri Jan 10 17:44:23 2014 From: cvs at cvs.gnupg.org (by Werner Koch) Date: Fri, 10 Jan 2014 17:44:23 +0100 Subject: [git] GPGME - branch, master, updated. gpgme-1.4.2-20-g1a504aa Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "GnuPG Made Easy". The branch, master has been updated via 1a504aab384947c1a6e949affd14bc696297fc8d (commit) from 74c0075ca2f37758d1c6fb1c59bf3f6e42b42770 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 1a504aab384947c1a6e949affd14bc696297fc8d Author: Werner Koch Date: Thu Jan 9 19:14:09 2014 +0100 Use the generic autogen.sh script. * autogen.rc: New. * Makefile.am (EXTRA_DIST): Add it. * autogen.sh: Update from GnuPG. * configure.ac (AM_SILENT_RULES): New. diff --git a/Makefile.am b/Makefile.am index 18a8e38..28f9eca 100644 --- a/Makefile.am +++ b/Makefile.am @@ -22,9 +22,9 @@ ACLOCAL_AMFLAGS = -I m4 AUTOMAKE_OPTIONS = dist-bzip2 -DISTCHECK_CONFIGURE_FLAGS = --with-gpg="@GPG@" +DISTCHECK_CONFIGURE_FLAGS = -EXTRA_DIST = gpgme.spec.in autogen.sh \ +EXTRA_DIST = autogen.sh autogen.rc gpgme.spec.in \ ChangeLog-2011 m4/ChangeLog-2011 contrib/ChangeLog-2011 diff --git a/autogen.rc b/autogen.rc new file mode 100644 index 0000000..d0ade53 --- /dev/null +++ b/autogen.rc @@ -0,0 +1,20 @@ +# autogen.sh configuration for GPGME -*- sh -*- + +case "$myhost" in + w32) + configure_opts=" + --with-gpg-error-prefix=@SYSROOT@ + --with-libassuan-prefix=@SYSROOT@ + " + ;; + + amd64) + configure_opts=" + --with-gpg-error-prefix=@SYSROOT@ + --with-libassuan-prefix=@SYSROOT@ + " + ;; +esac + + +final_info="./configure --enable-maintainer-mode && make" diff --git a/autogen.sh b/autogen.sh index 067870a..471193c 100755 --- a/autogen.sh +++ b/autogen.sh @@ -1,7 +1,6 @@ #! /bin/sh -# Run this to generate all the initial makefiles, etc. -# -# Copyright (C) 2003 g10 Code GmbH +# autogen.sh +# Copyright (C) 2003, 2014 g10 Code GmbH # # This file is free software; as a special exception the author gives # unlimited permission to copy and/or distribute it, with or without @@ -10,6 +9,13 @@ # This program 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. +# +# This is a generic script to create the configure script and handle cross +# build environments. It requires the presence of a autogen.rc file to +# configure it for the respective package. It is maintained as part of +# GnuPG and source copied by other packages. +# +# Version: 2014-01-10 configure_ac="configure.ac" @@ -18,7 +24,7 @@ cvtver () { } check_version () { - if [ `("$1" --version || echo "0") | cvtver` -ge "$2" ]; then + if [ $(( `("$1" --version || echo "0") | cvtver` >= $2 )) = 1 ]; then return 0 fi echo "**Error**: "\`$1\'" not installed or too old." >&2 @@ -28,67 +34,150 @@ check_version () { return 1 } +fatal () { + echo "autogen.sh:" "$*" >&2 + DIE=yes +} + +info () { + if [ -z "${SILENT}" ]; then + echo "autogen.sh:" "$*" + fi +} + +die_p () { + if [ "$DIE" = "yes" ]; then + echo "autogen.sh: Stop." >&2 + exit 1 + fi +} + +replace_sysroot () { + configure_opts=$(echo $configure_opts | sed "s#@SYSROOT@#${w32root}#g") + extraoptions=$(echo $extraoptions | sed "s#@SYSROOT@#${w32root}#g") +} + +# Allow to override the default tool names +AUTOCONF=${AUTOCONF_PREFIX}${AUTOCONF:-autoconf}${AUTOCONF_SUFFIX} +AUTOHEADER=${AUTOCONF_PREFIX}${AUTOHEADER:-autoheader}${AUTOCONF_SUFFIX} + +AUTOMAKE=${AUTOMAKE_PREFIX}${AUTOMAKE:-automake}${AUTOMAKE_SUFFIX} +ACLOCAL=${AUTOMAKE_PREFIX}${ACLOCAL:-aclocal}${AUTOMAKE_SUFFIX} + +GETTEXT=${GETTEXT_PREFIX}${GETTEXT:-gettext}${GETTEXT_SUFFIX} +MSGMERGE=${GETTEXT_PREFIX}${MSGMERGE:-msgmerge}${GETTEXT_SUFFIX} DIE=no FORCE= +SILENT= +tmp=$(dirname "$0") +tsdir=$(cd "${tmp}"; pwd) + +if [ -n "${AUTOGEN_SH_SILENT}" ]; then + SILENT=" --silent" +fi +if test x"$1" = x"--help"; then + echo "usage: ./autogen.sh [--silent] [--force] [--build-TYPE] [ARGS]" + exit 0 +fi +if test x"$1" = x"--silent"; then + SILENT=" --silent" + shift +fi if test x"$1" = x"--force"; then FORCE=" --force" shift fi -# Begin list of optional variables sourced from ~/.gnupg-autogen.rc + +# Reject unsafe characters in $HOME, $tsdir and cwd. We consider spaces +# as unsafe because it is too easy to get scripts wrong in this regard. +am_lf=' +' +case `pwd` in + *[\;\\\"\#\$\&\'\`$am_lf\ \ ]*) + fatal "unsafe working directory name" ;; +esac +case $tsdir in + *[\;\\\"\#\$\&\'\`$am_lf\ \ ]*) + fatal "unsafe source directory: \`$tsdir'" ;; +esac +case $HOME in + *[\;\\\"\#\$\&\'\`$am_lf\ \ ]*) + fatal "unsafe home directory: \`$HOME'" ;; +esac +die_p + + +# List of variables sourced from autogen.rc. The strings '@SYSROOT@' in +# these variables are replaced by the actual system root. +configure_opts= +extraoptions= +# List of optional variables sourced from autogen.rc and ~/.gnupg-autogen.rc w32_toolprefixes= w32_extraoptions= w32ce_toolprefixes= w32ce_extraoptions= +w64_toolprefixes= +w64_extraoptions= amd64_toolprefixes= # End list of optional variables sourced from ~/.gnupg-autogen.rc # What follows are variables which are sourced but default to # environment variables or lacking them hardcoded values. #w32root= #w32ce_root= +#w64root= #amd64root= -if [ -f "$HOME/.gnupg-autogen.rc" ]; then - echo "sourcing extra definitions from $HOME/.gnupg-autogen.rc" - . "$HOME/.gnupg-autogen.rc" -fi - # Convenience option to use certain configure options for some hosts. myhost="" myhostsub="" case "$1" in --build-w32) myhost="w32" + shift ;; --build-w32ce) myhost="w32" myhostsub="ce" + shift ;; --build-w64) myhost="w32" myhostsub="64" + shift ;; --build-amd64) myhost="amd64" + shift ;; --build*) - echo "**Error**: invalid build option $1" >&2 - exit 1 + fatal "**Error**: invalid build option $1" + shift ;; *) ;; esac +die_p + + +# Source our configuration +if [ -f "${tsdir}/autogen.rc" ]; then + . "${tsdir}/autogen.rc" +fi +# Source optional site specific configuration +if [ -f "$HOME/.gnupg-autogen.rc" ]; then + info "sourcing extra definitions from $HOME/.gnupg-autogen.rc" + . "$HOME/.gnupg-autogen.rc" +fi -# ***** W32 build script ******* -# Used to cross-compile for Windows. +# ****************** +# W32 build script +# ****************** if [ "$myhost" = "w32" ]; then - tmp=`dirname $0` - tsdir=`cd "$tmp"; pwd` - shift - if [ ! -f $tsdir/build-aux/config.guess ]; then - echo "$tsdir/build-aux/config.guess not found" >&2 + if [ ! -f "$tsdir/build-aux/config.guess" ]; then + fatal "$tsdir/build-aux/config.guess not found" exit 1 fi build=`$tsdir/build-aux/config.guess` @@ -97,21 +186,26 @@ if [ "$myhost" = "w32" ]; then ce) w32root="$w32ce_root" [ -z "$w32root" ] && w32root="$HOME/w32ce_root" - toolprefixes="arm-mingw32ce" + toolprefixes="$w32ce_toolprefixes arm-mingw32ce" + extraoptions="$extraoptions $w32ce_extraoptions" ;; 64) w32root="$w64root" [ -z "$w32root" ] && w32root="$HOME/w64root" - toolprefixes="$amd64_toolprefixes amd64-mingw32msvc" + toolprefixes="$w64_toolprefixes x86_64-w64-mingw32" + extraoptions="$extraoptions $w64_extraoptions" ;; *) [ -z "$w32root" ] && w32root="$HOME/w32root" toolprefixes="$w32_toolprefixes i686-w64-mingw32 i586-mingw32msvc" toolprefixes="$toolprefixes i386-mingw32msvc mingw32" + extraoptions="$extraoptions $w32_extraoptions" ;; esac - echo "Using $w32root as standard install directory" >&2 + info "Using $w32root as standard install directory" + replace_sysroot + # Locate the cross compiler crossbindir= for host in $toolprefixes; do if ${host}-gcc --version >/dev/null 2>&1 ; then @@ -121,37 +215,33 @@ if [ "$myhost" = "w32" ]; then fi done if [ -z "$crossbindir" ]; then - echo "Cross compiler kit not installed" >&2 + fatal "cross compiler kit not installed" if [ -z "$myhostsub" ]; then - echo "Under Debian GNU/Linux, you may install it using" >&2 - echo " apt-get install mingw32 mingw32-runtime mingw32-binutils" >&2 + info "Under Debian GNU/Linux, you may install it using" + info " apt-get install mingw32 mingw32-runtime mingw32-binutils" fi - echo "Stop." >&2 - exit 1 + die_p fi if [ -f "$tsdir/config.log" ]; then if ! head $tsdir/config.log | grep "$host" >/dev/null; then - echo "Pease run a 'make distclean' first" >&2 - exit 1 + fatal "Please run a 'make distclean' first" + die_p fi fi - $tsdir/configure --enable-maintainer-mode --prefix=${w32root} \ - --host=${host} --build=${build} \ - --with-gpg-error-prefix=${w32root} \ - --with-libassuan-prefix=${w32root} "$@" - - exit $? + $tsdir/configure --enable-maintainer-mode ${SILENT} \ + --prefix=${w32root} \ + --host=${host} --build=${build} \ + ${configure_opts} ${extraoptions} "$@" + rc=$? + exit $rc fi # ***** end W32 build script ******* - # ***** AMD64 cross build script ******* # Used to cross-compile for AMD64 (for testing) if [ "$myhost" = "amd64" ]; then - tmp=`dirname $0` - tsdir=`cd "$tmp"; pwd` shift if [ ! -f $tsdir/build-aux/config.guess ]; then echo "$tsdir/build-aux/config.guess not found" >&2 @@ -160,11 +250,14 @@ if [ "$myhost" = "amd64" ]; then build=`$tsdir/build-aux/config.guess` [ -z "$amd64root" ] && amd64root="$HOME/amd64root" - echo "Using $amd64root as standard install directory" >&2 + info "Using $amd64root as standard install directory" + replace_sysroot + + toolprefixes="$amd64_toolprefixes x86_64-linux-gnu amd64-linux-gnu" # Locate the cross compiler crossbindir= - for host in x86_64-linux-gnu amd64-linux-gnu; do + for host in $toolprefixes ; do if ${host}-gcc --version >/dev/null 2>&1 ; then crossbindir=/usr/${host}/bin conf_CC="CC=${host}-gcc" @@ -184,15 +277,16 @@ if [ "$myhost" = "amd64" ]; then fi fi - $tsdir/configure --enable-maintainer-mode --prefix=${amd64root} \ - --host=${host} --build=${build} + $tsdir/configure --enable-maintainer-mode ${SILENT} \ + --prefix=${amd64root} \ + --host=${host} --build=${build} \ + ${configure_opts} ${extraoptions} "$@" rc=$? exit $rc fi # ***** end AMD64 cross build script ******* - # Grep the required versions from configure.ac autoconf_vers=`sed -n '/^AC_PREREQ(/ { s/^.*(\(.*\))/\1/p @@ -206,29 +300,22 @@ q }' ${configure_ac}` automake_vers_num=`echo "$automake_vers" | cvtver` -#gettext_vers=`sed -n '/^AM_GNU_GETTEXT_VERSION(/ { -#s/^.*(\(.*\))/\1/p -#q -#}' ${configure_ac}` -#gettext_vers_num=`echo "$gettext_vers" | cvtver` - +if [ -d "${tsdir}/po" ]; then + gettext_vers=`sed -n '/^AM_GNU_GETTEXT_VERSION(/ { +s/^.*\[\(.*\)])/\1/p +q +}' ${configure_ac}` + gettext_vers_num=`echo "$gettext_vers" | cvtver` +else + gettext_vers="n/a" +fi -if [ -z "$autoconf_vers" -o -z "$automake_vers" ] +if [ -z "$autoconf_vers" -o -z "$automake_vers" -o -z "$gettext_vers" ] then echo "**Error**: version information not found in "\`${configure_ac}\'"." >&2 exit 1 fi -# Allow to override the default tool names -AUTOCONF=${AUTOCONF_PREFIX}${AUTOCONF:-autoconf}${AUTOCONF_SUFFIX} -AUTOHEADER=${AUTOCONF_PREFIX}${AUTOHEADER:-autoheader}${AUTOCONF_SUFFIX} - -AUTOMAKE=${AUTOMAKE_PREFIX}${AUTOMAKE:-automake}${AUTOMAKE_SUFFIX} -ACLOCAL=${AUTOMAKE_PREFIX}${ACLOCAL:-aclocal}${AUTOMAKE_SUFFIX} - -#GETTEXT=${GETTEXT_PREFIX}${GETTEXT:-gettext}${GETTEXT_SUFFIX} -#MSGMERGE=${GETTEXT_PREFIX}${MSGMERGE:-msgmerge}${GETTEXT_SUFFIX} - if check_version $AUTOCONF $autoconf_vers_num $autoconf_vers ; then check_version $AUTOHEADER $autoconf_vers_num $autoconf_vers autoconf @@ -236,54 +323,71 @@ fi if check_version $AUTOMAKE $automake_vers_num $automake_vers; then check_version $ACLOCAL $automake_vers_num $autoconf_vers automake fi -#if check_version $GETTEXT $gettext_vers_num $gettext_vers; then -# check_version $MSGMERGE $gettext_vers_num $gettext_vers gettext -#fi +if [ "$gettext_vers" != "n/a" ]; then + if check_version $GETTEXT $gettext_vers_num $gettext_vers; then + check_version $MSGMERGE $gettext_vers_num $gettext_vers gettext + fi +fi -if test "$DIE" = "yes"; then +if [ "$DIE" = "yes" ]; then cat <&2 + [ -z "${SILENT}" ] && cat <&2 + [ -z "${SILENT}" ] && cat < This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The GNU Privacy Assistant". The branch, master has been updated via cb0e2c95aafaab607ae7f040a79e3b47db80ee0f (commit) via e432add8990e6e01488ef67fcc644b2cddbfc60d (commit) from ba72a6a1ff15dd0a72ceccd7335ba25d2e4ac004 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit cb0e2c95aafaab607ae7f040a79e3b47db80ee0f Author: Werner Koch Date: Thu Jan 9 19:14:09 2014 +0100 Use the generic autogen.sh script. * autogen.rc: New. * Makefile.am (EXTRA_DIST): Add it. * autogen.sh: Update from GnuPG. diff --git a/Makefile.am b/Makefile.am index 78379d7..e24d01b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -24,7 +24,7 @@ AUTOMAKE_OPTIONS = dist-bzip2 SUBDIRS = m4 src po pixmaps doc EXTRA_DIST = \ - autogen.sh TODO to-utf8 gpa.spec \ + autogen.sh autogen.rc TODO to-utf8 gpa.spec \ gpa.desktop gpa.png gpadefs.h.in \ po/ChangeLog-2011 pixmaps/ChangeLog-2011 ChangeLog-2011 \ m4/ChangeLog-2011 src/ChangeLog-2011 st-fonts/ChangeLog-2011 diff --git a/autogen.rc b/autogen.rc new file mode 100644 index 0000000..df2ab16 --- /dev/null +++ b/autogen.rc @@ -0,0 +1,14 @@ +# autogen.sh configuration for GPA -*- sh -*- + +configure_opts=" + --with-zlib=@SYSROOT@ + --with-gpg-error-prefix=@SYSROOT@ + --with-gpgme-prefix=@SYSROOT@ + --with-libassuan-prefix=@SYSROOT@ + --with-libiconv-prefix=@SYSROOT@ + SYSROOT=\"@SYSROOT@\" + PKG_CONFIG=\"@SYSROOT@/bin/pkg-config\" + PKG_CONFIG_LIBDIR=\"@SYSROOT@/lib/pkgconfig\" + " + +final_info="./configure --enable-maintainer-mode && make" diff --git a/autogen.sh b/autogen.sh index 2acfed2..471193c 100755 --- a/autogen.sh +++ b/autogen.sh @@ -1,8 +1,21 @@ -#!/bin/bash -# Run this to generate all the initial makefiles, etc. +#! /bin/sh +# autogen.sh +# Copyright (C) 2003, 2014 g10 Code GmbH # -# Use --build-w32 to prepare the cross compiling build for Windoze +# 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 program 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. +# +# This is a generic script to create the configure script and handle cross +# build environments. It requires the presence of a autogen.rc file to +# configure it for the respective package. It is maintained as part of +# GnuPG and source copied by other packages. +# +# Version: 2014-01-10 configure_ac="configure.ac" @@ -11,7 +24,7 @@ cvtver () { } check_version () { - if [ `("$1" --version || echo "0") | cvtver` -ge "$2" ]; then + if [ $(( `("$1" --version || echo "0") | cvtver` >= $2 )) = 1 ]; then return 0 fi echo "**Error**: "\`$1\'" not installed or too old." >&2 @@ -21,6 +34,29 @@ check_version () { return 1 } +fatal () { + echo "autogen.sh:" "$*" >&2 + DIE=yes +} + +info () { + if [ -z "${SILENT}" ]; then + echo "autogen.sh:" "$*" + fi +} + +die_p () { + if [ "$DIE" = "yes" ]; then + echo "autogen.sh: Stop." >&2 + exit 1 + fi +} + +replace_sysroot () { + configure_opts=$(echo $configure_opts | sed "s#@SYSROOT@#${w32root}#g") + extraoptions=$(echo $extraoptions | sed "s#@SYSROOT@#${w32root}#g") +} + # Allow to override the default tool names AUTOCONF=${AUTOCONF_PREFIX}${AUTOCONF:-autoconf}${AUTOCONF_SUFFIX} AUTOHEADER=${AUTOCONF_PREFIX}${AUTOHEADER:-autoheader}${AUTOCONF_SUFFIX} @@ -33,86 +69,141 @@ MSGMERGE=${GETTEXT_PREFIX}${MSGMERGE:-msgmerge}${GETTEXT_SUFFIX} DIE=no FORCE= -tmp=`dirname $0` -tsdir=`cd "$tmp"; pwd` -if test x"$1" == x"--force"; then +SILENT= +tmp=$(dirname "$0") +tsdir=$(cd "${tmp}"; pwd) + +if [ -n "${AUTOGEN_SH_SILENT}" ]; then + SILENT=" --silent" +fi +if test x"$1" = x"--help"; then + echo "usage: ./autogen.sh [--silent] [--force] [--build-TYPE] [ARGS]" + exit 0 +fi +if test x"$1" = x"--silent"; then + SILENT=" --silent" + shift +fi +if test x"$1" = x"--force"; then FORCE=" --force" shift fi + # Reject unsafe characters in $HOME, $tsdir and cwd. We consider spaces # as unsafe because it is too easy to get scripts wrong in this regard. am_lf=' ' case `pwd` in *[\;\\\"\#\$\&\'\`$am_lf\ \ ]*) - echo "unsafe working directory name"; DIE=yes;; + fatal "unsafe working directory name" ;; esac case $tsdir in *[\;\\\"\#\$\&\'\`$am_lf\ \ ]*) - echo "unsafe source directory: \`$tsdir'"; DIE=yes;; + fatal "unsafe source directory: \`$tsdir'" ;; esac case $HOME in *[\;\\\"\#\$\&\'\`$am_lf\ \ ]*) - echo "unsafe home directory: \`$HOME'"; DIE=yes;; + fatal "unsafe home directory: \`$HOME'" ;; esac -if test "$DIE" = "yes"; then - exit 1 -fi +die_p -# Begin list of optional variables sourced from ~/.gnupg-autogen.rc + +# List of variables sourced from autogen.rc. The strings '@SYSROOT@' in +# these variables are replaced by the actual system root. +configure_opts= +extraoptions= +# List of optional variables sourced from autogen.rc and ~/.gnupg-autogen.rc w32_toolprefixes= w32_extraoptions= w32ce_toolprefixes= w32ce_extraoptions= +w64_toolprefixes= +w64_extraoptions= amd64_toolprefixes= # End list of optional variables sourced from ~/.gnupg-autogen.rc # What follows are variables which are sourced but default to # environment variables or lacking them hardcoded values. #w32root= #w32ce_root= +#w64root= #amd64root= -if [ -f "$HOME/.gnupg-autogen.rc" ]; then - echo "sourcing extra definitions from $HOME/.gnupg-autogen.rc" - . "$HOME/.gnupg-autogen.rc" -fi - # Convenience option to use certain configure options for some hosts. myhost="" myhostsub="" case "$1" in --build-w32) myhost="w32" + shift + ;; + --build-w32ce) + myhost="w32" + myhostsub="ce" + shift + ;; + --build-w64) + myhost="w32" + myhostsub="64" + shift + ;; + --build-amd64) + myhost="amd64" + shift ;; --build*) - echo "**Error**: invalid build option $1" >&2 - exit 1 + fatal "**Error**: invalid build option $1" + shift ;; *) ;; esac +die_p + +# Source our configuration +if [ -f "${tsdir}/autogen.rc" ]; then + . "${tsdir}/autogen.rc" +fi + +# Source optional site specific configuration +if [ -f "$HOME/.gnupg-autogen.rc" ]; then + info "sourcing extra definitions from $HOME/.gnupg-autogen.rc" + . "$HOME/.gnupg-autogen.rc" +fi -# ***** W32 build script ******* -# Used to cross-compile for Windows. +# ****************** +# W32 build script +# ****************** if [ "$myhost" = "w32" ]; then - shift - if [ ! -f $tsdir/config.guess ]; then - echo "$tsdir/config.guess not found" >&2 + if [ ! -f "$tsdir/build-aux/config.guess" ]; then + fatal "$tsdir/build-aux/config.guess not found" exit 1 fi - build=`$tsdir/config.guess` + build=`$tsdir/build-aux/config.guess` case $myhostsub in + ce) + w32root="$w32ce_root" + [ -z "$w32root" ] && w32root="$HOME/w32ce_root" + toolprefixes="$w32ce_toolprefixes arm-mingw32ce" + extraoptions="$extraoptions $w32ce_extraoptions" + ;; + 64) + w32root="$w64root" + [ -z "$w32root" ] && w32root="$HOME/w64root" + toolprefixes="$w64_toolprefixes x86_64-w64-mingw32" + extraoptions="$extraoptions $w64_extraoptions" + ;; *) [ -z "$w32root" ] && w32root="$HOME/w32root" toolprefixes="$w32_toolprefixes i686-w64-mingw32 i586-mingw32msvc" toolprefixes="$toolprefixes i386-mingw32msvc mingw32" - extraoptions="$w32_extraoptions" + extraoptions="$extraoptions $w32_extraoptions" ;; esac - echo "Using $w32root as standard install directory" >&2 + info "Using $w32root as standard install directory" + replace_sysroot # Locate the cross compiler crossbindir= @@ -124,11 +215,57 @@ if [ "$myhost" = "w32" ]; then fi done if [ -z "$crossbindir" ]; then - echo "Cross compiler kit not installed" >&2 - if [ -z "$sub" ]; then - echo "Under Debian GNU/Linux, you may install it using" >&2 - echo " apt-get install mingw32 mingw32-runtime mingw32-binutils" >&2 + fatal "cross compiler kit not installed" + if [ -z "$myhostsub" ]; then + info "Under Debian GNU/Linux, you may install it using" + info " apt-get install mingw32 mingw32-runtime mingw32-binutils" + fi + die_p + fi + + if [ -f "$tsdir/config.log" ]; then + if ! head $tsdir/config.log | grep "$host" >/dev/null; then + fatal "Please run a 'make distclean' first" + die_p + fi + fi + + $tsdir/configure --enable-maintainer-mode ${SILENT} \ + --prefix=${w32root} \ + --host=${host} --build=${build} \ + ${configure_opts} ${extraoptions} "$@" + rc=$? + exit $rc +fi +# ***** end W32 build script ******* + +# ***** AMD64 cross build script ******* +# Used to cross-compile for AMD64 (for testing) +if [ "$myhost" = "amd64" ]; then + shift + if [ ! -f $tsdir/build-aux/config.guess ]; then + echo "$tsdir/build-aux/config.guess not found" >&2 + exit 1 + fi + build=`$tsdir/build-aux/config.guess` + + [ -z "$amd64root" ] && amd64root="$HOME/amd64root" + info "Using $amd64root as standard install directory" + replace_sysroot + + toolprefixes="$amd64_toolprefixes x86_64-linux-gnu amd64-linux-gnu" + + # Locate the cross compiler + crossbindir= + for host in $toolprefixes ; do + if ${host}-gcc --version >/dev/null 2>&1 ; then + crossbindir=/usr/${host}/bin + conf_CC="CC=${host}-gcc" + break; fi + done + if [ -z "$crossbindir" ]; then + echo "Cross compiler kit not installed" >&2 echo "Stop." >&2 exit 1 fi @@ -140,20 +277,14 @@ if [ "$myhost" = "w32" ]; then fi fi - $tsdir/configure ${conf_CC} --build=${build} --host=${host} \ - --prefix=${w32root} \ - --with-zlib=${w32root} \ - --with-gpg-error-prefix=${w32root} \ - --with-gpgme-prefix=${w32root} \ - --with-libassuan-prefix=${w32root} \ - --with-libiconv-prefix=${w32root} \ - SYSROOT="$w32root" \ - PKG_CONFIG="$w32root/bin/pkg-config" \ - PKG_CONFIG_LIBDIR="$w32root/lib/pkgconfig" "$@" + $tsdir/configure --enable-maintainer-mode ${SILENT} \ + --prefix=${amd64root} \ + --host=${host} --build=${build} \ + ${configure_opts} ${extraoptions} "$@" rc=$? exit $rc fi -# ***** end W32 build script ******* +# ***** end AMD64 cross build script ******* # Grep the required versions from configure.ac @@ -169,12 +300,15 @@ q }' ${configure_ac}` automake_vers_num=`echo "$automake_vers" | cvtver` -gettext_vers=`sed -n '/^AM_GNU_GETTEXT_VERSION(/ { -s/^.*(\(.*\))/\1/p +if [ -d "${tsdir}/po" ]; then + gettext_vers=`sed -n '/^AM_GNU_GETTEXT_VERSION(/ { +s/^.*\[\(.*\)])/\1/p q }' ${configure_ac}` -gettext_vers_num=`echo "$gettext_vers" | cvtver` - + gettext_vers_num=`echo "$gettext_vers" | cvtver` +else + gettext_vers="n/a" +fi if [ -z "$autoconf_vers" -o -z "$automake_vers" -o -z "$gettext_vers" ] then @@ -189,59 +323,71 @@ fi if check_version $AUTOMAKE $automake_vers_num $automake_vers; then check_version $ACLOCAL $automake_vers_num $autoconf_vers automake fi -if check_version $GETTEXT $gettext_vers_num $gettext_vers; then - check_version $MSGMERGE $gettext_vers_num $gettext_vers gettext +if [ "$gettext_vers" != "n/a" ]; then + if check_version $GETTEXT $gettext_vers_num $gettext_vers; then + check_version $MSGMERGE $gettext_vers_num $gettext_vers gettext + fi fi -if test "$DIE" = "yes"; then +if [ "$DIE" = "yes" ]; then cat <&2 + [ -z "${SILENT}" ] && cat <&2 - git config --add filter.cleanpo.clean \ + + if [ "$gettext_vers" != "n/a" ]; then + tmp=$(git config --get filter.cleanpo.clean) + if [ "$tmp" != \ + "awk '/^\"POT-Creation-Date:/&&!s{s=1;next};!/^#: /{print}'" ] + then + info "*** Adding GIT filter.cleanpo.clean configuration." + git config --add filter.cleanpo.clean \ "awk '/^\"POT-Creation-Date:/&&!s{s=1;next};!/^#: /{print}'" + fi fi if [ -f build-aux/git-hooks/commit-msg -a ! -f .git/hooks/commit-msg ] ; then - cat <&2 + [ -z "${SILENT}" ] && cat < Date: Thu Jan 9 19:14:09 2014 +0100 Move helper scripts to build-aux/. * config.guess, config.rpath, config.sub, depcomp * install-sh, mdate-sh, missing: Move to build-aux/. * configure.ac (AC_CONFIG_AUX_DIR): New. (AM_SILENT_RULES): New. * Makefile.am (EXTRA_DIST): Remove config.rpath. diff --git a/Makefile.am b/Makefile.am index 5b08a12..78379d7 100644 --- a/Makefile.am +++ b/Makefile.am @@ -24,7 +24,7 @@ AUTOMAKE_OPTIONS = dist-bzip2 SUBDIRS = m4 src po pixmaps doc EXTRA_DIST = \ - config.rpath TODO to-utf8 autogen.sh gpa.spec \ + autogen.sh TODO to-utf8 gpa.spec \ gpa.desktop gpa.png gpadefs.h.in \ po/ChangeLog-2011 pixmaps/ChangeLog-2011 ChangeLog-2011 \ m4/ChangeLog-2011 src/ChangeLog-2011 st-fonts/ChangeLog-2011 diff --git a/config.guess b/build-aux/config.guess similarity index 100% rename from config.guess rename to build-aux/config.guess diff --git a/config.rpath b/build-aux/config.rpath similarity index 100% rename from config.rpath rename to build-aux/config.rpath diff --git a/config.sub b/build-aux/config.sub similarity index 100% rename from config.sub rename to build-aux/config.sub diff --git a/depcomp b/build-aux/depcomp similarity index 100% rename from depcomp rename to build-aux/depcomp diff --git a/install-sh b/build-aux/install-sh similarity index 100% rename from install-sh rename to build-aux/install-sh diff --git a/mdate-sh b/build-aux/mdate-sh similarity index 100% rename from mdate-sh rename to build-aux/mdate-sh diff --git a/missing b/build-aux/missing similarity index 100% rename from missing rename to build-aux/missing diff --git a/configure.ac b/configure.ac index 1e44068..c836ba0 100644 --- a/configure.ac +++ b/configure.ac @@ -52,7 +52,7 @@ NEED_LIBASSUAN_VERSION=1.1.0 NEED_GPGME_API=1 NEED_GPGME_VERSION=1.5.0 - +AC_CONFIG_AUX_DIR([build-aux]) AM_CONFIG_HEADER(config.h) AC_CONFIG_SRCDIR(src/gpa.c) AM_INIT_AUTOMAKE($PACKAGE_NAME, $PACKAGE_VERSION) @@ -105,6 +105,7 @@ AH_BOTTOM([ AM_MAINTAINER_MODE +AM_SILENT_RULES dnl Check for libraries AC_CHECK_LIB(m, sin) ----------------------------------------------------------------------- Summary of changes: Makefile.am | 2 +- autogen.rc | 14 ++ autogen.sh | 288 ++++++++++++++++++++++++-------- config.guess => build-aux/config.guess | 0 config.rpath => build-aux/config.rpath | 0 config.sub => build-aux/config.sub | 0 depcomp => build-aux/depcomp | 0 install-sh => build-aux/install-sh | 0 mdate-sh => build-aux/mdate-sh | 0 missing => build-aux/missing | 0 configure.ac | 3 +- 11 files changed, 234 insertions(+), 73 deletions(-) create mode 100644 autogen.rc rename config.guess => build-aux/config.guess (100%) rename config.rpath => build-aux/config.rpath (100%) rename config.sub => build-aux/config.sub (100%) rename depcomp => build-aux/depcomp (100%) rename install-sh => build-aux/install-sh (100%) rename mdate-sh => build-aux/mdate-sh (100%) rename missing => build-aux/missing (100%) hooks/post-receive -- The GNU Privacy Assistant http://git.gnupg.org From cvs at cvs.gnupg.org Fri Jan 10 19:03:35 2014 From: cvs at cvs.gnupg.org (by Werner Koch) Date: Fri, 10 Jan 2014 19:03:35 +0100 Subject: [git] GnuPG - branch, master, updated. gnupg-2.1.0beta3-285-g927377b Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The GNU Privacy Guard". The branch, master has been updated via 927377bc91288d121a7d8bdbb3c32d8fc728e9fb (commit) from 1dbf4a7573acf60cb3cfb8b7365c103080138345 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 927377bc91288d121a7d8bdbb3c32d8fc728e9fb Author: Werner Koch Date: Thu Jan 9 19:14:09 2014 +0100 speedo: Add support for gpgex. -- Speedo is now able to build gpgex for Windows. Building gpa for Windows does not yet work due to a bunch of other dependencies. diff --git a/build-aux/speedo.mk b/build-aux/speedo.mk index f18ca44..4870256 100644 --- a/build-aux/speedo.mk +++ b/build-aux/speedo.mk @@ -53,7 +53,16 @@ TARGETOS=native MAKE_J=3 # The packages that should be built. The order is also the build order. -speedo_spkgs = libgpg-error npth libgcrypt libassuan libksba gnupg gpgme gpa +speedo_spkgs = libgpg-error npth libgcrypt libassuan libksba gnupg gpgme + +ifneq ($(TARGETOS),w32) +speedo_spkgs += gpa +endif + +ifeq ($(TARGETOS),w32) +speedo_spkgs += gpgex +endif + # Version numbers of the released packages # Fixme: Take the version numbers from gnupg-doc/web/swdb.mac @@ -65,6 +74,7 @@ libksba_ver = 1.3.0 gnupg_ver = 2.0.22 gpgme_ver = 1.5.0 gpa_ver = 0.9.5 +gpgex_ver = 1.0.0 # The GIT repository. Using a local repo is much faster. #gitrep = git://git.gnupg.org @@ -104,7 +114,7 @@ ifeq ($(WHAT),git) speedo_pkg_libassuan_git = $(gitrep)/libassuan speedo_pkg_libassuan_gitref = master speedo_pkg_libgcrypt_git = $(gitrep)/libgcrypt - speedo_pkg_libgcrypt_gitref = master + speedo_pkg_libgcrypt_gitref = LIBGCRYPT-1-6-BRANCH speedo_pkg_libksba_git = $(gitrep)/libksba speedo_pkg_libksba_gitref = master speedo_pkg_gnupg_git = $(gitrep)/gnupg @@ -113,6 +123,8 @@ ifeq ($(WHAT),git) speedo_pkg_gpgme_gitref = master speedo_pkg_gpa_git = $(gitrep)/gpa speedo_pkg_gpa_gitref = master + speedo_pkg_gpgex_git = $(gitrep)/gpgex + speedo_pkg_gpgex_gitref = master else speedo_pkg_libgpg_error_tar = \ $(pkgrep)/libgpg-error/libgpg-error-$(libgpg_error_ver).tar.bz2 @@ -130,9 +142,13 @@ else $(pkgrep)/gpgme/gpgme-$(gpgme_ver).tar.bz2 speedo_pkg_gpa_tar = \ $(pkgrep)/gpa/gpa-$(gpa_ver).tar.bz2 + speedo_pkg_gpex_tar = \ + $(pkgrep)/gpex/gpgex-$(gpa_ver).tar.bz2 endif -speedo_pkg_pinentry_configure = --disable-pinentry-qt4 +speedo_pkg_libgpg_error_configure = --enable-static + +speedo_pkg_libassuan_configure = --enable-static speedo_pkg_libgcrypt_configure = --disable-static ----------------------------------------------------------------------- Summary of changes: build-aux/speedo.mk | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) hooks/post-receive -- The GNU Privacy Guard http://git.gnupg.org From cvs at cvs.gnupg.org Sun Jan 12 10:08:14 2014 From: cvs at cvs.gnupg.org (by Jussi Kivilinna) Date: Sun, 12 Jan 2014 10:08:14 +0100 Subject: [git] GCRYPT - branch, master, updated. libgcrypt-1.6.0-18-g4337689 Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The GNU crypto library". The branch, master has been updated via 43376891c01f4aff1fbfb23beafebb5adfd0868c (commit) from b0ac1f9b143aa15855914ba93fef900288d45c9c (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 43376891c01f4aff1fbfb23beafebb5adfd0868c Author: Jussi Kivilinna Date: Sun Jan 12 10:53:47 2014 +0200 Fix constant division for AMD64 assembly on Solaris/x86 * configure.ac (gcry_cv_gcc_as_const_division_ok): Add new check for constant division in assembly and test for "-Wa,--divide" workaround. (gcry_cv_gcc_amd64_platform_as_ok): Check for also constant division. -- Appearantly on Solaris/x86 '/' character is treated as begining of line comment by GNU as. This causes problems when compiling SHA-1 SSSE3 implementation: On 02.01.2014 16:26, Richard PALO wrote: >> COLLECT_GCC_OPTIONS='-D' 'HAVE_CONFIG_H' '-I' '.' '-I' '..' '-I' '../src' '-I' '/var/tmp/pkgsrc/security/libgcrypt/work/.buildlink/include' '-I' '/var/tmp/pkgsrc/security/libgcrypt/work/.buildlink/include/gettext' '-D' '_REENTRANT' '-O2' '-MT' 'sha1-ssse3-amd64.lo' '-MD' '-MP' '-MF' '.deps/sha1-ssse3-amd64.Tpo' '-c' '-fPIC' '-D' 'PIC' '-o' '.libs/sha1-ssse3-amd64.o' '-v' '-mtune=generic' '-march=x86-64' >> /usr/gnu/bin/as -v -I . -I .. -I ../src -I /var/tmp/pkgsrc/security/libgcrypt/work/.buildlink/include -I /var/tmp/pkgsrc/security/libgcrypt/work/.buildlink/include/gettext -V -Qy -s --64 -o .libs/sha1-ssse3-amd64.o /var/tmp//ccAxWPXX.s >> GNU assembler version 2.23.1 (i386-pc-solaris2.11) using BFD version (GNU Binutils) 2.23.1 >> /var/tmp//ccAxWPXX.s: Assembler messages: >> /var/tmp//ccAxWPXX.s:34: Error: unbalanced parenthesis in operand 1. >> /var/tmp//ccAxWPXX.s:38: Error: unbalanced parenthesis in operand 1. >> /var/tmp//ccAxWPXX.s:42: Error: unbalanced parenthesis in operand 1. >> /var/tmp//ccAxWPXX.s:46: Error: unbalanced parenthesis in operand 1. >> /var/tmp//ccAxWPXX.s:54: Error: unbalanced parenthesis in operand 1. >> /var/tmp//ccAxWPXX.s:58: Error: unbalanced parenthesis in operand 1. >> /var/tmp//ccAxWPXX.s:62: Error: unbalanced parenthesis in operand 1. >> /var/tmp//ccAxWPXX.s:66: Error: unbalanced parenthesis in operand 1. >> /var/tmp//ccAxWPXX.s:70: Error: unbalanced parenthesis in operand 1. >> /var/tmp//ccAxWPXX.s:74: Error: unbalanced parenthesis in operand 1. >> /var/tmp//ccAxWPXX.s:78: Error: unbalanced parenthesis in operand 1. >> /var/tmp//ccAxWPXX.s:82: Error: unbalanced parenthesis in operand 1. >> /var/tmp//ccAxWPXX.s:86: Error: unbalanced parenthesis in operand 1. >> /var/tmp//ccAxWPXX.s:90: Error: unbalanced parenthesis in operand 1. >> /var/tmp//ccAxWPXX.s:94: Error: unbalanced parenthesis in operand 1. >> /var/tmp//ccAxWPXX.s:98: Error: unbalanced parenthesis in operand 1. >> /var/tmp//ccAxWPXX.s:102: Error: unbalanced parenthesis in operand 1. >> /var/tmp//ccAxWPXX.s:106: Error: unbalanced parenthesis in operand 1. >> /var/tmp//ccAxWPXX.s:110: Error: unbalanced parenthesis in operand 1. >> /var/tmp//ccAxWPXX.s:114: Error: unbalanced parenthesis in operand 1. >> /var/tmp//ccAxWPXX.s:119: Error: unbalanced parenthesis in operand 1. >> /var/tmp//ccAxWPXX.s:123: Error: unbalanced parenthesis in operand 1. >> /var/tmp//ccAxWPXX.s:127: Error: unbalanced parenthesis in operand 1. >> /var/tmp//ccAxWPXX.s:132: Error: unbalanced parenthesis in operand 1. > > > apparently the paddd code, such as > `paddd (.LK_XMM + ((i)/20)*16) RIP, tmp0;` > isn't digested well, appended is the generated assembler code. On 02.01.2014 17:41, Richard PALO wrote: > Hi again, after finding the following: > https://sourceware.org/bugzilla/show_bug.cgi?id=4572 > > I tried using '-Wa,--divide' and that seemed to workaround the problem... > > perhaps the code, or at least the Makefile could be adapted accordingly? Patch adds detection of this feature and attempts to workaround issue with by adding "-Wa,--divide" to CPPFLAGS. If workaround does not work (old GAS on Solaris/x86), we'll disable AMD64 assembly. [v3]: - Update CPPFLAGS after testing instead of CFLAGS. Reported-and-tested-by: Richard PALO Signed-off-by: Jussi Kivilinna diff --git a/configure.ac b/configure.ac index 05cdaf8..fac5f7a 100644 --- a/configure.ac +++ b/configure.ac @@ -1079,11 +1079,42 @@ fi # +# Check whether GCC assembler needs "-Wa,--divide" to correctly handle +# constant division +# +if test $amd64_as_feature_detection = yes; then + AC_CACHE_CHECK([whether GCC assembler handles division correctly], + [gcry_cv_gcc_as_const_division_ok], + [gcry_cv_gcc_as_const_division_ok=no + AC_COMPILE_IFELSE([AC_LANG_SOURCE( + [[__asm__("xorl \$(123456789/12345678), %ebp;\n\t");]])], + [gcry_cv_gcc_as_const_division_ok=yes])]) + if test "$gcry_cv_gcc_as_const_division_ok" = "no" ; then + # + # Add '-Wa,--divide' to CPPFLAGS and try check again. + # + _gcc_cppflags_save="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS -Wa,--divide" + AC_CACHE_CHECK([whether GCC assembler handles division correctly with "-Wa,--divide"], + [gcry_cv_gcc_as_const_division_with_wadivide_ok], + [gcry_cv_gcc_as_const_division_with_wadivide_ok=no + AC_COMPILE_IFELSE([AC_LANG_SOURCE( + [[__asm__("xorl \$(123456789/12345678), %ebp;\n\t");]])], + [gcry_cv_gcc_as_const_division_with_wadivide_ok=yes])]) + if test "$gcry_cv_gcc_as_const_division_ok_with_wadivide_ok" = "no" ; then + # '-Wa,--divide' did not work, restore old flags. + CPPFLAGS="$_gcc_cppflags_save" + fi + fi +fi + + +# # Check whether GCC assembler supports features needed for our amd64 # implementations # if test $amd64_as_feature_detection = yes; then - AC_CACHE_CHECK([whether GCC assembler is compatible for amd64 assembly implementations], + AC_CACHE_CHECK([whether GCC assembler is compatible for amd64 assembly implementations], [gcry_cv_gcc_amd64_platform_as_ok], [gcry_cv_gcc_amd64_platform_as_ok=no AC_COMPILE_IFELSE([AC_LANG_SOURCE( @@ -1096,6 +1127,11 @@ if test $amd64_as_feature_detection = yes; then "asmfunc:\n\t" ".size asmfunc,.-asmfunc;\n\t" ".type asmfunc, at function;\n\t" + /* Test if assembler allows use of '/' for constant division + * (Solaris/x86 issue). If previous constant division check + * and "-Wa,--divide" workaround failed, this causes assembly + * to be disable on this machine. */ + "xorl \$(123456789/12345678), %ebp;\n\t" );]])], [gcry_cv_gcc_amd64_platform_as_ok=yes])]) if test "$gcry_cv_gcc_amd64_platform_as_ok" = "yes" ; then ----------------------------------------------------------------------- Summary of changes: configure.ac | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) hooks/post-receive -- The GNU crypto library http://git.gnupg.org From cvs at cvs.gnupg.org Sun Jan 12 10:45:39 2014 From: cvs at cvs.gnupg.org (by Jussi Kivilinna) Date: Sun, 12 Jan 2014 10:45:39 +0100 Subject: [git] GCRYPT - branch, LIBGCRYPT-1-6-BRANCH, updated. libgcrypt-1.6.0-5-gfb8d851 Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The GNU crypto library". The branch, LIBGCRYPT-1-6-BRANCH has been updated via fb8d8517ffb287c332ead453ab8c8f0519c6129f (commit) via 8302d66d140d5c78c5e808fa1555ed7a8ee27921 (commit) from 79c961592c09409a49e10d860882c81d51163ee3 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit fb8d8517ffb287c332ead453ab8c8f0519c6129f Author: Jussi Kivilinna Date: Sun Jan 5 17:59:22 2014 +0200 * cipher/Makefile.am: Add 'blowfish-arm.S' and 'serpent-armv7-neon.S'. -- Fix for bug https://bugs.g10code.com/gnupg/issue1584 Signed-off-by: Jussi Kivilinna (cherry picked from commit 7fef7f481c0a1542be34d1dc831f58d41846ac29) diff --git a/cipher/Makefile.am b/cipher/Makefile.am index a1718c5..0a62d3c 100644 --- a/cipher/Makefile.am +++ b/cipher/Makefile.am @@ -57,7 +57,7 @@ rmd.h EXTRA_libcipher_la_SOURCES = \ arcfour.c \ -blowfish.c blowfish-amd64.S \ +blowfish.c blowfish-amd64.S blowfish-arm.S \ cast5.c cast5-amd64.S cast5-arm.S \ crc.c \ des.c \ @@ -76,7 +76,7 @@ rsa.c \ salsa20.c salsa20-amd64.S salsa20-armv7-neon.S \ scrypt.c \ seed.c \ -serpent.c serpent-sse2-amd64.S serpent-avx2-amd64.S \ +serpent.c serpent-sse2-amd64.S serpent-avx2-amd64.S serpent-armv7-neon.S \ sha1.c sha1-ssse3-amd64.S \ sha256.c sha256-ssse3-amd64.S \ sha512.c sha512-ssse3-amd64.S sha512-avx-amd64.S sha512-avx2-bmi2-amd64.S \ commit 8302d66d140d5c78c5e808fa1555ed7a8ee27921 Author: Jussi Kivilinna Date: Sun Jan 12 11:31:20 2014 +0200 Fix buggy/incomplete detection of AVX/AVX2 support * configure.ac: Also check for 'xgetbv' instruction in AVX and AVX2 inline assembly checks. * src/hwf-x86.c [__i386__] (get_xgetbv): New function. [__x86_64__] (get_xgetbv): New function. [HAS_X86_CPUID] (detect_x86_gnuc): Check for OSXSAVE and OS support for XMM&YMM registers and enable AVX/AVX2 only if XMM&YMM registers are supported by OS. -- This patch is based on original patch and bug report by Panagiotis Christopoulos: Adding better detection of AVX/AVX2 support After upgrading libgcrypt from 1.5.3 to 1.6.0 on a remote XEN system (linode) my gpg2 stopped working properly, throwing SIGILL signals when doing sha512 operations etc. I managed to debug this with the help of Doublas Freed (dwfreed at mtu.edu) and it seems that the current AVX detection just checks for bit 28 on cpuid but the check still works on systems that have disabled the avx/avx2 instructions for some reason (eg. performance/unstability) resulting in SIGILLs (eg. when trying _gcry_sha512_transform_amd64_avx() ). From Intel resources[1][2], I found additional checks for better AVX detection and applied them in the following patch. Please review/change accordingly and commit some better AVX detection mechanism. The AVX part is tested but could not test the AVX2 one, because I lack proper hardware. I can provide additional information upon request. Use the patch only as a guideline, as it's not thoroughly tested. [1] http://software.intel.com/en-us/blogs/2011/04/14/is-avx-enabled [2] http://www.intel.com/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-manual-325462.pdf (sections 14.3 and 14.7.1) Reported-by: Panagiotis Christopoulos (pchrist) Cc: Doublas Freed Cc: Tim Harder Signed-off-by: Jussi Kivilinna (cherry picked from commit bbcb12187afb1756cb27296166b57fa19ee45d4d) diff --git a/configure.ac b/configure.ac index a47e13e..3387b9a 100644 --- a/configure.ac +++ b/configure.ac @@ -1035,7 +1035,7 @@ AC_CACHE_CHECK([whether GCC inline assembler supports AVX instructions], [gcry_cv_gcc_inline_asm_avx=no AC_COMPILE_IFELSE([AC_LANG_SOURCE( [[void a(void) { - __asm__("vaesdeclast (%[mem]),%%xmm0,%%xmm7\n\t"::[mem]"r"(0):); + __asm__("xgetbv; vaesdeclast (%[mem]),%%xmm0,%%xmm7\n\t"::[mem]"r"(0):); }]])], [gcry_cv_gcc_inline_asm_avx=yes])]) if test "$gcry_cv_gcc_inline_asm_avx" = "yes" ; then @@ -1052,7 +1052,7 @@ AC_CACHE_CHECK([whether GCC inline assembler supports AVX2 instructions], [gcry_cv_gcc_inline_asm_avx2=no AC_COMPILE_IFELSE([AC_LANG_SOURCE( [[void a(void) { - __asm__("vpbroadcastb %%xmm7,%%ymm1\n\t":::"cc"); + __asm__("xgetbv; vpbroadcastb %%xmm7,%%ymm1\n\t":::"cc"); }]])], [gcry_cv_gcc_inline_asm_avx2=yes])]) if test "$gcry_cv_gcc_inline_asm_avx2" = "yes" ; then diff --git a/src/hwf-x86.c b/src/hwf-x86.c index 4e82558..0591b4f 100644 --- a/src/hwf-x86.c +++ b/src/hwf-x86.c @@ -95,6 +95,21 @@ get_cpuid(unsigned int in, unsigned int *eax, unsigned int *ebx, if (edx) *edx = regs[3]; } + +static unsigned int +get_xgetbv(void) +{ + unsigned int t_eax; + + asm volatile + ("xgetbv\n\t" + : "=a" (t_eax) + : "c" (0) + ); + + return t_eax; +} + #endif /* i386 && GNUC */ @@ -129,6 +144,21 @@ get_cpuid(unsigned int in, unsigned int *eax, unsigned int *ebx, if (edx) *edx = regs[3]; } + +static unsigned int +get_xgetbv(void) +{ + unsigned int t_eax; + + asm volatile + ("xgetbv\n\t" + : "=a" (t_eax) + : "c" (0) + ); + + return t_eax; +} + #endif /* x86-64 && GNUC */ @@ -138,9 +168,12 @@ detect_x86_gnuc (void) { char vendor_id[12+1]; unsigned int features; + unsigned int os_supports_avx_avx2_registers = 0; unsigned int max_cpuid_level; unsigned int result = 0; + (void)os_supports_avx_avx2_registers; + if (!is_cpuid_available()) return 0; @@ -215,10 +248,20 @@ detect_x86_gnuc (void) if (features & 0x02000000) result |= HWF_INTEL_AESNI; #endif /*ENABLE_AESNI_SUPPORT*/ +#if defined(ENABLE_AVX_SUPPORT) || defined(ENABLE_AVX2_SUPPORT) + /* Test bit 27 for OSXSAVE (required for AVX/AVX2). */ + if (features & 0x08000000) + { + /* Check that OS has enabled both XMM and YMM state support. */ + if ((get_xgetbv() & 0x6) == 0x6) + os_supports_avx_avx2_registers = 1; + } +#endif #ifdef ENABLE_AVX_SUPPORT /* Test bit 28 for AVX. */ if (features & 0x10000000) - result |= HWF_INTEL_AVX; + if (os_supports_avx_avx2_registers) + result |= HWF_INTEL_AVX; #endif /*ENABLE_AVX_SUPPORT*/ #ifdef ENABLE_DRNG_SUPPORT /* Test bit 30 for RDRAND. */ @@ -242,6 +285,7 @@ detect_x86_gnuc (void) #ifdef ENABLE_AVX2_SUPPORT /* Test bit 5 for AVX2. */ if (features & 0x00000020) + if (os_supports_avx_avx2_registers) result |= HWF_INTEL_AVX2; #endif /*ENABLE_AVX_SUPPORT*/ } ----------------------------------------------------------------------- Summary of changes: cipher/Makefile.am | 4 ++-- configure.ac | 4 ++-- src/hwf-x86.c | 46 +++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 49 insertions(+), 5 deletions(-) hooks/post-receive -- The GNU crypto library http://git.gnupg.org From cvs at cvs.gnupg.org Sun Jan 12 14:04:24 2014 From: cvs at cvs.gnupg.org (by NIIBE Yutaka) Date: Sun, 12 Jan 2014 14:04:24 +0100 Subject: [git] GCRYPT - branch, master, updated. libgcrypt-1.6.0-19-g019e0e9 Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The GNU crypto library". The branch, master has been updated via 019e0e9e8c77a2edf283745e05e9301673ea6a0a (commit) from 43376891c01f4aff1fbfb23beafebb5adfd0868c (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 019e0e9e8c77a2edf283745e05e9301673ea6a0a Author: NIIBE Yutaka Date: Sun Jan 12 21:54:57 2014 +0900 Add secp256k1 curve. * cipher/ecc-curves.c (curve_aliases): Add secp256k1 and its OID. (domain_parms): Add secp256k1's domain paramerter. * tests/basic.c (check_pubkey): Add a key of secp256k1. * tests/curves.c (N_CURVES): Updated. -- The key in check_pubkey is from "Test vector 1" of following page. https://en.bitcoin.it/wiki/BIP_0032_TestVectors Signed-off-by: NIIBE Yutaka diff --git a/cipher/ecc-curves.c b/cipher/ecc-curves.c index ed629fc..a4bce67 100644 --- a/cipher/ecc-curves.c +++ b/cipher/ecc-curves.c @@ -73,6 +73,8 @@ static const struct { "brainpoolP384r1", "1.3.36.3.3.2.8.1.1.11"}, { "brainpoolP512r1", "1.3.36.3.3.2.8.1.1.13"}, + { "secp256k1", "1.3.132.0.10" }, + { NULL, NULL} }; @@ -297,6 +299,17 @@ static const ecc_domain_parms_t domain_parms[] = "c83ab156d77f1496bf7eb3351e1ee4e43dc1a18b91b24640b6dbb92cb1add371e", }, + { + "secp256k1", 256, 0, + MPI_EC_WEIERSTRASS, ECC_DIALECT_STANDARD, + "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000007", + "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141", + "0x79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798", + "0x483ADA7726A3C4655DA4FBFC0E1108A8FD17B448A68554199C47D08FFB10D4B8" + }, + { NULL, 0, 0, 0, 0, NULL, NULL, NULL, NULL } }; diff --git a/tests/basic.c b/tests/basic.c index 0eb8215..56328d1 100644 --- a/tests/basic.c +++ b/tests/basic.c @@ -5901,6 +5901,28 @@ check_pubkey (void) "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" } + }, + { /* secp256k1 test 256 bit. */ + GCRY_PK_ECDSA, FLAG_SIGN, + { + "(private-key\n" + " (ecc\n" + " (curve secp256k1)\n" + " (q #0439A36013301597DAEF41FBE593A02CC513D0B55527EC2D" + " F1050E2E8FF49C85C23CBE7DED0E7CE6A594896B8F62888F" + " DBC5C8821305E2EA42BF01E37300116281#)\n" + " (d #E8F32E723DECF4051AEFAC8E2C93C9C5B214313817CDB01A" + " 1494B917C8436B35#)))\n", + + "(public-key\n" + " (ecc\n" + " (curve secp256k1)\n" + " (q #0439A36013301597DAEF41FBE593A02CC513D0B55527EC2D" + " F1050E2E8FF49C85C23CBE7DED0E7CE6A594896B8F62888F" + " DBC5C8821305E2EA42BF01E37300116281#)))\n" + + "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" + "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" } } }; int i; diff --git a/tests/curves.c b/tests/curves.c index 198693e..04e6bc9 100644 --- a/tests/curves.c +++ b/tests/curves.c @@ -29,7 +29,7 @@ #include "../src/gcrypt-int.h" /* Number of curves defined in ../cipger/ecc.c */ -#define N_CURVES 15 +#define N_CURVES 16 /* A real world sample public key. */ static char const sample_key_1[] = ----------------------------------------------------------------------- Summary of changes: cipher/ecc-curves.c | 13 +++++++++++++ tests/basic.c | 22 ++++++++++++++++++++++ tests/curves.c | 2 +- 3 files changed, 36 insertions(+), 1 deletion(-) hooks/post-receive -- The GNU crypto library http://git.gnupg.org From cvs at cvs.gnupg.org Sun Jan 12 21:02:11 2014 From: cvs at cvs.gnupg.org (by Jussi Kivilinna) Date: Sun, 12 Jan 2014 21:02:11 +0100 Subject: [git] GCRYPT - branch, master, updated. libgcrypt-1.6.0-20-gef3e66e Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The GNU crypto library". The branch, master has been updated via ef3e66e168c4b9b86bfc4903001631e53a7125d8 (commit) from 019e0e9e8c77a2edf283745e05e9301673ea6a0a (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit ef3e66e168c4b9b86bfc4903001631e53a7125d8 Author: Jussi Kivilinna Date: Sun Jan 12 22:01:28 2014 +0200 Fix assembly division check * configure.ac (gcry_cv_gcc_as_const_division_ok): Correct variable name mismatch at '--Wa,--divide' workaround check. -- Signed-off-by: Jussi Kivilinna diff --git a/configure.ac b/configure.ac index fac5f7a..7d37f94 100644 --- a/configure.ac +++ b/configure.ac @@ -1101,7 +1101,7 @@ if test $amd64_as_feature_detection = yes; then AC_COMPILE_IFELSE([AC_LANG_SOURCE( [[__asm__("xorl \$(123456789/12345678), %ebp;\n\t");]])], [gcry_cv_gcc_as_const_division_with_wadivide_ok=yes])]) - if test "$gcry_cv_gcc_as_const_division_ok_with_wadivide_ok" = "no" ; then + if test "$gcry_cv_gcc_as_const_division_with_wadivide_ok" = "no" ; then # '-Wa,--divide' did not work, restore old flags. CPPFLAGS="$_gcc_cppflags_save" fi ----------------------------------------------------------------------- Summary of changes: configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- The GNU crypto library http://git.gnupg.org From cvs at cvs.gnupg.org Mon Jan 13 11:13:46 2014 From: cvs at cvs.gnupg.org (by Werner Koch) Date: Mon, 13 Jan 2014 11:13:46 +0100 Subject: [git] GCRYPT - branch, master, updated. libgcrypt-1.6.0-29-g91d3a2c Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The GNU crypto library". The branch, master has been updated via 91d3a2cc7ed2114b9f1821133eafc79efb55edca (commit) via 9edcf1090e0485f9f383b6c54b18ea8ca3d4a225 (commit) via 2c5ec803100ed8261e51442fb93b75367b7725ea (commit) via 9bedc5c3b646dfe481678ca58f5466ac46decaf7 (commit) via 7edcb574d8d6dffb6e234c2ba1996a9a04923859 (commit) via 653b58cb5e85511b6c04c3f85ef3e372c2e9f74f (commit) via 8439a379c86ef1088465ea70ac10840759a1638e (commit) via 36c9e0e4eb4f935da90df1c8df484d1940bda5eb (commit) via 2ef48ba59c32bfa1a9265d5eea8ab225a658903a (commit) from ef3e66e168c4b9b86bfc4903001631e53a7125d8 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 91d3a2cc7ed2114b9f1821133eafc79efb55edca Author: Werner Koch Date: Thu Jan 9 19:14:09 2014 +0100 Update NEWS. -- diff --git a/NEWS b/NEWS index 878742e..4bf4a06 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,18 @@ Noteworthy changes in version 1.7.0 (unreleased) ------------------------------------------------ + * Fix a 1.6.0 introduced regression in looking up an message digest + by OID. + + * Support curve sec256k1. + + * Support curves GOST R 34.10-2001 and GOST R 34.10-2012. + + * Interface changes relative to the 1.6.0 release: + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + gcry_mac_get_algo NEW. + GCRY_MAC_HMAC_MD2 NEW. + Noteworthy changes in version 1.6.0 (2013-12-16) ------------------------------------------------ commit 9edcf1090e0485f9f383b6c54b18ea8ca3d4a225 Author: Dmitry Eremin-Solenikov Date: Tue Dec 31 00:38:37 2013 +0400 Truncate hash values for ECDSA signature scheme * cipher/dsa-common (_gcry_dsa_normalize_hash): New. Truncate opaque mpis as required for DSA and ECDSA signature schemas. * cipher/dsa.c (verify): Return gpg_err_code_t value from verify() to behave like the rest of internal sign/verify functions. * cipher/dsa.c (sign, verify, dsa_verify): Factor out hash truncation. * cipher/ecc-ecdsa.c (_gcry_ecc_ecdsa_sign): Factor out hash truncation. * cipher/ecc-ecdsa.c (_gcry_ecc_ecdsa_verify): as required by ECDSA scheme, truncate hash values to bitlength of used curve. * tests/pubkey.c (check_ecc_sample_key): add a testcase for hash truncation. Signed-off-by: Dmitry Eremin-Solenikov diff --git a/cipher/dsa-common.c b/cipher/dsa-common.c index d251eae..a5e42a2 100644 --- a/cipher/dsa-common.c +++ b/cipher/dsa-common.c @@ -359,3 +359,36 @@ _gcry_dsa_gen_rfc6979_k (gcry_mpi_t *r_k, *r_k = k; return rc; } + +/* + * Truncate opaque hash value to qbits for DSA. + * Non-opaque input is not truncated, in hope that user + * knows what is passed. It is not possible to correctly + * trucate non-opaque inputs. + */ +gpg_err_code_t +_gcry_dsa_normalize_hash (gcry_mpi_t input, + gcry_mpi_t *out, + unsigned int qbits) +{ + gpg_err_code_t rc = 0; + const void *abuf; + unsigned int abits; + gcry_mpi_t hash; + + if (mpi_is_opaque (input)) + { + abuf = mpi_get_opaque (input, &abits); + rc = _gcry_mpi_scan (&hash, GCRYMPI_FMT_USG, abuf, (abits+7)/8, NULL); + if (rc) + return rc; + if (abits > qbits) + mpi_rshift (hash, hash, abits - qbits); + } + else + hash = input; + + *out = hash; + + return rc; +} diff --git a/cipher/dsa.c b/cipher/dsa.c index 50bdab1..1707d8c 100644 --- a/cipher/dsa.c +++ b/cipher/dsa.c @@ -115,7 +115,7 @@ static gpg_err_code_t generate (DSA_secret_key *sk, gcry_mpi_t **ret_factors); static gpg_err_code_t sign (gcry_mpi_t r, gcry_mpi_t s, gcry_mpi_t input, DSA_secret_key *skey, int flags, int hashalgo); -static int verify (gcry_mpi_t r, gcry_mpi_t s, gcry_mpi_t input, +static gpg_err_code_t verify (gcry_mpi_t r, gcry_mpi_t s, gcry_mpi_t input, DSA_public_key *pkey); static unsigned int dsa_get_nbits (gcry_sexp_t parms); @@ -165,12 +165,12 @@ test_keys (DSA_secret_key *sk, unsigned int qbits) sign (sig_a, sig_b, data, sk, 0, 0); /* Verify the signature using the public key. */ - if ( !verify (sig_a, sig_b, data, &pk) ) + if ( verify (sig_a, sig_b, data, &pk) ) goto leave; /* Signature does not match. */ /* Modify the data and check that the signing fails. */ mpi_add_ui (data, data, 1); - if ( verify (sig_a, sig_b, data, &pk) ) + if ( !verify (sig_a, sig_b, data, &pk) ) goto leave; /* Signature matches but should not. */ result = 0; /* The test succeeded. */ @@ -573,20 +573,9 @@ sign (gcry_mpi_t r, gcry_mpi_t s, gcry_mpi_t input, DSA_secret_key *skey, qbits = mpi_get_nbits (skey->q); /* Convert the INPUT into an MPI. */ - if (mpi_is_opaque (input)) - { - abuf = mpi_get_opaque (input, &abits); - rc = _gcry_mpi_scan (&hash, GCRYMPI_FMT_USG, abuf, (abits+7)/8, NULL); - if (rc) - return rc; - if (abits > qbits) - mpi_rshift (hash, hash, abits - qbits); - } - else - { - mpi_normalize (input); - hash = input; - } + rc = _gcry_dsa_normalize_hash (input, &hash, qbits); + if (rc) + return rc; again: /* Create the K value. */ @@ -651,18 +640,25 @@ sign (gcry_mpi_t r, gcry_mpi_t s, gcry_mpi_t input, DSA_secret_key *skey, /* Returns true if the signature composed from R and S is valid. */ -static int -verify (gcry_mpi_t r, gcry_mpi_t s, gcry_mpi_t hash, DSA_public_key *pkey ) +static gpg_err_code_t +verify (gcry_mpi_t r, gcry_mpi_t s, gcry_mpi_t input, DSA_public_key *pkey ) { - int rc; + gpg_err_code_t rc = 0; gcry_mpi_t w, u1, u2, v; gcry_mpi_t base[3]; gcry_mpi_t ex[3]; + gcry_mpi_t hash; + unsigned int nbits; if( !(mpi_cmp_ui( r, 0 ) > 0 && mpi_cmp( r, pkey->q ) < 0) ) - return 0; /* assertion 0 < r < q failed */ + return GPG_ERR_BAD_SIGNATURE; /* Assertion 0 < r < n failed. */ if( !(mpi_cmp_ui( s, 0 ) > 0 && mpi_cmp( s, pkey->q ) < 0) ) - return 0; /* assertion 0 < s < q failed */ + return GPG_ERR_BAD_SIGNATURE; /* Assertion 0 < s < n failed. */ + + nbits = mpi_get_nbits (pkey->q); + rc = _gcry_dsa_normalize_hash (input, &hash, nbits); + if (rc) + return rc; w = mpi_alloc( mpi_get_nlimbs(pkey->q) ); u1 = mpi_alloc( mpi_get_nlimbs(pkey->q) ); @@ -685,12 +681,25 @@ verify (gcry_mpi_t r, gcry_mpi_t s, gcry_mpi_t hash, DSA_public_key *pkey ) mpi_mulpowm( v, base, ex, pkey->p ); mpi_fdiv_r( v, v, pkey->q ); - rc = !mpi_cmp( v, r ); + if (mpi_cmp( v, r )) + { + if (DBG_CIPHER) + { + log_mpidump (" i", input); + log_mpidump (" h", hash); + log_mpidump (" v", v); + log_mpidump (" r", r); + log_mpidump (" s", s); + } + rc = GPG_ERR_BAD_SIGNATURE; + } mpi_free(w); mpi_free(u1); mpi_free(u2); mpi_free(v); + if (hash != input) + mpi_free (hash); return rc; } @@ -1090,31 +1099,7 @@ dsa_verify (gcry_sexp_t s_sig, gcry_sexp_t s_data, gcry_sexp_t s_keyparms) } /* Verify the signature. */ - if (mpi_is_opaque (data)) - { - const void *abuf; - unsigned int abits, qbits; - gcry_mpi_t a; - - qbits = mpi_get_nbits (pk.q); - - abuf = mpi_get_opaque (data, &abits); - rc = _gcry_mpi_scan (&a, GCRYMPI_FMT_USG, abuf, (abits+7)/8, NULL); - if (!rc) - { - if (abits > qbits) - mpi_rshift (a, a, abits - qbits); - - if (!verify (sig_r, sig_s, a, &pk)) - rc = GPG_ERR_BAD_SIGNATURE; - _gcry_mpi_release (a); - } - } - else - { - if (!verify (sig_r, sig_s, data, &pk)) - rc = GPG_ERR_BAD_SIGNATURE; - } + rc = verify (sig_r, sig_s, data, &pk); leave: _gcry_mpi_release (pk.p); diff --git a/cipher/ecc-ecdsa.c b/cipher/ecc-ecdsa.c index b4bbe2c..1484830 100644 --- a/cipher/ecc-ecdsa.c +++ b/cipher/ecc-ecdsa.c @@ -57,18 +57,9 @@ _gcry_ecc_ecdsa_sign (gcry_mpi_t input, ECC_secret_key *skey, qbits = mpi_get_nbits (skey->E.n); /* Convert the INPUT into an MPI if needed. */ - if (mpi_is_opaque (input)) - { - abuf = mpi_get_opaque (input, &abits); - rc = _gcry_mpi_scan (&hash, GCRYMPI_FMT_USG, abuf, (abits+7)/8, NULL); - if (rc) - return rc; - if (abits > qbits) - mpi_rshift (hash, hash, abits - qbits); - } - else - hash = input; - + rc = _gcry_dsa_normalize_hash (input, &hash, qbits); + if (rc) + return rc; k = NULL; dr = mpi_alloc (0); @@ -161,15 +152,21 @@ _gcry_ecc_ecdsa_verify (gcry_mpi_t input, ECC_public_key *pkey, gcry_mpi_t r, gcry_mpi_t s) { gpg_err_code_t err = 0; - gcry_mpi_t h, h1, h2, x; + gcry_mpi_t hash, h, h1, h2, x; mpi_point_struct Q, Q1, Q2; mpi_ec_t ctx; + unsigned int nbits; if( !(mpi_cmp_ui (r, 0) > 0 && mpi_cmp (r, pkey->E.n) < 0) ) return GPG_ERR_BAD_SIGNATURE; /* Assertion 0 < r < n failed. */ if( !(mpi_cmp_ui (s, 0) > 0 && mpi_cmp (s, pkey->E.n) < 0) ) return GPG_ERR_BAD_SIGNATURE; /* Assertion 0 < s < n failed. */ + nbits = mpi_get_nbits (pkey->E.n); + err = _gcry_dsa_normalize_hash (input, &hash, nbits); + if (err) + return err; + h = mpi_alloc (0); h1 = mpi_alloc (0); h2 = mpi_alloc (0); @@ -184,7 +181,7 @@ _gcry_ecc_ecdsa_verify (gcry_mpi_t input, ECC_public_key *pkey, /* h = s^(-1) (mod n) */ mpi_invm (h, s, pkey->E.n); /* h1 = hash * s^(-1) (mod n) */ - mpi_mulm (h1, input, h, pkey->E.n); + mpi_mulm (h1, hash, h, pkey->E.n); /* Q1 = [ hash * s^(-1) ]G */ _gcry_mpi_ec_mul_point (&Q1, h1, &pkey->E.G, ctx); /* h2 = r * s^(-1) (mod n) */ @@ -230,5 +227,8 @@ _gcry_ecc_ecdsa_verify (gcry_mpi_t input, ECC_public_key *pkey, mpi_free (h2); mpi_free (h1); mpi_free (h); + if (hash != input) + mpi_free (hash); + return err; } diff --git a/cipher/pubkey-internal.h b/cipher/pubkey-internal.h index db1399d..193248c 100644 --- a/cipher/pubkey-internal.h +++ b/cipher/pubkey-internal.h @@ -88,6 +88,9 @@ gpg_err_code_t _gcry_dsa_gen_rfc6979_k (gcry_mpi_t *r_k, int halgo, unsigned int extraloops); +gpg_err_code_t _gcry_dsa_normalize_hash (gcry_mpi_t input, + gcry_mpi_t *out, + unsigned int qbits); /*-- ecc.c --*/ gpg_err_code_t _gcry_pk_ecc_get_sexp (gcry_sexp_t *r_sexp, int mode, diff --git a/tests/pubkey.c b/tests/pubkey.c index 4e12dfd..ae5eea2 100644 --- a/tests/pubkey.c +++ b/tests/pubkey.c @@ -980,9 +980,23 @@ check_ecc_sample_key (void) "(data (flags raw)\n" " (value #00112233445566778899AABBCCDDEEFF" /* */ "000102030405060708090A0B0C0D0E0F#))"; + static const char hash2_string[] = + "(data (flags raw)\n" + " (hash sha1 #00112233445566778899AABBCCDDEEFF" + /* */ "000102030405060708090A0B0C0D0E0F" + /* */ "000102030405060708090A0B0C0D0E0F" + /* */ "00112233445566778899AABBCCDDEEFF#))"; + /* hash2, but longer than curve length, so it will be truncated */ + static const char hash3_string[] = + "(data (flags raw)\n" + " (hash sha1 #00112233445566778899AABBCCDDEEFF" + /* */ "000102030405060708090A0B0C0D0E0F" + /* */ "000102030405060708090A0B0C0D0E0F" + /* */ "00112233445566778899AABBCCDDEEFF" + /* */ "000102030405060708090A0B0C0D0E0F#))"; gpg_error_t err; - gcry_sexp_t key, hash, sig; + gcry_sexp_t key, hash, hash2, hash3, sig, sig2; if (verbose) fprintf (stderr, "Checking sample ECC key.\n"); @@ -990,6 +1004,12 @@ check_ecc_sample_key (void) if ((err = gcry_sexp_new (&hash, hash_string, 0, 1))) die ("line %d: %s", __LINE__, gpg_strerror (err)); + if ((err = gcry_sexp_new (&hash2, hash2_string, 0, 1))) + die ("line %d: %s", __LINE__, gpg_strerror (err)); + + if ((err = gcry_sexp_new (&hash3, hash3_string, 0, 1))) + die ("line %d: %s", __LINE__, gpg_strerror (err)); + if ((err = gcry_sexp_new (&key, ecc_private_key, 0, 1))) die ("line %d: %s", __LINE__, gpg_strerror (err)); @@ -1003,6 +1023,28 @@ check_ecc_sample_key (void) if ((err = gcry_pk_verify (sig, hash, key))) die ("gcry_pk_verify failed: %s", gpg_strerror (err)); + /* Verify hash truncation */ + gcry_sexp_release (key); + if ((err = gcry_sexp_new (&key, ecc_private_key, 0, 1))) + die ("line %d: %s", __LINE__, gpg_strerror (err)); + + if ((err = gcry_pk_sign (&sig2, hash2, key))) + die ("gcry_pk_sign failed: %s", gpg_strerror (err)); + + gcry_sexp_release (sig); + if ((err = gcry_pk_sign (&sig, hash3, key))) + die ("gcry_pk_sign failed: %s", gpg_strerror (err)); + + gcry_sexp_release (key); + if ((err = gcry_sexp_new (&key, ecc_public_key, 0, 1))) + die ("line %d: %s", __LINE__, gpg_strerror (err)); + + if ((err = gcry_pk_verify (sig, hash2, key))) + die ("gcry_pk_verify failed: %s", gpg_strerror (err)); + + if ((err = gcry_pk_verify (sig2, hash3, key))) + die ("gcry_pk_verify failed: %s", gpg_strerror (err)); + /* Now try signing without the Q parameter. */ gcry_sexp_release (key); @@ -1021,8 +1063,11 @@ check_ecc_sample_key (void) die ("gcry_pk_verify signed without Q failed: %s", gpg_strerror (err)); gcry_sexp_release (sig); + gcry_sexp_release (sig2); gcry_sexp_release (key); gcry_sexp_release (hash); + gcry_sexp_release (hash2); + gcry_sexp_release (hash3); } commit 2c5ec803100ed8261e51442fb93b75367b7725ea Author: Dmitry Eremin-Solenikov Date: Tue Dec 31 00:39:58 2013 +0400 Add GOST R 34.10-2012 curves proposed by TC26 * cipher/ecc-curves.c (domain_parmss): Add two GOST R 34.10-2012 curves proposed/pending to standardization by TC26 (Russian cryptography technical comitee). * cipher/ecc-curves.c (curve_alias): Add OID aliases. * tests/curves.c: Increase N_CURVES. Signed-off-by: Dmitry Eremin-Solenikov diff --git a/cipher/ecc-curves.c b/cipher/ecc-curves.c index 5e2d9a4..dc74ee0 100644 --- a/cipher/ecc-curves.c +++ b/cipher/ecc-curves.c @@ -82,6 +82,9 @@ static const struct { "GOST2001-CryptoPro-A", "1.2.643.2.2.36.0" }, { "GOST2001-CryptoPro-C", "1.2.643.2.2.36.1" }, + { "GOST2012-tc26-A", "1.2.643.7.1.2.1.2.1" }, + { "GOST2012-tc26-B", "1.2.643.7.1.2.1.2.2" }, + { "secp256k1", "1.3.132.0.10" }, { NULL, NULL} @@ -352,6 +355,38 @@ static const ecc_domain_parms_t domain_parms[] = "0x2bb312a43bd2ce6e0d020613c857acddcfbf061e91e5f2c3f32447c259f39b2" "c83ab156d77f1496bf7eb3351e1ee4e43dc1a18b91b24640b6dbb92cb1add371e", }, + { + "GOST2012-tc26-A", 512, 0, + MPI_EC_WEIERSTRASS, ECC_DIALECT_STANDARD, + "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" + "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc7", + "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" + "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc4", + "0xe8c2505dedfc86ddc1bd0b2b6667f1da34b82574761cb0e879bd081cfd0b6265" + "ee3cb090f30d27614cb4574010da90dd862ef9d4ebee4761503190785a71c760", + "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" + "27e69532f48d89116ff22b8d4e0560609b4b38abfad2b85dcacdb1411f10b275", + "0x0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000003", + "0x7503cfe87a836ae3a61b8816e25450e6ce5e1c93acf1abc1778064fdcbefa921" + "df1626be4fd036e93d75e6a50e3a41e98028fe5fc235f5b889a589cb5215f2a4", + }, + { + "GOST2012-tc26-B", 512, 0, + MPI_EC_WEIERSTRASS, ECC_DIALECT_STANDARD, + "0x8000000000000000000000000000000000000000000000000000000000000000" + "000000000000000000000000000000000000000000000000000000000000006f", + "0x8000000000000000000000000000000000000000000000000000000000000000" + "000000000000000000000000000000000000000000000000000000000000006c", + "0x687d1b459dc841457e3e06cf6f5e2517b97c7d614af138bcbf85dc806c4b289f" + "3e965d2db1416d217f8b276fad1ab69c50f78bee1fa3106efb8ccbc7c5140116", + "0x8000000000000000000000000000000000000000000000000000000000000001" + "49a1ec142565a545acfdb77bd9d40cfa8b996712101bea0ec6346c54374f25bd", + "0x0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000002", + "0x1a8f7eda389b094c2c071e3647a8940f3c123b697578c213be6dd9e6c8ec7335" + "dcb228fd1edf4a39152cbcaaf8c0398828041055f94ceeec7e21340780fe41bd", + }, { "secp256k1", 256, 0, diff --git a/tests/curves.c b/tests/curves.c index de5ae46..0581452 100644 --- a/tests/curves.c +++ b/tests/curves.c @@ -29,7 +29,7 @@ #include "../src/gcrypt-int.h" /* Number of curves defined in ../cipger/ecc.c */ -#define N_CURVES 19 +#define N_CURVES 21 /* A real world sample public key. */ static char const sample_key_1[] = commit 9bedc5c3b646dfe481678ca58f5466ac46decaf7 Author: Dmitry Eremin-Solenikov Date: Tue Dec 31 00:39:57 2013 +0400 Add GOST R 34.10-2001 curves per RFC4357 * cipher/ecc-curves.c (domain_parms): Add 3 curves defined in rfc4357. * cipher/ecc-curves.c (curve_aliases): Add OID and Xch aliases for GOST curves. * tests/curves.c (N_CURVES): Update value. Signed-off-by: Dmitry Eremin-Solenikov diff --git a/cipher/ecc-curves.c b/cipher/ecc-curves.c index 9016ec6..5e2d9a4 100644 --- a/cipher/ecc-curves.c +++ b/cipher/ecc-curves.c @@ -73,6 +73,15 @@ static const struct { "brainpoolP384r1", "1.3.36.3.3.2.8.1.1.11"}, { "brainpoolP512r1", "1.3.36.3.3.2.8.1.1.13"}, + { "GOST2001-test", "1.2.643.2.2.35.0" }, + { "GOST2001-CryptoPro-A", "1.2.643.2.2.35.1" }, + { "GOST2001-CryptoPro-B", "1.2.643.2.2.35.2" }, + { "GOST2001-CryptoPro-C", "1.2.643.2.2.35.3" }, + { "GOST2001-CryptoPro-A", "GOST2001-CryptoPro-XchA" }, + { "GOST2001-CryptoPro-C", "GOST2001-CryptoPro-XchB" }, + { "GOST2001-CryptoPro-A", "1.2.643.2.2.36.0" }, + { "GOST2001-CryptoPro-C", "1.2.643.2.2.36.1" }, + { "secp256k1", "1.3.132.0.10" }, { NULL, NULL} @@ -297,7 +306,36 @@ static const ecc_domain_parms_t domain_parms[] = "0x0000000000000000000000000000000000000000000000000000000000000002", "0x08e2a8a0e65147d4bd6316030e16d19c85c97f0a9ca267122b96abbcea7e8fc8", }, - + { + "GOST2001-CryptoPro-A", 256, 0, + MPI_EC_WEIERSTRASS, ECC_DIALECT_STANDARD, + "0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd97", + "0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd94", + "0x00000000000000000000000000000000000000000000000000000000000000a6", + "0xffffffffffffffffffffffffffffffff6c611070995ad10045841b09b761b893", + "0x0000000000000000000000000000000000000000000000000000000000000001", + "0x8d91e471e0989cda27df505a453f2b7635294f2ddf23e3b122acc99c9e9f1e14" + }, + { + "GOST2001-CryptoPro-B", 256, 0, + MPI_EC_WEIERSTRASS, ECC_DIALECT_STANDARD, + "0x8000000000000000000000000000000000000000000000000000000000000c99", + "0x8000000000000000000000000000000000000000000000000000000000000c96", + "0x3e1af419a269a5f866a7d3c25c3df80ae979259373ff2b182f49d4ce7e1bbc8b", + "0x800000000000000000000000000000015f700cfff1a624e5e497161bcc8a198f", + "0x0000000000000000000000000000000000000000000000000000000000000001", + "0x3fa8124359f96680b83d1c3eb2c070e5c545c9858d03ecfb744bf8d717717efc" + }, + { + "GOST2001-CryptoPro-C", 256, 0, + MPI_EC_WEIERSTRASS, ECC_DIALECT_STANDARD, + "0x9b9f605f5a858107ab1ec85e6b41c8aacf846e86789051d37998f7b9022d759b", + "0x9b9f605f5a858107ab1ec85e6b41c8aacf846e86789051d37998f7b9022d7598", + "0x000000000000000000000000000000000000000000000000000000000000805a", + "0x9b9f605f5a858107ab1ec85e6b41c8aa582ca3511eddfb74f02f3a6598980bb9", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x41ece55743711a8c3cbf3783cd08c0ee4d4dc440d4641a8f366e550dfdb3bb67" + }, { "GOST2012-test", 511, 0, MPI_EC_WEIERSTRASS, ECC_DIALECT_STANDARD, diff --git a/tests/curves.c b/tests/curves.c index 04e6bc9..de5ae46 100644 --- a/tests/curves.c +++ b/tests/curves.c @@ -29,7 +29,7 @@ #include "../src/gcrypt-int.h" /* Number of curves defined in ../cipger/ecc.c */ -#define N_CURVES 16 +#define N_CURVES 19 /* A real world sample public key. */ static char const sample_key_1[] = commit 7edcb574d8d6dffb6e234c2ba1996a9a04923859 Author: Dmitry Eremin-Solenikov Date: Tue Dec 31 00:39:56 2013 +0400 Fix typo in search_oid * cipher/md.c (search_oid): Invert condition on oid comparison. -- Function stricmp() returns 0 in case strings match, so proper condition that checks for matching OID strings should be if (!stricmp(...)) Signed-off-by: Dmitry Eremin-Solenikov diff --git a/cipher/md.c b/cipher/md.c index d9c1ad4..1b59765 100644 --- a/cipher/md.c +++ b/cipher/md.c @@ -195,7 +195,7 @@ search_oid (const char *oid, gcry_md_oid_spec_t *oid_spec) if (spec && spec->oids) { for (i = 0; spec->oids[i].oidstring; i++) - if (stricmp (oid, spec->oids[i].oidstring)) + if (!stricmp (oid, spec->oids[i].oidstring)) { if (oid_spec) *oid_spec = spec->oids[i]; commit 653b58cb5e85511b6c04c3f85ef3e372c2e9f74f Author: Dmitry Eremin-Solenikov Date: Fri Dec 27 12:37:12 2013 +0400 Add MD2-HMAC calculation support * src/gcrypt.h.in (GCRY_MAC_HMAC_MD2): New. * cipher/mac-hmac.c: Support GCRY_MAC_HMAC_MD2. Signed-off-by: Dmitry Eremin-Solenikov diff --git a/cipher/mac-hmac.c b/cipher/mac-hmac.c index 5edd7e8..2c660e9 100644 --- a/cipher/mac-hmac.c +++ b/cipher/mac-hmac.c @@ -35,6 +35,8 @@ map_mac_algo_to_md (int mac_algo) { default: return GCRY_MD_NONE; + case GCRY_MAC_HMAC_MD2: + return GCRY_MD_MD2; case GCRY_MAC_HMAC_MD4: return GCRY_MD_MD4; case GCRY_MAC_HMAC_MD5: @@ -270,3 +272,9 @@ gcry_mac_spec_t _gcry_mac_type_spec_hmac_md4 = { &hmac_ops }; #endif +#if USE_MD2 +gcry_mac_spec_t _gcry_mac_type_spec_hmac_md2 = { + GCRY_MAC_HMAC_MD2, {0, 0}, "HMAC_MD2", + &hmac_ops +}; +#endif diff --git a/src/gcrypt.h.in b/src/gcrypt.h.in index 402e4fd..f8318c0 100644 --- a/src/gcrypt.h.in +++ b/src/gcrypt.h.in @@ -1319,6 +1319,7 @@ enum gcry_mac_algos GCRY_MAC_HMAC_GOSTR3411_94 = 111, GCRY_MAC_HMAC_STRIBOG256 = 112, GCRY_MAC_HMAC_STRIBOG512 = 113, + GCRY_MAC_HMAC_MD2 = 114, GCRY_MAC_CMAC_AES = 201, GCRY_MAC_CMAC_3DES = 202, commit 8439a379c86ef1088465ea70ac10840759a1638e Author: Dmitry Eremin-Solenikov Date: Fri Dec 27 12:37:11 2013 +0400 Add a function to retrieve algorithm used by MAC handler * cipher/mac.c (_gcry_mac_get_algo): New function, returns used algo. * src/visibility.c (gcry_mac_get_algo): New wrapper. * src/visibility.h: Hanlde gcry_mac_get_algo. * src/gcrypt-int.h (_gcry_mac_get_algo): New. * src/gcrypt.h.in (gcry_mac_get_algo): New. * src/libgcrypt.def (gcry_mac_get_algo): New. * src/libgcrypt.vers (gcry_mac_get_algo): New. * doc/gcrypt.texi: Document gcry_mac_get_algo. * tests/basic.c (check_one_mac): Verify gcry_mac_get_algo. Signed-off-by: Dmitry Eremin-Solenikov diff --git a/cipher/mac.c b/cipher/mac.c index 3daf2ee..7805467 100644 --- a/cipher/mac.c +++ b/cipher/mac.c @@ -369,6 +369,13 @@ _gcry_mac_verify (gcry_mac_hd_t hd, const void *buf, size_t buflen) } +int +_gcry_mac_get_algo (gcry_mac_hd_t hd) +{ + return hd->algo; +} + + unsigned int _gcry_mac_get_algo_maclen (int algo) { diff --git a/doc/gcrypt.texi b/doc/gcrypt.texi index ce17c8e..25d8227 100644 --- a/doc/gcrypt.texi +++ b/doc/gcrypt.texi @@ -3722,6 +3722,16 @@ the MAC calculated in object @var{h}. @end deftypefun +In some situations it might be hard to remember the algorithm used for +the MAC calculation. The following function might be used to get that +information: + + at deftypefun {int} gcry_mac_get_algo (gcry_mac_hd_t @var{h}) + +Retrieve the algorithm used with the handle @var{h}. + at end deftypefun + + @c *********************************** @c ***** MAC info functions ********** @c *********************************** diff --git a/src/gcrypt-int.h b/src/gcrypt-int.h index 65dcb4d..8a6df84 100644 --- a/src/gcrypt-int.h +++ b/src/gcrypt-int.h @@ -180,6 +180,7 @@ gpg_err_code_t _gcry_mac_write (gcry_mac_hd_t hd, const void *buffer, gpg_err_code_t _gcry_mac_read (gcry_mac_hd_t hd, void *buffer, size_t *buflen); gpg_err_code_t _gcry_mac_verify (gcry_mac_hd_t hd, const void *buffer, size_t buflen); +int _gcry_mac_get_algo (gcry_mac_hd_t hd); unsigned int _gcry_mac_get_algo_maclen (int algo); unsigned int _gcry_mac_get_algo_keylen (int algo); const char *_gcry_mac_algo_name (int algorithm) _GCRY_GCC_ATTR_PURE; diff --git a/src/gcrypt.h.in b/src/gcrypt.h.in index 5c771e5..402e4fd 100644 --- a/src/gcrypt.h.in +++ b/src/gcrypt.h.in @@ -1382,6 +1382,9 @@ gcry_error_t gcry_mac_read (gcry_mac_hd_t hd, void *buffer, size_t *buflen); gcry_error_t gcry_mac_verify (gcry_mac_hd_t hd, const void *buffer, size_t buflen); +/* Retrieve the algorithm used with MAC. */ +int gcry_mac_get_algo (gcry_mac_hd_t hd); + /* Retrieve the length in bytes of the MAC yielded by algorithm ALGO. */ unsigned int gcry_mac_get_algo_maclen (int algo); diff --git a/src/libgcrypt.def b/src/libgcrypt.def index a90efce..57ed490 100644 --- a/src/libgcrypt.def +++ b/src/libgcrypt.def @@ -274,6 +274,7 @@ EXPORTS gcry_mac_read @240 gcry_mac_verify @241 gcry_mac_ctl @242 + gcry_mac_get_algo @243 ;; end of file with public symbols for Windows. diff --git a/src/libgcrypt.vers b/src/libgcrypt.vers index 5118c81..7ee0541 100644 --- a/src/libgcrypt.vers +++ b/src/libgcrypt.vers @@ -54,7 +54,7 @@ GCRYPT_1.6 { gcry_cipher_authenticate; gcry_cipher_gettag; gcry_cipher_checktag; gcry_mac_algo_info; gcry_mac_algo_name; gcry_mac_map_name; - gcry_mac_get_algo_maclen; gcry_mac_get_algo_keylen; + gcry_mac_get_algo_maclen; gcry_mac_get_algo_keylen; gcry_mac_get_algo; gcry_mac_open; gcry_mac_close; gcry_mac_setkey; gcry_mac_setiv; gcry_mac_write; gcry_mac_read; gcry_mac_verify; gcry_mac_ctl; diff --git a/src/visibility.c b/src/visibility.c index 2989498..6ed57ca 100644 --- a/src/visibility.c +++ b/src/visibility.c @@ -855,6 +855,12 @@ gcry_mac_map_name (const char *string) return _gcry_mac_map_name (string); } +int +gcry_mac_get_algo (gcry_mac_hd_t hd) +{ + return _gcry_mac_get_algo (hd); +} + unsigned int gcry_mac_get_algo_maclen (int algo) { diff --git a/src/visibility.h b/src/visibility.h index 4127a43..96b5235 100644 --- a/src/visibility.h +++ b/src/visibility.h @@ -137,6 +137,7 @@ MARK_VISIBLEX (gcry_cipher_open) MARK_VISIBLEX (gcry_mac_algo_info) MARK_VISIBLEX (gcry_mac_algo_name) MARK_VISIBLEX (gcry_mac_map_name) +MARK_VISIBLEX (gcry_mac_get_algo) MARK_VISIBLEX (gcry_mac_get_algo_maclen) MARK_VISIBLEX (gcry_mac_get_algo_keylen) MARK_VISIBLEX (gcry_mac_open) @@ -380,6 +381,7 @@ MARK_VISIBLEX (_gcry_mpi_get_const) #define gcry_mac_algo_info _gcry_USE_THE_UNDERSCORED_FUNCTION #define gcry_mac_algo_name _gcry_USE_THE_UNDERSCORED_FUNCTION #define gcry_mac_map_name _gcry_USE_THE_UNDERSCORED_FUNCTION +#define gcry_mac_get_algo _gcry_USE_THE_UNDERSCORED_FUNCTION #define gcry_mac_get_algo_maclen _gcry_USE_THE_UNDERSCORED_FUNCTION #define gcry_mac_get_algo_keylen _gcry_USE_THE_UNDERSCORED_FUNCTION #define gcry_mac_open _gcry_USE_THE_UNDERSCORED_FUNCTION diff --git a/tests/basic.c b/tests/basic.c index 56328d1..697485e 100644 --- a/tests/basic.c +++ b/tests/basic.c @@ -4469,6 +4469,12 @@ check_one_mac (int algo, const char *data, int datalen, return; } + i = gcry_mac_get_algo (hd); + if (i != algo) + { + fail ("algo %d, gcry_mac_get_algo failed: %d\n", algo, i); + } + maclen = gcry_mac_get_algo_maclen (algo); if (maclen < 1 || maclen > 500) { commit 36c9e0e4eb4f935da90df1c8df484d1940bda5eb Author: Dmitry Eremin-Solenikov Date: Fri Dec 27 12:37:10 2013 +0400 Correct formatting of gcry_mac_get_algo_keylen documentation * doc/gcrypt.texi: add braces near gcry_mac_get_algo_keylen documentation. Use braces around unsigned int in gcry_mac_get_algo_keylen documentation, otherwise texinfo breaks that and uses 'int' as a function definition. Signed-off-by: Dmitry Eremin-Solenikov diff --git a/doc/gcrypt.texi b/doc/gcrypt.texi index cef6318..ce17c8e 100644 --- a/doc/gcrypt.texi +++ b/doc/gcrypt.texi @@ -3767,7 +3767,7 @@ for the MAC value. On error @code{0} is returned. @end deftypefun - at deftypefun unsigned int gcry_mac_get_algo_keylen (@var{algo}) + at deftypefun {unsigned int} gcry_mac_get_algo_keylen (@var{algo}) This function returns length of the key for MAC algorithm @var{algo}. If the algorithm supports multiple key lengths, the default supported key commit 2ef48ba59c32bfa1a9265d5eea8ab225a658903a Author: Werner Koch Date: Thu Jan 9 19:14:09 2014 +0100 ecc: Make a macro shorter. * src/mpi.h (MPI_EC_TWISTEDEDWARDS): Rename to MPI_EC_EDWARDS. CHnage all users. * cipher/ecc-curves.c (domain_parms): Add parameters for Curve3617 as comment. * mpi/ec.c (dup_point_twistededwards): Rename to dup_point_edwards. (add_points_twistededwards): Rename to add_points_edwards. Signed-off-by: Werner Koch diff --git a/cipher/ecc-curves.c b/cipher/ecc-curves.c index a4bce67..9016ec6 100644 --- a/cipher/ecc-curves.c +++ b/cipher/ecc-curves.c @@ -107,7 +107,7 @@ static const ecc_domain_parms_t domain_parms[] = { /* (-x^2 + y^2 = 1 + dx^2y^2) */ "Ed25519", 256, 0, - MPI_EC_TWISTEDEDWARDS, ECC_DIALECT_ED25519, + MPI_EC_EDWARDS, ECC_DIALECT_ED25519, "0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFED", "-0x01", "-0x2DFC9311D490018C7338BF8688861767FF8FF5B2BEBE27548A14B235ECA6874A", @@ -115,6 +115,22 @@ static const ecc_domain_parms_t domain_parms[] = "0x216936D3CD6E53FEC0A4E231FDD6DC5C692CC7609525A7B2C9562D608F25D51A", "0x6666666666666666666666666666666666666666666666666666666666666658" }, +#if 0 /* No real specs yet found. */ + { + /* x^2 + y^2 = 1 + 3617x^2y^2 mod 2^414 - 17 */ + "Curve3617", + "0x3FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEF", + MPI_EC_EDWARDS, 0, + "0x01", + "0x0e21", + "0x07FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEB3CC92414CF" + "706022B36F1C0338AD63CF181B0E71A5E106AF79", + "0x1A334905141443300218C0631C326E5FCD46369F44C03EC7F57FF35498A4AB4D" + "6D6BA111301A73FAA8537C64C4FD3812F3CBC595", + "0x22" + }, +#endif /*0*/ { "NIST P-192", 192, 1, MPI_EC_WEIERSTRASS, ECC_DIALECT_STANDARD, @@ -417,7 +433,7 @@ _gcry_ecc_fill_in_curve (unsigned int nbits, const char *name, switch (domain_parms[idx].model) { case MPI_EC_WEIERSTRASS: - case MPI_EC_TWISTEDEDWARDS: + case MPI_EC_EDWARDS: break; case MPI_EC_MONTGOMERY: return GPG_ERR_NOT_SUPPORTED; @@ -1038,7 +1054,7 @@ _gcry_ecc_get_mpi (const char *name, mpi_ec_t ec, int copy) if (name[1] != '@') return _gcry_mpi_ec_ec2os (ec->Q, ec); - if (!strcmp (name+2, "eddsa") && ec->model == MPI_EC_TWISTEDEDWARDS) + if (!strcmp (name+2, "eddsa") && ec->model == MPI_EC_EDWARDS) { unsigned char *encpk; unsigned int encpklen; diff --git a/cipher/ecc-misc.c b/cipher/ecc-misc.c index 7b750c0..3f284fe 100644 --- a/cipher/ecc-misc.c +++ b/cipher/ecc-misc.c @@ -79,7 +79,7 @@ _gcry_ecc_model2str (enum gcry_mpi_ec_models model) { case MPI_EC_WEIERSTRASS: str = "Weierstrass"; break; case MPI_EC_MONTGOMERY: str = "Montgomery"; break; - case MPI_EC_TWISTEDEDWARDS: str = "Twisted Edwards"; break; + case MPI_EC_EDWARDS: str = "Edwards"; break; } return str; } @@ -252,7 +252,7 @@ _gcry_ecc_compute_public (mpi_point_t Q, mpi_ec_t ec, if (!d || !G || !ec->p || !ec->a) return NULL; - if (ec->model == MPI_EC_TWISTEDEDWARDS && !ec->b) + if (ec->model == MPI_EC_EDWARDS && !ec->b) return NULL; if (ec->dialect == ECC_DIALECT_ED25519 diff --git a/cipher/ecc.c b/cipher/ecc.c index 06bfb47..0e5776c 100644 --- a/cipher/ecc.c +++ b/cipher/ecc.c @@ -643,7 +643,7 @@ ecc_check_secret_key (gcry_sexp_t keyparms) if (!curvename) { sk.E.model = ((flags & PUBKEY_FLAG_EDDSA) - ? MPI_EC_TWISTEDEDWARDS + ? MPI_EC_EDWARDS : MPI_EC_WEIERSTRASS); sk.E.dialect = ((flags & PUBKEY_FLAG_EDDSA) ? ECC_DIALECT_ED25519 @@ -775,7 +775,7 @@ ecc_sign (gcry_sexp_t *r_sig, gcry_sexp_t s_data, gcry_sexp_t keyparms) if (!curvename) { sk.E.model = ((ctx.flags & PUBKEY_FLAG_EDDSA) - ? MPI_EC_TWISTEDEDWARDS + ? MPI_EC_EDWARDS : MPI_EC_WEIERSTRASS); sk.E.dialect = ((ctx.flags & PUBKEY_FLAG_EDDSA) ? ECC_DIALECT_ED25519 @@ -939,7 +939,7 @@ ecc_verify (gcry_sexp_t s_sig, gcry_sexp_t s_data, gcry_sexp_t s_keyparms) if (!curvename) { pk.E.model = ((sigflags & PUBKEY_FLAG_EDDSA) - ? MPI_EC_TWISTEDEDWARDS + ? MPI_EC_EDWARDS : MPI_EC_WEIERSTRASS); pk.E.dialect = ((sigflags & PUBKEY_FLAG_EDDSA) ? ECC_DIALECT_ED25519 @@ -1529,7 +1529,7 @@ compute_keygrip (gcry_md_hd_t md, gcry_sexp_t keyparms) if (!curvename) { model = ((flags & PUBKEY_FLAG_EDDSA) - ? MPI_EC_TWISTEDEDWARDS + ? MPI_EC_EDWARDS : MPI_EC_WEIERSTRASS); dialect = ((flags & PUBKEY_FLAG_EDDSA) ? ECC_DIALECT_ED25519 diff --git a/mpi/ec.c b/mpi/ec.c index 168076f..9e007cd 100644 --- a/mpi/ec.c +++ b/mpi/ec.c @@ -605,7 +605,7 @@ _gcry_mpi_ec_get_affine (gcry_mpi_t x, gcry_mpi_t y, mpi_point_t point, } return -1; - case MPI_EC_TWISTEDEDWARDS: + case MPI_EC_EDWARDS: { gcry_mpi_t z; @@ -725,7 +725,7 @@ dup_point_montgomery (mpi_point_t result, mpi_point_t point, mpi_ec_t ctx) /* RESULT = 2 * POINT (Twisted Edwards version). */ static void -dup_point_twistededwards (mpi_point_t result, mpi_point_t point, mpi_ec_t ctx) +dup_point_edwards (mpi_point_t result, mpi_point_t point, mpi_ec_t ctx) { #define X1 (point->x) #define Y1 (point->y) @@ -811,8 +811,8 @@ _gcry_mpi_ec_dup_point (mpi_point_t result, mpi_point_t point, mpi_ec_t ctx) case MPI_EC_MONTGOMERY: dup_point_montgomery (result, point, ctx); break; - case MPI_EC_TWISTEDEDWARDS: - dup_point_twistededwards (result, point, ctx); + case MPI_EC_EDWARDS: + dup_point_edwards (result, point, ctx); break; } } @@ -977,9 +977,9 @@ add_points_montgomery (mpi_point_t result, /* RESULT = P1 + P2 (Twisted Edwards version).*/ static void -add_points_twistededwards (mpi_point_t result, - mpi_point_t p1, mpi_point_t p2, - mpi_ec_t ctx) +add_points_edwards (mpi_point_t result, + mpi_point_t p1, mpi_point_t p2, + mpi_ec_t ctx) { #define X1 (p1->x) #define Y1 (p1->y) @@ -1087,8 +1087,8 @@ _gcry_mpi_ec_add_points (mpi_point_t result, case MPI_EC_MONTGOMERY: add_points_montgomery (result, p1, p2, ctx); break; - case MPI_EC_TWISTEDEDWARDS: - add_points_twistededwards (result, p1, p2, ctx); + case MPI_EC_EDWARDS: + add_points_edwards (result, p1, p2, ctx); break; } } @@ -1106,7 +1106,7 @@ _gcry_mpi_ec_mul_point (mpi_point_t result, unsigned int i, loops; mpi_point_struct p1, p2, p1inv; - if (ctx->model == MPI_EC_TWISTEDEDWARDS) + if (ctx->model == MPI_EC_EDWARDS) { /* Simple left to right binary method. GECC Algorithm 3.27 */ unsigned int nbits; @@ -1269,7 +1269,7 @@ _gcry_mpi_ec_curve_point (gcry_mpi_point_t point, mpi_ec_t ctx) log_fatal ("%s: %s not yet supported\n", "_gcry_mpi_ec_curve_point", "Montgomery"); break; - case MPI_EC_TWISTEDEDWARDS: + case MPI_EC_EDWARDS: { /* a ? x^2 + y^2 - 1 - b ? x^2 ? y^2 == 0 */ ec_pow2 (x, x, ctx); diff --git a/src/mpi.h b/src/mpi.h index 7a57b9a..eb0730e 100644 --- a/src/mpi.h +++ b/src/mpi.h @@ -239,13 +239,18 @@ void _gcry_mpi_snatch_point (gcry_mpi_t x, gcry_mpi_t y, gcry_mpi_t z, /* Models describing an elliptic curve. */ enum gcry_mpi_ec_models { - + /* The Short Weierstrass equation is + y^2 = x^3 + ax + b + */ MPI_EC_WEIERSTRASS = 0, + /* The Montgomery equation is + by^2 = x^3 + ax^2 + x + */ MPI_EC_MONTGOMERY, - MPI_EC_TWISTEDEDWARDS - /* The equation for Twisted Edwards curves is + /* The Twisted Edwards equation is ax^2 + y^2 = 1 + bx^2y^2 Note that we use 'b' instead of the commonly used 'd'. */ + MPI_EC_EDWARDS }; /* Dialects used with elliptic curves. It is easier to keep the ----------------------------------------------------------------------- Summary of changes: NEWS | 12 ++++++ cipher/dsa-common.c | 33 ++++++++++++++++ cipher/dsa.c | 81 ++++++++++++++++---------------------- cipher/ecc-curves.c | 97 ++++++++++++++++++++++++++++++++++++++++++++-- cipher/ecc-ecdsa.c | 28 ++++++------- cipher/ecc-misc.c | 4 +- cipher/ecc.c | 8 ++-- cipher/mac-hmac.c | 8 ++++ cipher/mac.c | 7 ++++ cipher/md.c | 2 +- cipher/pubkey-internal.h | 3 ++ doc/gcrypt.texi | 12 +++++- mpi/ec.c | 22 +++++------ src/gcrypt-int.h | 1 + src/gcrypt.h.in | 4 ++ src/libgcrypt.def | 1 + src/libgcrypt.vers | 2 +- src/mpi.h | 11 ++++-- src/visibility.c | 6 +++ src/visibility.h | 2 + tests/basic.c | 6 +++ tests/curves.c | 2 +- tests/pubkey.c | 47 +++++++++++++++++++++- 23 files changed, 308 insertions(+), 91 deletions(-) hooks/post-receive -- The GNU crypto library http://git.gnupg.org From cvs at cvs.gnupg.org Mon Jan 13 11:26:19 2014 From: cvs at cvs.gnupg.org (by Werner Koch) Date: Mon, 13 Jan 2014 11:26:19 +0100 Subject: [git] GCRYPT - branch, master, updated. libgcrypt-1.6.0-30-g518ae27 Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The GNU crypto library". The branch, master has been updated via 518ae274a1845ce626b2b4223a9b3805cbbab1a7 (commit) from 91d3a2cc7ed2114b9f1821133eafc79efb55edca (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 518ae274a1845ce626b2b4223a9b3805cbbab1a7 Author: Werner Koch Date: Thu Jan 9 19:14:09 2014 +0100 Use internal malloc function in fips.c * src/fips.c (check_binary_integrity): s/gcry_malloc/xtrymalloc/. -- This fixes a build problem with ENABLE_HMAC_BINARY_CHECK. Reported-by: Michal Vyskocil. diff --git a/src/fips.c b/src/fips.c index 8148dcd..3ab33f9 100644 --- a/src/fips.c +++ b/src/fips.c @@ -602,7 +602,7 @@ check_binary_integrity (void) err = gpg_error (GPG_ERR_INTERNAL); else { - fname = gcry_malloc (strlen (info.dli_fname) + 1 + 5 + 1 ); + fname = xtrymalloc (strlen (info.dli_fname) + 1 + 5 + 1 ); if (!fname) err = gpg_error_from_syserror (); else ----------------------------------------------------------------------- Summary of changes: src/fips.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- The GNU crypto library http://git.gnupg.org From cvs at cvs.gnupg.org Mon Jan 13 11:48:52 2014 From: cvs at cvs.gnupg.org (by Werner Koch) Date: Mon, 13 Jan 2014 11:48:52 +0100 Subject: [git] GCRYPT - branch, LIBGCRYPT-1-6-BRANCH, updated. libgcrypt-1.6.0-9-g0f75a2a Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The GNU crypto library". The branch, LIBGCRYPT-1-6-BRANCH has been updated via 0f75a2a939cf57997a44868826ef3390f7a5c913 (commit) via 36214bfa8f612cd2faa4de217d1a12a8b5faadbf (commit) via 6133d9a041b594200c2f0fbe976dfca7e61adb0c (commit) via 01cdd8d0d86b00fcce0067e67635cdd5d6b738c1 (commit) from fb8d8517ffb287c332ead453ab8c8f0519c6129f (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 0f75a2a939cf57997a44868826ef3390f7a5c913 Author: Werner Koch Date: Thu Jan 9 19:14:09 2014 +0100 Update NEWS. -- diff --git a/NEWS b/NEWS index 8f43923..97fb089 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,11 @@ Noteworthy changes in version 1.6.1 (unreleased) ------------------------------------------------ + * Fix a 1.6.0 introduced regression in looking up an message digest + by OID. + + * Fix build problem on NetBSD. + Noteworthy changes in version 1.6.0 (2013-12-16) ------------------------------------------------ commit 36214bfa8f612cd2faa4de217d1a12a8b5faadbf Author: Werner Koch Date: Thu Jan 9 19:14:09 2014 +0100 Fix macro conflict in NetBSD * cipher/bithelp.h (bswap32): Rename to _gcry_bswap32. (bswap64): Rename to _gcry_bswap64. -- NetBSD provides system macros bswap32 and bswap64 which conflicts with our macros. Prefixing them with _gcry_ is easier than to come up with a proper test. GnuPG-bug-id: 1600 Signed-off-by: Werner Koch diff --git a/cipher/bithelp.h b/cipher/bithelp.h index 418bdf5..6e59c53 100644 --- a/cipher/bithelp.h +++ b/cipher/bithelp.h @@ -39,9 +39,10 @@ static inline u32 ror(u32 x, int n) /* Byte swap for 32-bit and 64-bit integers. If available, use compiler provided helpers. */ #ifdef HAVE_BUILTIN_BSWAP32 -# define bswap32 __builtin_bswap32 +# define _gcry_bswap32 __builtin_bswap32 #else -static inline u32 bswap32(u32 x) +static inline u32 +_gcry_bswap32(u32 x) { return ((rol(x, 8) & 0x00ff00ffL) | (ror(x, 8) & 0xff00ff00L)); } @@ -49,29 +50,30 @@ static inline u32 bswap32(u32 x) #ifdef HAVE_U64_TYPEDEF # ifdef HAVE_BUILTIN_BSWAP64 -# define bswap64 __builtin_bswap64 +# define _gcry_bswap64 __builtin_bswap64 # else -static inline u64 bswap64(u64 x) +static inline u64 +_gcry_bswap64(u64 x) { - return ((u64)bswap32(x) << 32) | (bswap32(x >> 32)); + return ((u64)_gcry_bswap32(x) << 32) | (_gcry_bswap32(x >> 32)); } # endif #endif /* Endian dependent byte swap operations. */ #ifdef WORDS_BIGENDIAN -# define le_bswap32(x) bswap32(x) +# define le_bswap32(x) _gcry_bswap32(x) # define be_bswap32(x) ((u32)(x)) # ifdef HAVE_U64_TYPEDEF -# define le_bswap64(x) bswap64(x) +# define le_bswap64(x) _gcry_bswap64(x) # define be_bswap64(x) ((u64)(x)) # endif #else # define le_bswap32(x) ((u32)(x)) -# define be_bswap32(x) bswap32(x) +# define be_bswap32(x) _gcry_bswap32(x) # ifdef HAVE_U64_TYPEDEF # define le_bswap64(x) ((u64)(x)) -# define be_bswap64(x) bswap64(x) +# define be_bswap64(x) _gcry_bswap64(x) # endif #endif commit 6133d9a041b594200c2f0fbe976dfca7e61adb0c Author: Dmitry Eremin-Solenikov Date: Tue Dec 31 00:39:56 2013 +0400 Fix typo in search_oid * cipher/md.c (search_oid): Invert condition on oid comparison. -- Function stricmp() returns 0 in case strings match, so proper condition that checks for matching OID strings should be if (!stricmp(...)) Signed-off-by: Dmitry Eremin-Solenikov diff --git a/cipher/md.c b/cipher/md.c index d9c1ad4..1b59765 100644 --- a/cipher/md.c +++ b/cipher/md.c @@ -195,7 +195,7 @@ search_oid (const char *oid, gcry_md_oid_spec_t *oid_spec) if (spec && spec->oids) { for (i = 0; spec->oids[i].oidstring; i++) - if (stricmp (oid, spec->oids[i].oidstring)) + if (!stricmp (oid, spec->oids[i].oidstring)) { if (oid_spec) *oid_spec = spec->oids[i]; commit 01cdd8d0d86b00fcce0067e67635cdd5d6b738c1 Author: Dmitry Eremin-Solenikov Date: Fri Dec 27 12:37:10 2013 +0400 Correct formatting of gcry_mac_get_algo_keylen documentation * doc/gcrypt.texi: add braces near gcry_mac_get_algo_keylen documentation. Use braces around unsigned int in gcry_mac_get_algo_keylen documentation, otherwise texinfo breaks that and uses 'int' as a function definition. Signed-off-by: Dmitry Eremin-Solenikov diff --git a/doc/gcrypt.texi b/doc/gcrypt.texi index 38af0c6..7af1706 100644 --- a/doc/gcrypt.texi +++ b/doc/gcrypt.texi @@ -3767,7 +3767,7 @@ for the MAC value. On error @code{0} is returned. @end deftypefun - at deftypefun unsigned int gcry_mac_get_algo_keylen (@var{algo}) + at deftypefun {unsigned int} gcry_mac_get_algo_keylen (@var{algo}) This function returns length of the key for MAC algorithm @var{algo}. If the algorithm supports multiple key lengths, the default supported key ----------------------------------------------------------------------- Summary of changes: NEWS | 5 +++++ cipher/bithelp.h | 20 +++++++++++--------- cipher/md.c | 2 +- doc/gcrypt.texi | 2 +- 4 files changed, 18 insertions(+), 11 deletions(-) hooks/post-receive -- The GNU crypto library http://git.gnupg.org From cvs at cvs.gnupg.org Mon Jan 13 11:53:02 2014 From: cvs at cvs.gnupg.org (by Werner Koch) Date: Mon, 13 Jan 2014 11:53:02 +0100 Subject: [git] GCRYPT - branch, master, updated. libgcrypt-1.6.0-31-g5f2af6c Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The GNU crypto library". The branch, master has been updated via 5f2af6c26bc04975c0b518881532871d7387d7ce (commit) from 518ae274a1845ce626b2b4223a9b3805cbbab1a7 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 5f2af6c26bc04975c0b518881532871d7387d7ce Author: Werner Koch Date: Thu Jan 9 19:14:09 2014 +0100 Fix macro conflict in NetBSD * cipher/bithelp.h (bswap32): Rename to _gcry_bswap32. (bswap64): Rename to _gcry_bswap64. -- NetBSD provides system macros bswap32 and bswap64 which conflicts with our macros. Prefixing them with _gcry_ is easier than to come up with a proper test. GnuPG-bug-id: 1600 Signed-off-by: Werner Koch (cherry picked from commit 36214bfa8f612cd2faa4de217d1a12a8b5faadbf) diff --git a/cipher/bithelp.h b/cipher/bithelp.h index 418bdf5..6e59c53 100644 --- a/cipher/bithelp.h +++ b/cipher/bithelp.h @@ -39,9 +39,10 @@ static inline u32 ror(u32 x, int n) /* Byte swap for 32-bit and 64-bit integers. If available, use compiler provided helpers. */ #ifdef HAVE_BUILTIN_BSWAP32 -# define bswap32 __builtin_bswap32 +# define _gcry_bswap32 __builtin_bswap32 #else -static inline u32 bswap32(u32 x) +static inline u32 +_gcry_bswap32(u32 x) { return ((rol(x, 8) & 0x00ff00ffL) | (ror(x, 8) & 0xff00ff00L)); } @@ -49,29 +50,30 @@ static inline u32 bswap32(u32 x) #ifdef HAVE_U64_TYPEDEF # ifdef HAVE_BUILTIN_BSWAP64 -# define bswap64 __builtin_bswap64 +# define _gcry_bswap64 __builtin_bswap64 # else -static inline u64 bswap64(u64 x) +static inline u64 +_gcry_bswap64(u64 x) { - return ((u64)bswap32(x) << 32) | (bswap32(x >> 32)); + return ((u64)_gcry_bswap32(x) << 32) | (_gcry_bswap32(x >> 32)); } # endif #endif /* Endian dependent byte swap operations. */ #ifdef WORDS_BIGENDIAN -# define le_bswap32(x) bswap32(x) +# define le_bswap32(x) _gcry_bswap32(x) # define be_bswap32(x) ((u32)(x)) # ifdef HAVE_U64_TYPEDEF -# define le_bswap64(x) bswap64(x) +# define le_bswap64(x) _gcry_bswap64(x) # define be_bswap64(x) ((u64)(x)) # endif #else # define le_bswap32(x) ((u32)(x)) -# define be_bswap32(x) bswap32(x) +# define be_bswap32(x) _gcry_bswap32(x) # ifdef HAVE_U64_TYPEDEF # define le_bswap64(x) ((u64)(x)) -# define be_bswap64(x) bswap64(x) +# define be_bswap64(x) _gcry_bswap64(x) # endif #endif ----------------------------------------------------------------------- Summary of changes: cipher/bithelp.h | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) hooks/post-receive -- The GNU crypto library http://git.gnupg.org From cvs at cvs.gnupg.org Tue Jan 14 15:48:26 2014 From: cvs at cvs.gnupg.org (by Sam Tuke) Date: Tue, 14 Jan 2014 15:48:26 +0100 Subject: [git] gnupg-doc - branch, master, updated. 95adf65c74548fb48a677076da8d4e89ac649cf5 Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The GnuPG website and other docs". The branch, master has been updated via 95adf65c74548fb48a677076da8d4e89ac649cf5 (commit) from 1ea495ecb24eed0e90ceaac94fd0d3bf990a5fc6 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 95adf65c74548fb48a677076da8d4e89ac649cf5 Author: Sam Tuke Date: Tue Jan 14 15:48:33 2014 +0100 Improved wording diff --git a/misc/blog.gnupg.org/20131230-how-good-is-goteo.html b/misc/blog.gnupg.org/20131230-how-good-is-goteo.html index 5c08016..386355e 100644 --- a/misc/blog.gnupg.org/20131230-how-good-is-goteo.html +++ b/misc/blog.gnupg.org/20131230-how-good-is-goteo.html @@ -84,7 +84,8 @@

"One question: why did you choose the quite unknown Spanish crowdfunding site Goteo?" So shot back the reply to the press release I had just sent to a few dozen selected journalists announcing the launch of the GnuPG crowdfunding campaign. "You won't get any exposure on there, we got a few hundred thousand hits just from being on indiegogo" I was told by one experienced crowdfunder at my favourite Berlin hackerspace last month. "What's Goteo?" has been one of the most frequently asked questions of this campaign from friends and supporters.

-

I ummed and ahhed over which crowfunding platform to choose. It's a decision that has a huge impact on the campaign - market exposure, transaction costs, and design and layout are just a few of the many factors that have to be taken into account. This is a crowded market - new crowdfunding sites are popping up each week as more companies try to cash in on what has is recognised a key tech trend of 2013. An estimated $5bn was raised by crowdfunders this year. That equates to around $35m in commission fees for the platforms hosting these campaigns, who typically charge between 5-10%. It's no surprise that everyone wants a slice.

+

I ummed and ahhed over which crowfunding platform to choose. It's a decision that has a huge impact on the campaign - market exposure, transaction costs, and design and layout are just a few of the many factors that have to be taken into account. This is a crowded market - new crowdfunding sites are popping up each week as more companies try to cash in on what is recognised a key tech trend of 2013. An estimated $5bn was raised by crowdfunders this year. That equates to around $35m in commission fees for the platforms hosting these campaigns, who typically charge between 5-10%. It's no surprise that everyone wants a slice.

@@ -95,7 +96,7 @@

Goteo is also the only such site to my knowledge that's built with public money. Funded by Spain's Department for Education, Culture and Sport, Barcelona's City Council, and The University of Andalucia, Goteo exists to host projects which "contribute to the common good, free knowledge, and open code". Everything about the platform and the projects it hosts point to common goods, shared resources, and collaborative effort.

-

Besides that, these are other great features make it stand out:

+

Besides that, these other features make it stand out:

  • Signup and donation workflow is smooth and simple
  • @@ -105,8 +106,8 @@
  • Built in license chooser for all "goods" projects produce (categories for software, artwork, etc.)
  • Mandatory delivery timeframe / deadline setter with public calendar
  • Nice "image wall widget" of donors faces has potential, provides public recognition of donations
  • -
  • Web forms for project creation are comprehensive, well designed, and highly usable
  • -
  • Crowdsourcing of extra skills ("non-economic donations") works really well
  • +
  • Web forms for project creation are comprehensive and well designed
  • +
  • Crowdsourcing of extra skills ("non-economic donations") works well
  • Donations are guaranteed by PayPal and Goteo, not pledged or retractable
  • Goteo staff are friendly and knowledgable, providing personal guidance and assistance
  • Many funding successes, including a few related to hardware, software, and Hackerspaces
  • diff --git a/misc/blog.gnupg.org/index.html b/misc/blog.gnupg.org/index.html index 35e2dad..1f62357 100644 --- a/misc/blog.gnupg.org/index.html +++ b/misc/blog.gnupg.org/index.html @@ -84,7 +84,8 @@

    "One question: why did you choose the quite unknown Spanish crowdfunding site Goteo?" So shot back the reply to the press release I had just sent to a few dozen selected journalists announcing the launch of the GnuPG crowdfunding campaign. "You won't get any exposure on there, we got a few hundred thousand hits just from being on indiegogo" I was told by one experienced crowdfunder at my favourite Berlin hackerspace last month. "What's Goteo?" has been one of the most frequently asked questions of this campaign from friends and supporters.

    -

    I ummed and ahhed over which crowfunding platform to choose. It's a decision that has a huge impact on the campaign - market exposure, transaction costs, and design and layout are just a few of the many factors that have to be taken into account. This is a crowded market - new crowdfunding sites are popping up each week as more companies try to cash in on what has is recognised a key tech trend of 2013. An estimated $5bn was raised by crowdfunders this year. That equates to around $35m in commission fees for the platforms hosting these campaigns, who typically charge between 5-10%. It's no surprise that everyone wants a slice.

    +

    I ummed and ahhed over which crowfunding platform to choose. It's a decision that has a huge impact on the campaign - market exposure, transaction costs, and design and layout are just a few of the many factors that have to be taken into account. This is a crowded market - new crowdfunding sites are popping up each week as more companies try to cash in on what is recognised a key tech trend of 2013. An estimated $5bn was raised by crowdfunders this year. That equates to around $35m in commission fees for the platforms hosting these campaigns, who typically charge between 5-10%. It's no surprise that everyone wants a slice.

    @@ -95,7 +96,7 @@

    Goteo is also the only such site to my knowledge that's built with public money. Funded by Spain's Department for Education, Culture and Sport, Barcelona's City Council, and The University of Andalucia, Goteo exists to host projects which "contribute to the common good, free knowledge, and open code". Everything about the platform and the projects it hosts point to common goods, shared resources, and collaborative effort.

    -

    Besides that, these are other great features make it stand out:

    +

    Besides that, these other features make it stand out:

    • Signup and donation workflow is smooth and simple
    • @@ -105,8 +106,8 @@
    • Built in license chooser for all "goods" projects produce (categories for software, artwork, etc.)
    • Mandatory delivery timeframe / deadline setter with public calendar
    • Nice "image wall widget" of donors faces has potential, provides public recognition of donations
    • -
    • Web forms for project creation are comprehensive, well designed, and highly usable
    • -
    • Crowdsourcing of extra skills ("non-economic donations") works really well
    • +
    • Web forms for project creation are comprehensive and well designed
    • +
    • Crowdsourcing of extra skills ("non-economic donations") works well
    • Donations are guaranteed by PayPal and Goteo, not pledged or retractable
    • Goteo staff are friendly and knowledgable, providing personal guidance and assistance
    • Many funding successes, including a few related to hardware, software, and Hackerspaces
    • ----------------------------------------------------------------------- Summary of changes: misc/blog.gnupg.org/20131230-how-good-is-goteo.html | 9 +++++---- misc/blog.gnupg.org/index.html | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) hooks/post-receive -- The GnuPG website and other docs http://git.gnupg.org From cvs at cvs.gnupg.org Tue Jan 14 16:40:00 2014 From: cvs at cvs.gnupg.org (by Milan Broz) Date: Tue, 14 Jan 2014 16:40:00 +0100 Subject: [git] GCRYPT - branch, master, updated. libgcrypt-1.6.0-33-g04cda6b Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The GNU crypto library". The branch, master has been updated via 04cda6b7cc16f3f52c12d9d3e46c56701003496e (commit) via dfde161355b15b25b1d1214d5ee0338e50b33517 (commit) from 5f2af6c26bc04975c0b518881532871d7387d7ce (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 04cda6b7cc16f3f52c12d9d3e46c56701003496e Author: Milan Broz Date: Mon Jan 13 21:30:42 2014 +0100 PBKDF2: Use gcry_md_reset to speed up calculation. * cipher/kdf.c (_gcry_kdf_pkdf2): Use gcry_md_reset to speed up calculation. -- Current PBKDF2 implementation uses gcry_md_set_key in every iteration which is extremely slow (even in comparison with other implementations). Use gcry_md_reset instead and set key only once. With this test program: char input[32000], salt[8], key[16]; gcry_kdf_derive(input, sizeof(input), GCRY_KDF_PBKDF2, gcry_md_map_name("sha1"), salt, sizeof(salt), 100000, sizeof(key), key); running time without patch: real 0m11.165s user 0m11.136s sys 0m0.000s and with patch applied real 0m0.230s user 0m0.184s sys 0m0.024s (The problem was found when cryptsetup started to use gcrypt internal PBKDF2 and for very long keyfiles unlocking time increased drastically. See https://bugzilla.redhat.com/show_bug.cgi?id=1051733) Signed-off-by: Milan Broz diff --git a/cipher/kdf.c b/cipher/kdf.c index 503f068..af0dc48 100644 --- a/cipher/kdf.c +++ b/cipher/kdf.c @@ -175,19 +175,21 @@ _gcry_kdf_pkdf2 (const void *passphrase, size_t passphraselen, return ec; } + ec = _gcry_md_setkey (md, passphrase, passphraselen); + if (ec) + { + _gcry_md_close (md); + xfree (sbuf); + return ec; + } + /* Step 3 and 4. */ memcpy (sbuf, salt, saltlen); for (lidx = 1; lidx <= l; lidx++) { for (iter = 0; iter < iterations; iter++) { - ec = _gcry_md_setkey (md, passphrase, passphraselen); - if (ec) - { - _gcry_md_close (md); - xfree (sbuf); - return ec; - } + _gcry_md_reset (md); if (!iter) /* Compute U_1: */ { sbuf[saltlen] = (lidx >> 24); commit dfde161355b15b25b1d1214d5ee0338e50b33517 Author: Werner Koch Date: Thu Jan 9 19:14:09 2014 +0100 Add DCO entry for Milan Broz. -- diff --git a/AUTHORS b/AUTHORS index dc933dc..2c92998 100644 --- a/AUTHORS +++ b/AUTHORS @@ -154,6 +154,9 @@ Jussi Kivilinna Jussi Kivilinna 2013-05-06:5186720A.4090101 at iki.fi: +Milan Broz +2014-01-13:52D44CC6.4050707 at gmail.com: + Rafa?l Carr? 2012-04-20:4F91988B.1080502 at videolan.org: ----------------------------------------------------------------------- Summary of changes: AUTHORS | 3 +++ cipher/kdf.c | 16 +++++++++------- 2 files changed, 12 insertions(+), 7 deletions(-) hooks/post-receive -- The GNU crypto library http://git.gnupg.org From cvs at cvs.gnupg.org Wed Jan 15 04:47:55 2014 From: cvs at cvs.gnupg.org (by NIIBE Yutaka) Date: Wed, 15 Jan 2014 04:47:55 +0100 Subject: [git] GCRYPT - branch, master, updated. libgcrypt-1.6.0-34-g49edeeb Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The GNU crypto library". The branch, master has been updated via 49edeebb43174865cf4fa2c170a42a8e4274c4f0 (commit) from 04cda6b7cc16f3f52c12d9d3e46c56701003496e (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 49edeebb43174865cf4fa2c170a42a8e4274c4f0 Author: NIIBE Yutaka Date: Wed Jan 15 12:41:37 2014 +0900 ecc: Fix _gcry_mpi_ec_p_new to allow secp256k1. * mpi/ec.c (_gcry_mpi_ec_p_new): Remove checking a!=0. * tests/t-mpi-point.c (context_alloc): Remove two spurious tests. -- It is no problem when a==0. Signed-off-by: NIIBE Yutaka diff --git a/mpi/ec.c b/mpi/ec.c index 9e007cd..4f35de0 100644 --- a/mpi/ec.c +++ b/mpi/ec.c @@ -495,7 +495,7 @@ _gcry_mpi_ec_p_new (gcry_ctx_t *r_ctx, mpi_ec_t ec; *r_ctx = NULL; - if (!p || !a || !mpi_cmp_ui (a, 0)) + if (!p || !a) return GPG_ERR_EINVAL; ctx = _gcry_ctx_alloc (CONTEXT_TYPE_EC, sizeof *ec, ec_deinit); diff --git a/tests/t-mpi-point.c b/tests/t-mpi-point.c index ae52601..d60b3f0 100644 --- a/tests/t-mpi-point.c +++ b/tests/t-mpi-point.c @@ -434,28 +434,18 @@ context_alloc (void) gcry_mpi_release (a); gcry_ctx_release (ctx); - p = gcry_mpi_set_ui (NULL, 0); + p = NULL; a = gcry_mpi_set_ui (NULL, 0); - err = ec_p_new (&ctx, p, a); - if (!err || gpg_err_code (err) != GPG_ERR_EINVAL) - fail ("ec_p_new: bad parameter detection failed (1)\n"); - - gcry_mpi_set_ui (p, 1); - err = ec_p_new (&ctx, p, a); - if (!err || gpg_err_code (err) != GPG_ERR_EINVAL) - fail ("ec_p_new: bad parameter detection failed (2)\n"); - gcry_mpi_release (p); - p = NULL; err = ec_p_new (&ctx, p, a); if (!err || gpg_err_code (err) != GPG_ERR_EINVAL) - fail ("ec_p_new: bad parameter detection failed (3)\n"); + fail ("ec_p_new: bad parameter detection failed (1)\n"); gcry_mpi_release (a); a = NULL; err = ec_p_new (&ctx, p, a); if (!err || gpg_err_code (err) != GPG_ERR_EINVAL) - fail ("ec_p_new: bad parameter detection failed (4)\n"); + fail ("ec_p_new: bad parameter detection failed (2)\n"); } ----------------------------------------------------------------------- Summary of changes: mpi/ec.c | 2 +- tests/t-mpi-point.c | 16 +++------------- 2 files changed, 4 insertions(+), 14 deletions(-) hooks/post-receive -- The GNU crypto library http://git.gnupg.org From cvs at cvs.gnupg.org Thu Jan 16 02:10:14 2014 From: cvs at cvs.gnupg.org (by NIIBE Yutaka) Date: Thu, 16 Jan 2014 02:10:14 +0100 Subject: [git] GnuPG - branch, master, updated. gnupg-2.1.0beta3-288-g0ee66a6 Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The GNU Privacy Guard". The branch, master has been updated via 0ee66a6f66d7389e381fffa5f9eedbc8de9add10 (commit) via 9c731bbedfd8bded5efd886304c5ca6655768c45 (commit) via c5e41f539b9a21cbad10c7dae95572a4445d31c3 (commit) from 927377bc91288d121a7d8bdbb3c32d8fc728e9fb (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 0ee66a6f66d7389e381fffa5f9eedbc8de9add10 Author: NIIBE Yutaka Date: Thu Jan 16 10:00:17 2014 +0900 agent: Not remove SSH socket when already running. * agent/gpg-agent.c (main): Defer setting of socket_name_ssh to avoid removal of the socket when it will die in create_server_socket for socket_name. Signed-off-by: NIIBE Yutaka diff --git a/agent/gpg-agent.c b/agent/gpg-agent.c index ed664ea..1e60717 100644 --- a/agent/gpg-agent.c +++ b/agent/gpg-agent.c @@ -1045,13 +1045,14 @@ main (int argc, char **argv ) /* Create the sockets. */ socket_name = create_socket_name (GPG_AGENT_SOCK_NAME, "gpg-XXXXXX/"GPG_AGENT_SOCK_NAME); - if (opt.ssh_support) - socket_name_ssh = create_socket_name - (GPG_AGENT_SSH_SOCK_NAME, "gpg-XXXXXX/"GPG_AGENT_SSH_SOCK_NAME); fd = create_server_socket (socket_name, 0, &socket_nonce); if (opt.ssh_support) - fd_ssh = create_server_socket (socket_name_ssh, 1, &socket_nonce_ssh); + { + socket_name_ssh = create_socket_name + (GPG_AGENT_SSH_SOCK_NAME, "gpg-XXXXXX/"GPG_AGENT_SSH_SOCK_NAME); + fd_ssh = create_server_socket (socket_name_ssh, 1, &socket_nonce_ssh); + } else fd_ssh = GNUPG_INVALID_FD; commit 9c731bbedfd8bded5efd886304c5ca6655768c45 Author: NIIBE Yutaka Date: Thu Jan 16 09:07:11 2014 +0900 agent: Fix agent_is_eddsa_key. * agent/findkey.c (agent_is_eddsa_key): Implemented. Signed-off-by: NIIBE Yutaka diff --git a/agent/findkey.c b/agent/findkey.c index aa2c6a2..6464b02 100644 --- a/agent/findkey.c +++ b/agent/findkey.c @@ -812,14 +812,10 @@ agent_is_eddsa_key (gcry_sexp_t s_key) return 0; if (key_parms_from_sexp (s_key, NULL, algoname, sizeof algoname, NULL, 0)) - return 0; /* Error - assume it is not an DSA key. */ + return 0; /* Error - assume it is not an EdDSA key. */ - if (!strcmp (algoname, "dsa")) - return GCRY_PK_DSA; - else if (!strcmp (algoname, "ecc")) - return GCRY_PK_ECDSA; /* FIXME: Check for the EdDSA flag. */ - else if (!strcmp (algoname, "ecdsa")) - return GCRY_PK_ECDSA; + if (!strcmp (algoname, "eddsa")) + return 1; else return 0; } commit c5e41f539b9a21cbad10c7dae95572a4445d31c3 Author: NIIBE Yutaka Date: Wed Jan 15 15:00:24 2014 +0900 Add secp256k1. * common/openpgp-oid.c (openpgp_curve_to_oid): Add secp256k1. (openpgp_oid_to_curve): Likewise. * g10/keygen.c (ask_curve): Add secp256k1. Signed-off-by: NIIBE Yutaka diff --git a/common/openpgp-oid.c b/common/openpgp-oid.c index 05b1a40..28567b7 100644 --- a/common/openpgp-oid.c +++ b/common/openpgp-oid.c @@ -310,6 +310,11 @@ openpgp_curve_to_oid (const char *name, unsigned int *r_nbits) oidstr = "1.3.36.3.3.2.8.1.1.13"; nbits = 512; } + else if (!strcmp (name, "secp256k1")) + { + oidstr = "1.3.132.0.10"; + nbits = 256; + } else oidstr = NULL; @@ -333,6 +338,8 @@ openpgp_oid_to_curve (const char *oid) name = "Ed25519"; else if (!strcmp (oid, "1.2.840.10045.3.1.7")) name = "nistp256"; + else if (!strcmp (oid, "1.3.132.0.10")) + name = "secp256k1"; else if (!strcmp (oid, "1.3.132.0.34")) name = "nistp384"; else if (!strcmp (oid, "1.3.132.0.35")) diff --git a/g10/keygen.c b/g10/keygen.c index 4bb8bba..7582b0b 100644 --- a/g10/keygen.c +++ b/g10/keygen.c @@ -2062,6 +2062,7 @@ ask_curve (void) { "brainpoolP256r1", 0, 1, "Brainpool P-256" }, { "brainpoolP384r1", 0, 1, "Brainpool P-384" }, { "brainpoolP512r1", 0, 1, "Brainpool P-512" }, + { "secp256k1", 0, 1 }, }; int idx; char *answer; ----------------------------------------------------------------------- Summary of changes: agent/findkey.c | 10 +++------- agent/gpg-agent.c | 9 +++++---- common/openpgp-oid.c | 7 +++++++ g10/keygen.c | 1 + 4 files changed, 16 insertions(+), 11 deletions(-) hooks/post-receive -- The GNU Privacy Guard http://git.gnupg.org From cvs at cvs.gnupg.org Thu Jan 16 10:01:44 2014 From: cvs at cvs.gnupg.org (by Werner Koch) Date: Thu, 16 Jan 2014 10:01:44 +0100 Subject: [git] GPG-ERROR - branch, master, updated. libgpg-error-1.12-11-gff937c3 Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Error codes used by GnuPG et al.". The branch, master has been updated via ff937c39febe63d52c55590d8e3bd3a460f26651 (commit) via 78a06348fb07f2dce861615cc6d19964818f7334 (commit) from c1871fddf85cdddc33c1b35d5f1c8bae76388ee5 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit ff937c39febe63d52c55590d8e3bd3a460f26651 Author: Werner Koch Date: Thu Jan 9 19:14:09 2014 +0100 Add gpgrt_lock_ functions. * src/gpg-error.h.in (GPGRT_LOCK_DEFINE): New. (gpgrt_lock_init): New. (gpgrt_lock_lock): New. (gpgrt_lock_unlock): New. (gpgrt_lock_destroy): New. (gpgrt_yield): New. * src/gpg-error.def.in: Add new functions. * m4/lock.m4, m4/threadlib.m4: New. Taken from current gnulib. * configure.ac: Call gl_LOCK. Check size of pthread_mutex_t. Add LIBTHREAD to GPG_ERROR_CONFIG_LIBS. * src/err-codes.h.in (GPG_ERR_INV_LOCK_OBJ): New. * src/gen-posix-lock-obj.c: New. * src/gen-w32-lock-obj.c: New. * src/lock.h, src/thread.h: New. * src/posix-lock-obj.h, src/w32-lock-obj.h: New. * src/posix-lock.c, src/w32-lock.c: New. * src/posix-thread.c, src/w32-thread.c: * src/w32-lock-obj-pub.in: New. * src/mkheader.c (include_file): Support build time include files. (write_special): Add keyword "include:lock-obj". * src/Makefile.am: (posix-lock-obj-pub.in): New rule. (noinst_PROGRAMS): Add gen-*-lock-obj helpers. * tests/t-common.h: New. * tests/t-lock.c: New. * tests/Makefile.am (t_lock_LDADD): Add new test. -- This patch introduces the gpgrt_ functions which will be extended over time to provide a library of commonly used code in GnuPG and Libgcrypt. Having them in a library named libgpg-error is a misnomer but this way we can achieve a smooth upgrade path. In contrasts to other GnuPG libraries, the gpgrt_ functions return a simple gpg_err_code_t and not gpg_error_t. The rationale for this is that a source of error identifier does not make sense here; it is better to use the source of error identifier of the caller. This can easily be achieved in a component by wrapping these function in a gpg_error macro/inline. There is no cross-compiling support for Posix platforms; the gen-posix-lock-obj tool must be run on the target system. Note that the gen-w32-lock-obj tool is not needed at build time but was used to figure out ABI definitions for Windows. Signed-off-by: Werner Koch diff --git a/NEWS b/NEWS index 2600b4e..c7f666b 100644 --- a/NEWS +++ b/NEWS @@ -1,9 +1,20 @@ Noteworthy changes in version 1.13 (unreleased) ----------------------------------------------- - * Interface changes relative to the 1.11 release: + Add a portable mutex API. + + * Interface changes relative to the 1.12 release: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ GPG_ERR_MAC_ALGO NEW. + GPG_ERR_INV_LOCK_OBJ NEW. + gpgrt_lock_t NEW. + GPGRT_LOCK_INITIALIZER NEW. + GPGRT_LOCK_DEFINE NEW. + gpgrt_lock_init NEW. + gpgrt_lock_lock NEW. + gpgrt_lock_unlock NEW. + gpgrt_lock_destroy NEW. + gpgrt_yield NEW. Noteworthy changes in version 1.12 (2013-06-24) diff --git a/configure.ac b/configure.ac index 73de716..3d1e12f 100644 --- a/configure.ac +++ b/configure.ac @@ -85,6 +85,9 @@ AC_PROG_AWK AC_CHECK_TOOL(AR, ar, :) AC_GNU_SOURCE +gl_THREADLIB_EARLY + + LT_PREREQ([2.2.6]) LT_INIT([win32-dll disable-static]) LT_LANG([Windows Resource]) @@ -156,11 +159,26 @@ AC_MSG_WARN([[Without strerror_r, gpg_strerror_r might not be thread-safe]])) ;; esac +AC_CHECK_FUNCS([flockfile]) + + # Checks for typedefs, structures, and compiler characteristics. AC_C_CONST + +# Check for thread library +gl_LOCK +if test "$gl_threads_api" = posix; then + AC_CHECK_SIZEOF(pthread_mutex_t,,[AC_INCLUDES_DEFAULT + #include ]) +fi + + # Substitution used for gpg-error-config GPG_ERROR_CONFIG_LIBS="-lgpg-error" +if test "x$LIBTHREAD" != x; then + GPG_ERROR_CONFIG_LIBS="${GPG_ERROR_CONFIG_LIBS} ${LIBTHREAD}" +fi GPG_ERROR_CONFIG_CFLAGS="" GPG_ERROR_CONFIG_ISUBDIRAFTER="" GPG_ERROR_CONFIG_HOST="$host" diff --git a/m4/lock.m4 b/m4/lock.m4 index d1ea1ca..73a3c54 100644 --- a/m4/lock.m4 +++ b/m4/lock.m4 @@ -1,289 +1,42 @@ -# lock.m4 serial 2 (gettext-0.15) -dnl Copyright (C) 2005 Free Software Foundation, Inc. +# lock.m4 serial 13 (gettext-0.18.2) +dnl Copyright (C) 2005-2014 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. dnl From Bruno Haible. -dnl Tests for a multithreading library to be used. -dnl Defines at most one of the macros USE_POSIX_THREADS, USE_SOLARIS_THREADS, -dnl USE_PTH_THREADS, USE_WIN32_THREADS -dnl Sets the variables LIBTHREAD and LTLIBTHREAD to the linker options for use -dnl in a Makefile (LIBTHREAD for use without libtool, LTLIBTHREAD for use with -dnl libtool). -dnl Sets the variables LIBMULTITHREAD and LTLIBMULTITHREAD similarly, for -dnl programs that really need multithread functionality. The difference -dnl between LIBTHREAD and LIBMULTITHREAD is that on platforms supporting weak -dnl symbols, typically LIBTHREAD="" whereas LIBMULTITHREAD="-lpthread". -dnl Adds to CPPFLAGS the flag -D_REENTRANT or -D_THREAD_SAFE if needed for -dnl multithread-safe programs. - AC_DEFUN([gl_LOCK], [ - AC_REQUIRE([gl_LOCK_BODY]) -]) - -dnl The guts of gl_LOCK. Needs to be expanded only once. - -AC_DEFUN([gl_LOCK_BODY], -[ - dnl Ordering constraints: This macro modifies CPPFLAGS in a way that - dnl influences the result of the autoconf tests that test for *_unlocked - dnl declarations, on AIX 5 at least. Therefore it must come early. - AC_BEFORE([$0], [gl_FUNC_GLIBC_UNLOCKED_IO])dnl - AC_BEFORE([$0], [gl_ARGP])dnl - - AC_REQUIRE([AC_CANONICAL_HOST]) - AC_REQUIRE([AC_GNU_SOURCE]) dnl needed for pthread_rwlock_t on glibc systems - dnl Check for multithreading. - AC_ARG_ENABLE(threads, -AC_HELP_STRING([--enable-threads={posix|solaris|pth|win32}], [specify multithreading API]) -AC_HELP_STRING([--disable-threads], [build without multithread safety]), - gl_use_threads=$enableval, gl_use_threads=yes) - gl_threads_api=none - LIBTHREAD= - LTLIBTHREAD= - LIBMULTITHREAD= - LTLIBMULTITHREAD= - if test "$gl_use_threads" != no; then - dnl Check whether the compiler and linker support weak declarations. - AC_MSG_CHECKING([whether imported symbols can be declared weak]) - gl_have_weak=no - AC_TRY_LINK([extern void xyzzy (); -#pragma weak xyzzy], [xyzzy();], [gl_have_weak=yes]) - AC_MSG_RESULT([$gl_have_weak]) - if test "$gl_use_threads" = yes || test "$gl_use_threads" = posix; then - # On OSF/1, the compiler needs the flag -pthread or -D_REENTRANT so that - # it groks . - gl_save_CPPFLAGS="$CPPFLAGS" - CPPFLAGS="$CPPFLAGS -D_REENTRANT" - AC_CHECK_HEADER(pthread.h, gl_have_pthread_h=yes, gl_have_pthread_h=no) - CPPFLAGS="$gl_save_CPPFLAGS" - if test "$gl_have_pthread_h" = yes; then - # Other possible tests: - # -lpthreads (FSU threads, PCthreads) - # -lgthreads - case "$host_os" in - osf*) - # On OSF/1, the compiler needs the flag -D_REENTRANT so that it - # groks . cc also understands the flag -pthread, but - # we don't use it because 1. gcc-2.95 doesn't understand -pthread, - # 2. putting a flag into CPPFLAGS that has an effect on the linker - # causes the AC_TRY_LINK test below to succeed unexpectedly, - # leading to wrong values of LIBTHREAD and LTLIBTHREAD. - CPPFLAGS="$CPPFLAGS -D_REENTRANT" - ;; - esac - gl_have_pthread= - # Test whether both pthread_mutex_lock and pthread_mutexattr_init exist - # in libc. IRIX 6.5 has the first one in both libc and libpthread, but - # the second one only in libpthread, and lock.c needs it. - AC_TRY_LINK([#include ], - [pthread_mutex_lock((pthread_mutex_t*)0); - pthread_mutexattr_init((pthread_mutexattr_t*)0);], - [gl_have_pthread=yes]) - # Test for libpthread by looking for pthread_kill. (Not pthread_self, - # since it is defined as a macro on OSF/1.) - if test -n "$gl_have_pthread"; then - # The program links fine without libpthread. But it may actually - # need to link with libpthread in order to create multiple threads. - AC_CHECK_LIB(pthread, pthread_kill, - [LIBMULTITHREAD=-lpthread LTLIBMULTITHREAD=-lpthread - # On Solaris and HP-UX, most pthread functions exist also in libc. - # Therefore pthread_in_use() needs to actually try to create a - # thread: pthread_create from libc will fail, whereas - # pthread_create will actually create a thread. - case "$host_os" in - solaris* | hpux*) - AC_DEFINE([PTHREAD_IN_USE_DETECTION_HARD], 1, - [Define if the pthread_in_use() detection is hard.]) - esac - ]) - else - # Some library is needed. Try libpthread and libc_r. - AC_CHECK_LIB(pthread, pthread_kill, - [gl_have_pthread=yes - LIBTHREAD=-lpthread LTLIBTHREAD=-lpthread - LIBMULTITHREAD=-lpthread LTLIBMULTITHREAD=-lpthread]) - if test -z "$gl_have_pthread"; then - # For FreeBSD 4. - AC_CHECK_LIB(c_r, pthread_kill, - [gl_have_pthread=yes - LIBTHREAD=-lc_r LTLIBTHREAD=-lc_r - LIBMULTITHREAD=-lc_r LTLIBMULTITHREAD=-lc_r]) - fi - fi - if test -n "$gl_have_pthread"; then - gl_threads_api=posix - AC_DEFINE([USE_POSIX_THREADS], 1, - [Define if the POSIX multithreading library can be used.]) - if test -n "$LIBMULTITHREAD" || test -n "$LTLIBMULTITHREAD"; then - if test $gl_have_weak = yes; then - AC_DEFINE([USE_POSIX_THREADS_WEAK], 1, - [Define if references to the POSIX multithreading library should be made weak.]) - LIBTHREAD= - LTLIBTHREAD= - fi - fi - # OSF/1 4.0 and MacOS X 10.1 lack the pthread_rwlock_t type and the - # pthread_rwlock_* functions. - AC_CHECK_TYPE([pthread_rwlock_t], - [AC_DEFINE([HAVE_PTHREAD_RWLOCK], 1, - [Define if the POSIX multithreading library has read/write locks.])], - [], - [#include ]) - # glibc defines PTHREAD_MUTEX_RECURSIVE as enum, not as a macro. - AC_TRY_COMPILE([#include ], - [#if __FreeBSD__ == 4 + AC_REQUIRE([gl_THREADLIB]) + if test "$gl_threads_api" = posix; then + # OSF/1 4.0 and Mac OS X 10.1 lack the pthread_rwlock_t type and the + # pthread_rwlock_* functions. + AC_CHECK_TYPE([pthread_rwlock_t], + [AC_DEFINE([HAVE_PTHREAD_RWLOCK], [1], + [Define if the POSIX multithreading library has read/write locks.])], + [], + [#include ]) + # glibc defines PTHREAD_MUTEX_RECURSIVE as enum, not as a macro. + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM( + [[#include ]], + [[ +#if __FreeBSD__ == 4 error "No, in FreeBSD 4.0 recursive mutexes actually don't work." +#elif (defined __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ \ + && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1070) +error "No, in Mac OS X < 10.7 recursive mutexes actually don't work." #else int x = (int)PTHREAD_MUTEX_RECURSIVE; -#endif], - [AC_DEFINE([HAVE_PTHREAD_MUTEX_RECURSIVE], 1, - [Define if the defines PTHREAD_MUTEX_RECURSIVE.])]) - # Some systems optimize for single-threaded programs by default, and - # need special flags to disable these optimizations. For example, the - # definition of 'errno' in . - case "$host_os" in - aix* | freebsd*) CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE" ;; - solaris*) CPPFLAGS="$CPPFLAGS -D_REENTRANT" ;; - esac - fi - fi - fi - if test -z "$gl_have_pthread"; then - if test "$gl_use_threads" = yes || test "$gl_use_threads" = solaris; then - gl_have_solaristhread= - gl_save_LIBS="$LIBS" - LIBS="$LIBS -lthread" - AC_TRY_LINK([#include -#include ], - [thr_self();], - [gl_have_solaristhread=yes]) - LIBS="$gl_save_LIBS" - if test -n "$gl_have_solaristhread"; then - gl_threads_api=solaris - LIBTHREAD=-lthread - LTLIBTHREAD=-lthread - LIBMULTITHREAD="$LIBTHREAD" - LTLIBMULTITHREAD="$LTLIBTHREAD" - AC_DEFINE([USE_SOLARIS_THREADS], 1, - [Define if the old Solaris multithreading library can be used.]) - if test $gl_have_weak = yes; then - AC_DEFINE([USE_SOLARIS_THREADS_WEAK], 1, - [Define if references to the old Solaris multithreading library should be made weak.]) - LIBTHREAD= - LTLIBTHREAD= - fi - fi - fi - fi - if test "$gl_use_threads" = pth; then - gl_save_CPPFLAGS="$CPPFLAGS" - AC_LIB_LINKFLAGS(pth) - gl_have_pth= - gl_save_LIBS="$LIBS" - LIBS="$LIBS -lpth" - AC_TRY_LINK([#include ], [pth_self();], gl_have_pth=yes) - LIBS="$gl_save_LIBS" - if test -n "$gl_have_pth"; then - gl_threads_api=pth - LIBTHREAD="$LIBPTH" - LTLIBTHREAD="$LTLIBPTH" - LIBMULTITHREAD="$LIBTHREAD" - LTLIBMULTITHREAD="$LTLIBTHREAD" - AC_DEFINE([USE_PTH_THREADS], 1, - [Define if the GNU Pth multithreading library can be used.]) - if test -n "$LIBMULTITHREAD" || test -n "$LTLIBMULTITHREAD"; then - if test $gl_have_weak = yes; then - AC_DEFINE([USE_PTH_THREADS_WEAK], 1, - [Define if references to the GNU Pth multithreading library should be made weak.]) - LIBTHREAD= - LTLIBTHREAD= - fi - fi - else - CPPFLAGS="$gl_save_CPPFLAGS" - fi - fi - if test -z "$gl_have_pthread"; then - if test "$gl_use_threads" = yes || test "$gl_use_threads" = win32; then - if { case "$host_os" in - mingw*) true;; - *) false;; - esac - }; then - gl_threads_api=win32 - AC_DEFINE([USE_WIN32_THREADS], 1, - [Define if the Win32 multithreading API can be used.]) - fi - fi - fi +return !x; +#endif + ]])], + [AC_DEFINE([HAVE_PTHREAD_MUTEX_RECURSIVE], [1], + [Define if the defines PTHREAD_MUTEX_RECURSIVE.])]) fi - AC_MSG_CHECKING([for multithread API to use]) - AC_MSG_RESULT([$gl_threads_api]) - AC_SUBST(LIBTHREAD) - AC_SUBST(LTLIBTHREAD) - AC_SUBST(LIBMULTITHREAD) - AC_SUBST(LTLIBMULTITHREAD) gl_PREREQ_LOCK ]) -# Prerequisites of lib/lock.c. -AC_DEFUN([gl_PREREQ_LOCK], [ - AC_REQUIRE([AC_C_INLINE]) -]) - -dnl Survey of platforms: -dnl -dnl Platform Available Compiler Supports test-lock -dnl flavours option weak result -dnl --------------- --------- --------- -------- --------- -dnl Linux 2.4/glibc posix -lpthread Y OK -dnl -dnl GNU Hurd/glibc posix -dnl -dnl FreeBSD 5.3 posix -lc_r Y -dnl posix -lkse ? Y -dnl posix -lpthread ? Y -dnl posix -lthr Y -dnl -dnl FreeBSD 5.2 posix -lc_r Y -dnl posix -lkse Y -dnl posix -lthr Y -dnl -dnl FreeBSD 4.0,4.10 posix -lc_r Y OK -dnl -dnl NetBSD 1.6 -- -dnl -dnl OpenBSD 3.4 posix -lpthread Y OK -dnl -dnl MacOS X 10.[123] posix -lpthread Y OK -dnl -dnl Solaris 7,8,9 posix -lpthread Y Sol 7,8: 0.0; Sol 9: OK -dnl solaris -lthread Y Sol 7,8: 0.0; Sol 9: OK -dnl -dnl HP-UX 11 posix -lpthread N (cc) OK -dnl Y (gcc) -dnl -dnl IRIX 6.5 posix -lpthread Y 0.5 -dnl -dnl AIX 4.3,5.1 posix -lpthread N AIX 4: 0.5; AIX 5: OK -dnl -dnl OSF/1 4.0,5.1 posix -pthread (cc) N OK -dnl -lpthread (gcc) Y -dnl -dnl Cygwin posix -lpthread Y OK -dnl -dnl Any of the above pth -lpth 0.0 -dnl -dnl Mingw win32 N OK -dnl -dnl BeOS 5 -- -dnl -dnl The test-lock result shows what happens if in test-lock.c EXPLICIT_YIELD is -dnl turned off: -dnl OK if all three tests terminate OK, -dnl 0.5 if the first test terminates OK but the second one loops endlessly, -dnl 0.0 if the first test already loops endlessly. +# Prerequisites of lib/glthread/lock.c. +AC_DEFUN([gl_PREREQ_LOCK], [:]) diff --git a/m4/threadlib.m4 b/m4/threadlib.m4 new file mode 100644 index 0000000..a91e819 --- /dev/null +++ b/m4/threadlib.m4 @@ -0,0 +1,341 @@ +# threadlib.m4 serial 10 (gettext-0.18.2) modified by wk 2014-01-15. +dnl Copyright (C) 2005-2014 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Bruno Haible. + +dnl gl_THREADLIB +dnl ------------ +dnl Tests for a multithreading library to be used. +dnl If the configure.ac contains a definition of the gl_THREADLIB_DEFAULT_NO +dnl (it must be placed before the invocation of gl_THREADLIB_EARLY!), then the +dnl default is 'no', otherwise it is system dependent. In both cases, the user +dnl can change the choice through the options --enable-threads=choice or +dnl --disable-threads. +dnl Defines at most one of the macros USE_POSIX_THREADS, USE_SOLARIS_THREADS, +dnl USE_WINDOWS_THREADS +dnl Sets the variables LIBTHREAD and LTLIBTHREAD to the linker options for use +dnl in a Makefile (LIBTHREAD for use without libtool, LTLIBTHREAD for use with +dnl libtool). +dnl Sets the variables LIBMULTITHREAD and LTLIBMULTITHREAD similarly, for +dnl programs that really need multithread functionality. The difference +dnl between LIBTHREAD and LIBMULTITHREAD is that on platforms supporting weak +dnl symbols, typically LIBTHREAD="" whereas LIBMULTITHREAD="-lpthread". +dnl Adds to CPPFLAGS the flag -D_REENTRANT or -D_THREAD_SAFE if needed for +dnl multithread-safe programs. + +AC_DEFUN([gl_THREADLIB_EARLY], +[ + AC_REQUIRE([gl_THREADLIB_EARLY_BODY]) +]) + +dnl The guts of gl_THREADLIB_EARLY. Needs to be expanded only once. + +AC_DEFUN([gl_THREADLIB_EARLY_BODY], +[ + dnl Ordering constraints: This macro modifies CPPFLAGS in a way that + dnl influences the result of the autoconf tests that test for *_unlocked + dnl declarations, on AIX 5 at least. Therefore it must come early. + AC_BEFORE([$0], [gl_FUNC_GLIBC_UNLOCKED_IO])dnl + AC_BEFORE([$0], [gl_ARGP])dnl + + AC_REQUIRE([AC_CANONICAL_HOST]) + dnl _GNU_SOURCE is needed for pthread_rwlock_t on glibc systems. + dnl AC_USE_SYSTEM_EXTENSIONS was introduced in autoconf 2.60 and obsoletes + dnl AC_GNU_SOURCE. + m4_ifdef([AC_USE_SYSTEM_EXTENSIONS], + [AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])], + [AC_REQUIRE([AC_GNU_SOURCE])]) + dnl Check for multithreading. + m4_ifdef([gl_THREADLIB_DEFAULT_NO], + [m4_divert_text([DEFAULTS], [gl_use_threads_default=no])], + [m4_divert_text([DEFAULTS], [gl_use_threads_default=])]) + AC_ARG_ENABLE([threads], +AC_HELP_STRING([--enable-threads={posix|solaris|windows}], [specify multithreading API])m4_ifdef([gl_THREADLIB_DEFAULT_NO], [], [ +AC_HELP_STRING([--disable-threads], [build without multithread safety])]), + [gl_use_threads=$enableval], + [if test -n "$gl_use_threads_default"; then + gl_use_threads="$gl_use_threads_default" + else +changequote(,)dnl + case "$host_os" in + dnl Disable multithreading by default on OSF/1, because it interferes + dnl with fork()/exec(): When msgexec is linked with -lpthread, its + dnl child process gets an endless segmentation fault inside execvp(). + dnl Disable multithreading by default on Cygwin 1.5.x, because it has + dnl bugs that lead to endless loops or crashes. See + dnl . + osf*) gl_use_threads=no ;; + cygwin*) + case `uname -r` in + 1.[0-5].*) gl_use_threads=no ;; + *) gl_use_threads=yes ;; + esac + ;; + *) gl_use_threads=yes ;; + esac +changequote([,])dnl + fi + ]) + if test "$gl_use_threads" = yes || test "$gl_use_threads" = posix; then + # For using : + case "$host_os" in + osf*) + # On OSF/1, the compiler needs the flag -D_REENTRANT so that it + # groks . cc also understands the flag -pthread, but + # we don't use it because 1. gcc-2.95 doesn't understand -pthread, + # 2. putting a flag into CPPFLAGS that has an effect on the linker + # causes the AC_LINK_IFELSE test below to succeed unexpectedly, + # leading to wrong values of LIBTHREAD and LTLIBTHREAD. + CPPFLAGS="$CPPFLAGS -D_REENTRANT" + ;; + esac + # Some systems optimize for single-threaded programs by default, and + # need special flags to disable these optimizations. For example, the + # definition of 'errno' in . + case "$host_os" in + aix* | freebsd*) CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE" ;; + solaris*) CPPFLAGS="$CPPFLAGS -D_REENTRANT" ;; + esac + fi +]) + +dnl The guts of gl_THREADLIB. Needs to be expanded only once. + +AC_DEFUN([gl_THREADLIB_BODY], +[ + AC_REQUIRE([gl_THREADLIB_EARLY_BODY]) + gl_threads_api=none + LIBTHREAD= + LTLIBTHREAD= + LIBMULTITHREAD= + LTLIBMULTITHREAD= + if test "$gl_use_threads" != no; then + dnl Check whether the compiler and linker support weak declarations. + AC_CACHE_CHECK([whether imported symbols can be declared weak], + [gl_cv_have_weak], + [gl_cv_have_weak=no + dnl First, test whether the compiler accepts it syntactically. + AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[extern void xyzzy (); +#pragma weak xyzzy]], + [[xyzzy();]])], + [gl_cv_have_weak=maybe]) + if test $gl_cv_have_weak = maybe; then + dnl Second, test whether it actually works. On Cygwin 1.7.2, with + dnl gcc 4.3, symbols declared weak always evaluate to the address 0. + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#pragma weak fputs +int main () +{ + return (fputs == NULL); +}]])], + [gl_cv_have_weak=yes], + [gl_cv_have_weak=no], + [dnl When cross-compiling, assume that only ELF platforms support + dnl weak symbols. + AC_EGREP_CPP([Extensible Linking Format], + [#ifdef __ELF__ + Extensible Linking Format + #endif + ], + [gl_cv_have_weak="guessing yes"], + [gl_cv_have_weak="guessing no"]) + ]) + fi + ]) + if test "$gl_use_threads" = yes || test "$gl_use_threads" = posix; then + # On OSF/1, the compiler needs the flag -pthread or -D_REENTRANT so that + # it groks . It's added above, in gl_THREADLIB_EARLY_BODY. + AC_CHECK_HEADER([pthread.h], + [gl_have_pthread_h=yes], [gl_have_pthread_h=no]) + if test "$gl_have_pthread_h" = yes; then + # Other possible tests: + # -lpthreads (FSU threads, PCthreads) + # -lgthreads + gl_have_pthread= + # Test whether both pthread_mutex_lock and pthread_mutexattr_init exist + # in libc. IRIX 6.5 has the first one in both libc and libpthread, but + # the second one only in libpthread, and lock.c needs it. + AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[#include ]], + [[pthread_mutex_lock((pthread_mutex_t*)0); + pthread_mutexattr_init((pthread_mutexattr_t*)0);]])], + [gl_have_pthread=yes]) + # Test for libpthread by looking for pthread_kill. (Not pthread_self, + # since it is defined as a macro on OSF/1.) + if test -n "$gl_have_pthread"; then + # The program links fine without libpthread. But it may actually + # need to link with libpthread in order to create multiple threads. + AC_CHECK_LIB([pthread], [pthread_kill], + [LIBMULTITHREAD=-lpthread LTLIBMULTITHREAD=-lpthread + # On Solaris and HP-UX, most pthread functions exist also in libc. + # Therefore pthread_in_use() needs to actually try to create a + # thread: pthread_create from libc will fail, whereas + # pthread_create will actually create a thread. + case "$host_os" in + solaris* | hpux*) + AC_DEFINE([PTHREAD_IN_USE_DETECTION_HARD], [1], + [Define if the pthread_in_use() detection is hard.]) + esac + ]) + else + # Some library is needed. Try libpthread and libc_r. + AC_CHECK_LIB([pthread], [pthread_kill], + [gl_have_pthread=yes + LIBTHREAD=-lpthread LTLIBTHREAD=-lpthread + LIBMULTITHREAD=-lpthread LTLIBMULTITHREAD=-lpthread]) + if test -z "$gl_have_pthread"; then + # For FreeBSD 4. + AC_CHECK_LIB([c_r], [pthread_kill], + [gl_have_pthread=yes + LIBTHREAD=-lc_r LTLIBTHREAD=-lc_r + LIBMULTITHREAD=-lc_r LTLIBMULTITHREAD=-lc_r]) + fi + fi + if test -n "$gl_have_pthread"; then + gl_threads_api=posix + AC_DEFINE([USE_POSIX_THREADS], [1], + [Define if the POSIX multithreading library can be used.]) + if test -n "$LIBMULTITHREAD" || test -n "$LTLIBMULTITHREAD"; then + if case "$gl_cv_have_weak" in *yes) true;; *) false;; esac; then + AC_DEFINE([USE_POSIX_THREADS_WEAK], [1], + [Define if references to the POSIX multithreading library should be made weak.]) + LIBTHREAD= + LTLIBTHREAD= + fi + fi + fi + fi + fi + if test -z "$gl_have_pthread"; then + if test "$gl_use_threads" = yes || test "$gl_use_threads" = solaris; then + gl_have_solaristhread= + gl_save_LIBS="$LIBS" + LIBS="$LIBS -lthread" + AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[ +#include +#include + ]], + [[thr_self();]])], + [gl_have_solaristhread=yes]) + LIBS="$gl_save_LIBS" + if test -n "$gl_have_solaristhread"; then + gl_threads_api=solaris + LIBTHREAD=-lthread + LTLIBTHREAD=-lthread + LIBMULTITHREAD="$LIBTHREAD" + LTLIBMULTITHREAD="$LTLIBTHREAD" + AC_DEFINE([USE_SOLARIS_THREADS], [1], + [Define if the old Solaris multithreading library can be used.]) + if case "$gl_cv_have_weak" in *yes) true;; *) false;; esac; then + AC_DEFINE([USE_SOLARIS_THREADS_WEAK], [1], + [Define if references to the old Solaris multithreading library should be made weak.]) + LIBTHREAD= + LTLIBTHREAD= + fi + fi + fi + fi + if test -z "$gl_have_pthread"; then + case "$gl_use_threads" in + yes | windows | win32) # The 'win32' is for backward compatibility. + if { case "$host_os" in + mingw*) true;; + *) false;; + esac + }; then + gl_threads_api=windows + AC_DEFINE([USE_WINDOWS_THREADS], [1], + [Define if the native Windows multithreading API can be used.]) + fi + ;; + esac + fi + fi + AC_MSG_CHECKING([for multithread API to use]) + AC_MSG_RESULT([$gl_threads_api]) + AC_SUBST([LIBTHREAD]) + AC_SUBST([LTLIBTHREAD]) + AC_SUBST([LIBMULTITHREAD]) + AC_SUBST([LTLIBMULTITHREAD]) +]) + +AC_DEFUN([gl_THREADLIB], +[ + AC_REQUIRE([gl_THREADLIB_EARLY]) + AC_REQUIRE([gl_THREADLIB_BODY]) +]) + + +dnl gl_DISABLE_THREADS +dnl ------------------ +dnl Sets the gl_THREADLIB default so that threads are not used by default. +dnl The user can still override it at installation time, by using the +dnl configure option '--enable-threads'. + +AC_DEFUN([gl_DISABLE_THREADS], [ + m4_divert_text([INIT_PREPARE], [gl_use_threads_default=no]) +]) + + +dnl Survey of platforms: +dnl +dnl Platform Available Compiler Supports test-lock +dnl flavours option weak result +dnl --------------- --------- --------- -------- --------- +dnl Linux 2.4/glibc posix -lpthread Y OK +dnl +dnl GNU Hurd/glibc posix +dnl +dnl FreeBSD 5.3 posix -lc_r Y +dnl posix -lkse ? Y +dnl posix -lpthread ? Y +dnl posix -lthr Y +dnl +dnl FreeBSD 5.2 posix -lc_r Y +dnl posix -lkse Y +dnl posix -lthr Y +dnl +dnl FreeBSD 4.0,4.10 posix -lc_r Y OK +dnl +dnl NetBSD 1.6 -- +dnl +dnl OpenBSD 3.4 posix -lpthread Y OK +dnl +dnl Mac OS X 10.[123] posix -lpthread Y OK +dnl +dnl Solaris 7,8,9 posix -lpthread Y Sol 7,8: 0.0; Sol 9: OK +dnl solaris -lthread Y Sol 7,8: 0.0; Sol 9: OK +dnl +dnl HP-UX 11 posix -lpthread N (cc) OK +dnl Y (gcc) +dnl +dnl IRIX 6.5 posix -lpthread Y 0.5 +dnl +dnl AIX 4.3,5.1 posix -lpthread N AIX 4: 0.5; AIX 5: OK +dnl +dnl OSF/1 4.0,5.1 posix -pthread (cc) N OK +dnl -lpthread (gcc) Y +dnl +dnl Cygwin posix -lpthread Y OK +dnl +dnl Any of the above pth -lpth 0.0 +dnl +dnl Mingw windows N OK +dnl +dnl BeOS 5 -- +dnl +dnl The test-lock result shows what happens if in test-lock.c EXPLICIT_YIELD is +dnl turned off: +dnl OK if all three tests terminate OK, +dnl 0.5 if the first test terminates OK but the second one loops endlessly, +dnl 0.0 if the first test already loops endlessly. diff --git a/src/Makefile.am b/src/Makefile.am index 74d89be..51b2ea9 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -30,7 +30,15 @@ extra_cppflags = endif localedir = $(datadir)/locale + bin_PROGRAMS = gpg-error + +if HAVE_W32_SYSTEM +noinst_PROGRAMS = gen-w32-lock-obj +else +noinst_PROGRAMS = gen-posix-lock-obj +endif + lib_LTLIBRARIES = libgpg-error.la include_HEADERS = gpg-error.h bin_SCRIPTS = gpg-error-config @@ -42,7 +50,8 @@ EXTRA_DIST = mkstrtable.awk err-sources.h.in err-codes.h.in \ mkerrcodes.awk mkerrcodes1.awk mkerrcodes2.awk mkerrcodes.c \ mkheader.c gpg-error.h.in mkw32errmap.c w32-add.h w32ce-add.h \ err-sources.h err-codes.h gpg-error-config.in gpg-error.m4 \ - gpg-error.def.in versioninfo.rc.in + gpg-error.def.in versioninfo.rc.in \ + w32-lock-obj-pub.in BUILT_SOURCES = err-sources.h err-codes.h code-to-errno.h code-from-errno.h \ err-sources-sym.h err-codes-sym.h errnos-sym.h gpg-error.h \ @@ -53,11 +62,10 @@ tmp_files = _mkerrcodes.h _gpg-error.def.h mkw32errmap.tab.h mkw32errmap.map.c CLEANFILES = err-sources.h err-codes.h code-to-errno.h code-from-errno.h \ gpg-error.h mkerrcodes mkerrcodes.h gpg-error.def mkw32errmap.tab.h \ mkw32errmap.map.c err-sources-sym.h err-codes-sym.h errnos-sym.h \ - gpg-extra/errno.h mkheader $(tmp_files) + gpg-extra/errno.h mkheader $(tmp_files) posix-lock-obj-pub.in if HAVE_W32_SYSTEM -arch_sources = w32-gettext.c - +arch_sources = w32-gettext.c w32-lock.c w32-lock-obj.h w32-thread.c RCCOMPILE = $(RC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ -DLOCALEDIR=\"$(localedir)\" $(AM_CPPFLAGS) $(CPPFLAGS) LTRCCOMPILE = $(LIBTOOL) --mode=compile --tag=RC $(RCCOMPILE) @@ -82,7 +90,7 @@ libgpg_error_la_DEPENDENCIES = $(gpg_error_res) gpg-error.def intllibs = else -arch_sources = +arch_sources = posix-lock.c posix-lock-obj.h posix-thread.c gpg_error_res = no_undefined = export_symbols = @@ -98,17 +106,22 @@ libgpg_error_la_LDFLAGS = -version-info \ @LIBGPG_ERROR_LT_CURRENT@:@LIBGPG_ERROR_LT_REVISION@:@LIBGPG_ERROR_LT_AGE@ \ $(no_undefined) $(export_symbols) -parts_of_gpg_error_h = \ - gpg-error.h.in \ - err-sources.h.in \ - err-codes.h.in \ - errnos.in \ - w32-add.h \ - w32ce-add.h +parts_of_gpg_error_h = \ + gpg-error.h.in \ + err-sources.h.in \ + err-codes.h.in \ + errnos.in \ + w32-add.h \ + w32ce-add.h \ + w32-lock-obj-pub.in + +if ! HAVE_W32_SYSTEM +parts_of_gpg_error_h += posix-lock-obj-pub.in +endif libgpg_error_la_SOURCES = gpg-error.h gettext.h $(arch_sources) \ - init.c init.h version.c \ + init.c init.h version.c lock.h thread.h \ strsource.c strerror.c code-to-errno.c code-from-errno.c # Note that RCCOMPILE needs the same defines as ..._la_CPPFLAGS but @@ -195,9 +208,14 @@ errnos-sym.h: Makefile mkstrtable.awk errnos.in -v prefix=GPG_ERR_ -v namespace=errnos_ \ $(srcdir)/errnos.in >$@ + mkheader: mkheader.c Makefile $(CC_FOR_BUILD) -g -O0 -I. -I$(srcdir) -o $@ $(srcdir)/mkheader.c + +posix-lock-obj-pub.in: Makefile gen-posix-lock-obj posix-lock-obj.h + ./gen-posix-lock-obj >$@ + # We also depend on versioninfo.rc because that is build by # config.status and thus has up-to-date version numbers. gpg-error.h: Makefile mkheader $(parts_of_gpg_error_h) versioninfo.rc diff --git a/src/err-codes.h.in b/src/err-codes.h.in index 4ecc24e..c912bcd 100644 --- a/src/err-codes.h.in +++ b/src/err-codes.h.in @@ -247,7 +247,11 @@ 212 GPG_ERR_SEXP_ODD_HEX_NUMBERS Odd hexadecimal numbers in S-expression 213 GPG_ERR_SEXP_BAD_OCT_CHAR Bad octal character in S-expression -# 214 to 254 are free to be used. 255 and 256 are RFU. +# 214 to 253 are free to be used. + +254 GPG_ERR_INV_LOCK_OBJ Invalid lock object + +# 255 and 256 are RFU. # Error codes pertaining to the Assuan IPC interface 257 GPG_ERR_ASS_GENERAL General IPC error diff --git a/src/gen-posix-lock-obj.c b/src/gen-posix-lock-obj.c new file mode 100644 index 0000000..b641fd0 --- /dev/null +++ b/src/gen-posix-lock-obj.c @@ -0,0 +1,95 @@ +/* gen-posix-lock-obj.c - Build tool to construct the lock object. + Copyright (C) 2014 g10 Code GmbH + + This file is part of libgpg-error. + + libgpg-error is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public License + as published by the Free Software Foundation; either version 2.1 of + the License, or (at your option) any later version. + + libgpg-error 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 . + */ + +#if HAVE_CONFIG_H +#include +#endif + +#ifdef HAVE_W32_SYSTEM +# error This module may not be build for Windows. +#endif + +#include +#include +#include + +#include "posix-lock-obj.h" + +#define PGM "gen-posix-lock-obj" + +/* Check that configure did its job. */ +#if SIZEOF_PTHREAD_MUTEX_T < 4 +# error sizeof pthread_mutex_t is not known. +#endif + +static pthread_mutex_t mtx = PTHREAD_MUTEX_INITIALIZER; + + +int +main (void) +{ + unsigned char *p; + int i; + struct { + pthread_mutex_t mtx; + long vers; + } dummyobj; + + if (sizeof mtx != SIZEOF_PTHREAD_MUTEX_T) + { + fprintf (stderr, PGM ": pthread_mutex_t mismatch\n"); + exit (1); + } + + if (sizeof (dummyobj) != sizeof (_gpgrt_lock_t)) + { + fprintf (stderr, PGM ": internal and external lock object mismatch\n"); + exit (1); + } + + /* To force a probably suitable alignment of the structure we use a + union and include a long and a pointer to a long. */ + printf ("## File created by " PGM " - DO NOT EDIT\n" + "## To be included by mkheader into gpg-error.h\n" + "\n" + "typedef union\n" + "{\n" + " struct {\n" + " volatile char _priv[%d];\n" + " long _vers;\n" + " } d;\n" + " long _x_align;\n" + " long *_xp_align;\n" + "} gpgrt_lock_t;\n" + "\n" + "#define GPGRT_LOCK_INITIALIZER {{{", + SIZEOF_PTHREAD_MUTEX_T); + p = (unsigned char *)&mtx; + for (i=0; i < sizeof mtx; i++) + { + if (i && !(i % 8)) + printf (" \\\n%*s", 34, ""); + printf ("%u", p[i]); + if (i < sizeof mtx - 1) + putchar (','); + } + printf ("},%d}}\n", LOCK_ABI_VERSION); + + return 0; +} diff --git a/src/gen-w32-lock-obj.c b/src/gen-w32-lock-obj.c new file mode 100644 index 0000000..9e49d1e --- /dev/null +++ b/src/gen-w32-lock-obj.c @@ -0,0 +1,55 @@ +/* gen-w32-lock-obj.c - Build tool to get the size of the lock object. + Copyright (C) 2014 g10 Code GmbH + + This file is part of libgpg-error. + + libgpg-error is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public License + as published by the Free Software Foundation; either version 2.1 of + the License, or (at your option) any later version. + + libgpg-error 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 . + */ + +#if HAVE_CONFIG_H +#include +#endif + +#ifndef HAVE_W32_SYSTEM +# error This module may only be build for Windows. +#endif + +#include +#include +#include + +#include "w32-lock-obj.h" + + +int +main (void) +{ + _gpgrt_lock_t lk; + unsigned char *p; + int i; + + printf ("sizeof CRITICAL_SECTION = %u\n", (int)sizeof (CRITICAL_SECTION)); + printf ("sizeof _gpgrt_lock_t = %u\n", (int)sizeof lk); + + memset (&lk, 0, sizeof lk); + lk.vers = LOCK_ABI_VERSION; + lk.started = -1; + printf ("#define GPGRT_LOCK_INITIALIZER {"); + p = (unsigned char *)&lk; + for (i=0; i < sizeof lk - 1; i++) + printf ("%u,", p[i]); + printf ("%u}\n", p[sizeof(lk)-1]); + + return 0; +} diff --git a/src/gpg-error.def.in b/src/gpg-error.def.in index 62e0681..2ea482a 100644 --- a/src/gpg-error.def.in +++ b/src/gpg-error.def.in @@ -28,3 +28,9 @@ EXPORTS #endif gpg_err_deinit @18 gpg_error_check_version @19 + + gpgrt_lock_init @20 + gpgrt_lock_lock @21 + gpgrt_lock_unlock @22 + gpgrt_lock_destroy @23 + gpgrt_yield @24 diff --git a/src/gpg-error.h.in b/src/gpg-error.h.in index a2fb044..adb796b 100644 --- a/src/gpg-error.h.in +++ b/src/gpg-error.h.in @@ -66,7 +66,10 @@ extern "C" { GPG_ERR_ENABLE_GETTEXT_MACROS: Define to provide macros to map the internal gettext API to standard names. This has only an effect on - Windows platforms. */ + Windows platforms. + + In addition to the error codes, Libgpg-error also provides a set of + functions used by most GnuPG components. */ /* The error source type gpg_err_source_t. @@ -279,9 +282,35 @@ gpg_error_from_syserror (void) return gpg_error (gpg_err_code_from_syserror ()); } + + +/* Lock functions. */ + + at include:lock-obj@ + +#define GPGRT_LOCK_DEFINE(name) \ + static gpgrt_lock_t name = GPGRT_LOCK_INITIALIZER + + +gpg_err_code_t gpgrt_lock_init (gpgrt_lock_t *lockhd); +gpg_err_code_t gpgrt_lock_lock (gpgrt_lock_t *lockhd); +gpg_err_code_t gpgrt_lock_unlock (gpgrt_lock_t *lockhd); +gpg_err_code_t gpgrt_lock_destroy (gpgrt_lock_t *lockhd); + + + +/* Thread functions. */ + +gpg_err_code_t gpgrt_yield (void); + + + + +/* Estream */ + + + #ifdef __cplusplus } #endif - - #endif /* GPG_ERROR_H */ diff --git a/src/lock.h b/src/lock.h new file mode 100644 index 0000000..b60f2c2 --- /dev/null +++ b/src/lock.h @@ -0,0 +1,24 @@ +/* lock.h - Declarations for *-lock.c + Copyright (C) 2014 g10 Code GmbH + + This file is part of libgpg-error. + + libgpg-error is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public License + as published by the Free Software Foundation; either version 2.1 of + the License, or (at your option) any later version. + + libgpg-error 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 LOCK_H +#define LOCK_H + + +#endif /*LOCK_H*/ diff --git a/src/mkheader.c b/src/mkheader.c index eea7914..e7db729 100644 --- a/src/mkheader.c +++ b/src/mkheader.c @@ -132,7 +132,8 @@ write_errnos_in (char *line) is not further expanded. It may have comments indicated by a double hash mark at the begin of a line. OUTF is called for each read line and passed a buffer with the content of line sans line - line endings. */ + line endings. If NAME is prefixed with "./" it is included from + the current directory and not from the source directory. */ static void include_file (const char *fname, int lnr, const char *name, void (*outf)(char*)) { @@ -147,7 +148,11 @@ include_file (const char *fname, int lnr, const char *name, void (*outf)(char*)) fputs (PGM ": out of core\n", stderr); exit (1); } - strcpy (incfname, srcdir); + + if (*name == '.' && name[1] == '/') + *incfname = 0; + else + strcpy (incfname, srcdir); strcat (incfname, name); fp = fopen (incfname, "r"); @@ -242,6 +247,15 @@ write_special (const char *fname, int lnr, const char *tag) include_file (fname, lnr, "w32ce-add.h", write_line); } } + else if (!strcmp (tag, "include:lock-obj")) + { + if (!strcmp (host_os, "mingw32")) + { + include_file (fname, lnr, "w32-lock-obj-pub.in", write_line); + } + else + include_file (fname, lnr, "./posix-lock-obj-pub.in", write_line); + } else return 0; /* Unknown tag. */ diff --git a/src/posix-lock-obj.h b/src/posix-lock-obj.h new file mode 100644 index 0000000..a5a9ee7 --- /dev/null +++ b/src/posix-lock-obj.h @@ -0,0 +1,32 @@ +/* posic-lock-obj.h - Declaration of the POSIX lock object + Copyright (C) 2014 g10 Code GmbH + + This file is part of libgpg-error. + + libgpg-error is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public License + as published by the Free Software Foundation; either version 2.1 of + the License, or (at your option) any later version. + + libgpg-error 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 POSIX_LOCK_OBJ_H +#define POSIX_LOCK_OBJ_H + +#define LOCK_ABI_VERSION 1 + +typedef struct +{ + pthread_mutex_t mtx; + long vers; +} _gpgrt_lock_t; + + +#endif /*POSIX_LOCK_OBJ_H*/ diff --git a/src/posix-lock.c b/src/posix-lock.c new file mode 100644 index 0000000..46e3a84 --- /dev/null +++ b/src/posix-lock.c @@ -0,0 +1,213 @@ +/* posix-lock.c - GPGRT lock functions for POSIX systems + Copyright (C) 2005-2009 Free Software Foundation, Inc. + Copyright (C) 2014 g10 Code GmbH + + This file is part of libgpg-error. + + libgpg-error is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public License + as published by the Free Software Foundation; either version 2.1 of + the License, or (at your option) any later version. + + libgpg-error 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 . + + Parts of the code, in particular use_pthreads_p, are based on code + from gettext, written by Bruno Haible , 2005. + */ + +#if HAVE_CONFIG_H +#include +#endif + +#ifdef HAVE_W32_SYSTEM +# error This module may not be build for Windows. +#endif + +#include +#include +#include +#include + +#if USE_POSIX_THREADS +# include +#endif + +#include "gpg-error.h" +#include "lock.h" +#include "posix-lock-obj.h" + + +#if USE_POSIX_THREADS +# if USE_POSIX_THREADS_WEAK + /* On ELF systems it is easy to use pthreads using weak + references. Take care not to test the address of a weak + referenced function we actually use; some GCC versions have a + bug were &foo != NULL is always evaluated to true in PIC mode. */ +# pragma weak pthread_cancel +# pragma weak pthread_mutex_init +# pragma weak pthread_mutex_lock +# pragma weak pthread_mutex_unlock +# pragma weak pthread_mutex_destroy +# if ! PTHREAD_IN_USE_DETECTION_HARD +# define use_pthread_p() (!!pthread_cancel) +# endif +# else /*!USE_POSIX_THREADS_WEAK*/ +# if ! PTHREAD_IN_USE_DETECTION_HARD +# define use_pthread_p() (1) +# endif +# endif /*!USE_POSIX_THREADS_WEAK*/ +# if PTHREAD_IN_USE_DETECTION_HARD +/* The function to be executed by a dummy thread. */ +static void * +dummy_thread_func (void *arg) +{ + return arg; +} + +static int +use_pthread_p (void) +{ + static int tested; + static int result; /* 1: linked with -lpthread, 0: only with libc */ + + if (!tested) + { + pthread_t thread; + + if (pthread_create (&thread, NULL, dummy_thread_func, NULL)) + result = 0; /* Thread creation failed. */ + else + { + /* Thread creation works. */ + void *retval; + if (pthread_join (thread, &retval) != 0) + abort (); + result = 1; + } + tested = 1; + } + return result; +} +#endif /*PTHREAD_IN_USE_DETECTION_HARD*/ +#endif /*USE_POSIX_THREADS*/ + + + +static _gpgrt_lock_t * +get_lock_object (gpgrt_lock_t *lockhd) +{ + _gpgrt_lock_t *lock = (_gpgrt_lock_t*)lockhd; + + if (lock->vers != LOCK_ABI_VERSION) + abort (); + if (sizeof (gpgrt_lock_t) < sizeof (_gpgrt_lock_t)) + abort (); + + return lock; +} + + +gpg_err_code_t +gpgrt_lock_init (gpgrt_lock_t *lockhd) +{ + _gpgrt_lock_t *lock = get_lock_object (lockhd); + int rc; + +#if USE_POSIX_THREADS + if (use_pthread_p()) + { + rc = pthread_mutex_init (&lock->mtx, NULL); + if (rc) + rc = gpg_err_code_from_errno (rc); + } + else + rc = 0; /* Threads are not used. */ +#else /* Unknown thread system. */ + rc = GPG_ERR_NOT_IMPLEMENTED; +#endif /* Unknown thread system. */ + + return rc; +} + + +gpg_err_code_t +gpgrt_lock_lock (gpgrt_lock_t *lockhd) +{ + _gpgrt_lock_t *lock = get_lock_object (lockhd); + int rc; + +#if USE_POSIX_THREADS + if (use_pthread_p()) + { + rc = pthread_mutex_lock (&lock->mtx); + if (rc) + rc = gpg_err_code_from_errno (rc); + } + else + rc = 0; /* Threads are not used. */ +#else /* Unknown thread system. */ + rc = GPG_ERR_NOT_IMPLEMENTED; +#endif /* Unknown thread system. */ + + return rc; +} + + +gpg_err_code_t +gpgrt_lock_unlock (gpgrt_lock_t *lockhd) +{ + _gpgrt_lock_t *lock = get_lock_object (lockhd); + int rc; + +#if USE_POSIX_THREADS + if (use_pthread_p()) + { + rc = pthread_mutex_unlock (&lock->mtx); + if (rc) + rc = gpg_err_code_from_errno (rc); + } + else + rc = 0; /* Threads are not used. */ +#else /* Unknown thread system. */ + rc = GPG_ERR_NOT_IMPLEMENTED; +#endif /* Unknown thread system. */ + + return rc; +} + + +/* Note: Use this function only if no other thread holds or waits for + this lock. */ +gpg_err_code_t +gpgrt_lock_destroy (gpgrt_lock_t *lockhd) +{ + _gpgrt_lock_t *lock = get_lock_object (lockhd); + int rc; + +#if USE_POSIX_THREADS + if (use_pthread_p()) + { + rc = pthread_mutex_destroy (&lock->mtx); + if (rc) + rc = gpg_err_code_from_errno (rc); + else + { + /* Re-init the the mutex so that it can be re-used. */ + gpgrt_lock_t tmp = GPGRT_LOCK_INITIALIZER; + memcpy (lockhd, &tmp, sizeof tmp); + } + } + else + rc = 0; /* Threads are not used. */ +#else /* Unknown thread system. */ + rc = GPG_ERR_NOT_IMPLEMENTED; +#endif /* Unknown thread system. */ + + return rc; +} diff --git a/src/posix-thread.c b/src/posix-thread.c new file mode 100644 index 0000000..a739e40 --- /dev/null +++ b/src/posix-thread.c @@ -0,0 +1,63 @@ +/* posix-thread.c - GPGRT thread functions for POSIX systems + Copyright (C) 2014 g10 Code GmbH + + This file is part of libgpg-error. + + libgpg-error is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public License + as published by the Free Software Foundation; either version 2.1 of + the License, or (at your option) any later version. + + libgpg-error 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 . + */ + +#if HAVE_CONFIG_H +#include +#endif + +#ifdef HAVE_W32_SYSTEM +# error This module may not be build for Windows. +#endif + +#include +#include +#include +#include +#include /* Get posix option macros. */ + +#if USE_POSIX_THREADS +# ifdef _POSIX_PRIORITY_SCHEDULING +# include +# endif +#elif USE_SOLARIS_THREADS +# include +#endif + +#include "gpg-error.h" + +#include "thread.h" + + +gpg_err_code_t +gpgrt_yield (void) +{ +#if USE_POSIX_THREADS +# ifdef _POSIX_PRIORITY_SCHEDULING + sched_yield (); +# else + return GPG_ERR_NOT_SUPPORTED; +# endif +#elif USE_SOLARIS_THREADS + thr_yield (); +#else + return GPG_ERR_NOT_SUPPORTED; +#endif + + return 0; +} diff --git a/src/thread.h b/src/thread.h new file mode 100644 index 0000000..0b2cf04 --- /dev/null +++ b/src/thread.h @@ -0,0 +1,24 @@ +/* thread.h - Declarations for *-thread.c + Copyright (C) 2014 g10 Code GmbH + + This file is part of libgpg-error. + + libgpg-error is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public License + as published by the Free Software Foundation; either version 2.1 of + the License, or (at your option) any later version. + + libgpg-error 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 THREAD_H +#define THREAD_H + + +#endif /*THREAD_H*/ diff --git a/src/version.c b/src/version.c index 36e2d58..5b40537 100644 --- a/src/version.c +++ b/src/version.c @@ -1,5 +1,5 @@ /* version.c - Version checking - * Copyright (C) 2001, 2002, 2012, 2013 g10 Code GmbH + * Copyright (C) 2001, 2002, 2012, 2013, 2014 g10 Code GmbH * * This file is part of libgpg-error. * @@ -39,7 +39,7 @@ cright_blurb (void) static const char blurb[] = "\n\n" "This is Libgpg-error " PACKAGE_VERSION " - An error code library\n" - "Copyright 2003, 2004, 2010, 2013 g10 Code GmbH\n" + "Copyright 2003, 2004, 2010, 2013, 2014 g10 Code GmbH\n" "\n" "(" BUILD_REVISION " " BUILD_TIMESTAMP ")\n" "\n\n"; diff --git a/src/w32-lock-obj-pub.in b/src/w32-lock-obj-pub.in new file mode 100644 index 0000000..2f3f911 --- /dev/null +++ b/src/w32-lock-obj-pub.in @@ -0,0 +1,44 @@ +## w32-lock-obj-pub.in - Include fragment for gpg-error.h -*- c-*- +## Copyright (C) 2014 g10 Code GmbH +## +## This file is free software; as a special exception the author gives +## unlimited permission to copy and/or distribute it, with or without +## modifications, as long as this notice is preserved. +## +## This file is distributed in the hope that it will be useful, but +## WITHOUT ANY WARRANTY, to the extent permitted by law; without even the +## implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +## +## +## This file defines the public version of the lock object for 32 bit +## Windows. The actual used version is in w32-lock-obj.h. This file +## is inserted into gpg-error.h by mkheader.c. The tool +## gen-w32-lock-obj.c has been used to construct it. + +#ifdef _WIN64 + +#pragma pack(push, 8) +typedef struct +{ + volatile char priv[56]; +} gpgrt_lock_t; +#pragma pack(pop) + +#define GPGRT_LOCK_INITIALIZER {1,0,0,0,0,0,0,0,255,255,255,255, \ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, \ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, \ + 0,0,0,0,0,0,0,0,0,0,0,0} + +#else + +#pragma pack(push, 8) +typedef struct +{ + volatile char priv[36]; +} gpgrt_lock_t; +#pragma pack(pop) + +#define GPGRT_LOCK_INITIALIZER {1,0,0,0,0,0,0,0,255,255,255,255, \ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, \ + 0,0,0,0,0,0,0,0} +#endif diff --git a/src/w32-lock-obj.h b/src/w32-lock-obj.h new file mode 100644 index 0000000..ef53546 --- /dev/null +++ b/src/w32-lock-obj.h @@ -0,0 +1,38 @@ +/* w32-lock-obj.h - Declaration of the Windows lock object + Copyright (C) 2014 g10 Code GmbH + + This file is part of libgpg-error. + + libgpg-error is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public License + as published by the Free Software Foundation; either version 2.1 of + the License, or (at your option) any later version. + + libgpg-error 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 W32_LOCK_OBJ_H +#define W32_LOCK_OBJ_H + +#define LOCK_ABI_VERSION 1 + +/* The real definition of our lock object. The public definition is + named gpgrt_lock_t and hides this internal structure. */ +#pragma pack(push, 8) +typedef struct +{ + long vers; + volatile long initdone; + volatile long started; + CRITICAL_SECTION csec; +} _gpgrt_lock_t; +#pragma pack(pop) + + +#endif /*W32_LOCK_OBJ_H*/ diff --git a/src/w32-lock.c b/src/w32-lock.c new file mode 100644 index 0000000..0ad9409 --- /dev/null +++ b/src/w32-lock.c @@ -0,0 +1,119 @@ +/* w32-lock.c - GPGRT lock functions for Windows + Copyright (C) 2014 g10 Code GmbH + + This file is part of libgpg-error. + + libgpg-error is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public License + as published by the Free Software Foundation; either version 2.1 of + the License, or (at your option) any later version. + + libgpg-error 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 . + */ + +#if HAVE_CONFIG_H +#include +#endif + +#ifndef HAVE_W32_SYSTEM +# error This module may only be build for Windows. +#endif + +#include +#include +#include +#include +#include +#define WIN32_LEAN_AND_MEAN +#include + +#include "lock.h" +#include "w32-lock-obj.h" + + +static _gpgrt_lock_t * +get_lock_object (gpgrt_lock_t *lockhd) +{ + _gpgrt_lock_t *lock = (_gpgrt_lock_t*)lockhd; + + if (lock->vers != LOCK_ABI_VERSION) + abort (); + + return lock; +} + + +gpg_err_code_t +gpgrt_lock_init (gpgrt_lock_t *lockhd) +{ + _gpgrt_lock_t *lock = get_lock_object (lockhd); + + if (sizeof (gpgrt_lock_t) < sizeof (_gpgrt_lock_t)) + abort (); + InitializeCriticalSection (&lock->csec); + lock->initdone = 1; +} + + +gpg_err_code_t +gpgrt_lock_lock (gpgrt_lock_t *lockhd) +{ + _gpgrt_lock_t *lock = get_lock_object (lockhd); + + if (!lock->initdone) + { + if (!InterlockedIncrement (&lock->started)) + { + /* The new value of started is 0. Because the initial value + if the variable was -1 we known that this thread is the + first who needs this lock. Thus we initialize now. All + other threads won't get 0 back from InterlockedIncrement + and thus fall into the wait loop below. We ignore that + STARTED may in theory overflow if this thread starves for + too long. */ + gpgrt_lock_init (lockhd); + } + else + { + while (!lock->initdone) + Sleep (0); + } + } + + EnterCriticalSection (&lock->csec); + return 0; +} + + +gpg_err_code_t +gpgrt_lock_unlock (gpgrt_lock_t *lockhd) +{ + _gpgrt_lock_t *lock = get_lock_object (lockhd); + + if (!lock->initdone) + return GPG_ERR_INV_LOCK_OBJ; + LeaveCriticalSection (&lock->csec); + return 0; +} + + +/* Note: Use this function only if no other thread holds or waits for + this lock. */ +gpg_err_code_t +gpgrt_lock_destroy (gpgrt_lock_t *lockhd) +{ + _gpgrt_lock_t *lock = get_lock_object (lockhd); + + if (!lock->initdone) + return GPG_ERR_INV_LOCK_OBJ; + DeleteCriticalSection (&lock->csec); + lock->initdone = 0; + lock->started = -1; + return 0; +} diff --git a/src/w32-thread.c b/src/w32-thread.c new file mode 100644 index 0000000..f86be35 --- /dev/null +++ b/src/w32-thread.c @@ -0,0 +1,44 @@ +/* w32-thread.c - GPGRT thread functions for Windows + Copyright (C) 2014 g10 Code GmbH + + This file is part of libgpg-error. + + libgpg-error is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public License + as published by the Free Software Foundation; either version 2.1 of + the License, or (at your option) any later version. + + libgpg-error 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 . + */ + +#if HAVE_CONFIG_H +#include +#endif + +#ifndef HAVE_W32_SYSTEM +# error This module may only be build for Windows. +#endif + +#include +#include +#include +#include +#include +#define WIN32_LEAN_AND_MEAN +#include + +#include "thread.h" + + +gpg_err_code_t +gpgrt_yield (void) +{ + Sleep (0); + return 0; +} diff --git a/tests/Makefile.am b/tests/Makefile.am index 1a27f81..277a78b 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -25,11 +25,16 @@ else extra_includes = endif +gpg_error_lib = ../src/libgpg-error.la -TESTS = t-version t-strerror t-syserror +TESTS = t-version t-strerror t-syserror t-lock INCLUDES = -I$(top_builddir)/src $(extra_includes) -LDADD = ../src/libgpg-error.la + +LDADD = $(gpg_error_lib) noinst_PROGRAMS = $(TESTS) +noinst_HEADERS = t-common.h + +t_lock_LDADD = $(gpg_error_lib) $(LIBMULTITHREAD) diff --git a/tests/t-common.h b/tests/t-common.h new file mode 100644 index 0000000..85bcd51 --- /dev/null +++ b/tests/t-common.h @@ -0,0 +1,99 @@ +/* t-common.h - Common code for the tests. + * Copyright (C) 2013 g10 Code GmbH + * + * This file is part of libgpg-error. + * + * libgpg-error is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * libgpg-error is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program; if not, see . + */ + +#include + +#include "../src/gpg-error.h" + +#ifndef PGM +# error Macro PGM not defined. +#endif + + +static int verbose; +static int debug; +static int errorcount; + + +static void +die (const char *format, ...) +{ + va_list arg_ptr ; + + fflush (stdout); +#ifdef HAVE_FLOCKFILE + flockfile (stderr); +#endif + fprintf (stderr, "%s: ", PGM); + va_start (arg_ptr, format) ; + vfprintf (stderr, format, arg_ptr); + va_end (arg_ptr); + if (*format && format[strlen(format)-1] != '\n') + putc ('\n', stderr); +#ifdef HAVE_FLOCKFILE + funlockfile (stderr); +#endif + exit (1); +} + + +static void +fail (const char *format, ...) +{ + va_list arg_ptr; + + fflush (stdout); +#ifdef HAVE_FLOCKFILE + flockfile (stderr); +#endif + fprintf (stderr, "%s: ", PGM); + va_start (arg_ptr, format); + vfprintf (stderr, format, arg_ptr); + va_end (arg_ptr); + if (*format && format[strlen(format)-1] != '\n') + putc ('\n', stderr); +#ifdef HAVE_FLOCKFILE + funlockfile (stderr); +#endif + errorcount++; + if (errorcount >= 50) + die ("stopped after 50 errors."); +} + + +static void +show (const char *format, ...) +{ + va_list arg_ptr; + + if (!verbose) + return; +#ifdef HAVE_FLOCKFILE + flockfile (stderr); +#endif + fprintf (stderr, "%s: ", PGM); + va_start (arg_ptr, format); + vfprintf (stderr, format, arg_ptr); + if (*format && format[strlen(format)-1] != '\n') + putc ('\n', stderr); + va_end (arg_ptr); +#ifdef HAVE_FLOCKFILE + funlockfile (stderr); +#endif +} diff --git a/tests/t-lock.c b/tests/t-lock.c new file mode 100644 index 0000000..91923fb --- /dev/null +++ b/tests/t-lock.c @@ -0,0 +1,318 @@ +/* t-lock.c - Check the lock functions + * Copyright (C) 2013 g10 Code GmbH + * + * This file is part of libgpg-error. + * + * libgpg-error is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * libgpg-error 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 . + */ + +#if HAVE_CONFIG_H +# include +#endif + +#include +#include +#include +#include +#ifdef _WIN32 +# include +#else +# include +#endif + +#define PGM "t-lock" + +#include "t-common.h" + +#ifdef _WIN32 +# define THREAD_RET_TYPE DWORD WINAPI +# define THREAD_RET_VALUE 0 +#else +# define THREAD_RET_TYPE void * +# define THREAD_RET_VALUE NULL +#endif + + +/* Our tests works by having a a couple of accountant threads which do + random transactions between accounts and a revision threads which + checks that the balance of all accounts is invariant. The idea for + this check is due to Bruno Haible. */ +#define N_ACCOUNT 8 +#define ACCOUNT_VALUE 42 +static int account[N_ACCOUNT]; +GPGRT_LOCK_DEFINE (accounts_lock); + +/* Number of transactions done by each accountant. */ +#define N_TRANSACTIONS 1000 + +/* Number of accountants to run. */ +#define N_ACCOUNTANTS 5 + +/* Maximum transaction value. A quite low value is used so that we + would get an integer overflow. */ +#define MAX_TRANSACTION_VALUE 50 + +/* Flag to tell the revision thread to finish. */ +static volatile int stop_revision_thread; + + +/* Initialze all accounts. */ +static void +init_accounts (void) +{ + int i; + + for (i=0; i < N_ACCOUNT; i++) + account[i] = ACCOUNT_VALUE; +} + + +/* Check that the sum of all accounts matches the intial sum. */ +static void +check_accounts (void) +{ + int i, sum; + + sum = 0; + for (i = 0; i < N_ACCOUNT; i++) + sum += account[i]; + if (sum != N_ACCOUNT * ACCOUNT_VALUE) + die ("accounts out of balance"); +} + + +static void +print_accounts (void) +{ + int i; + + for (i=0; i < N_ACCOUNT; i++) + printf ("account %d: %6d\n", i, account[i]); +} + + +/* Get a a random integer value in the range 0 to HIGH. */ +static unsigned int +get_rand (int high) +{ + return (unsigned int)(1+(int)((double)(high+1)*rand ()/(RAND_MAX+1.0))) - 1; +} + + +/* Pick a random account. Note that this fucntion is not + thread-safe. */ +static int +pick_account (void) +{ + return get_rand (N_ACCOUNT - 1); +} + + +/* Pick a random value for a transaction. This is not thread-safe. */ +static int +pick_value (void) +{ + return get_rand (MAX_TRANSACTION_VALUE); +} + + +/* This is the revision department. */ +static THREAD_RET_TYPE +revision_thread (void *arg) +{ + gpg_err_code_t rc; + int i; + + (void)arg; + + while (!stop_revision_thread) + { + rc = gpgrt_lock_lock (&accounts_lock); + if (rc) + fail ("gpgrt_lock_lock failed at %d: %s", __LINE__, gpg_strerror (rc)); + + check_accounts (); + rc = gpgrt_lock_unlock (&accounts_lock); + if (rc) + fail ("gpgrt_lock_unlock failed at %d: %s", __LINE__,gpg_strerror (rc)); + if (!(++i%7)) + gpgrt_yield (); + } + return THREAD_RET_VALUE; +} + + +/* This is one of our accountants. */ +static THREAD_RET_TYPE +accountant_thread (void *arg) +{ + gpg_err_code_t rc; + int i; + int acc1, acc2; + int value; + + (void)arg; + + for (i = 0; i < N_TRANSACTIONS; i++) + { + rc = gpgrt_lock_lock (&accounts_lock); + if (rc) + fail ("gpgrt_lock_lock failed at %d: %s", __LINE__, gpg_strerror (rc)); + + acc1 = pick_account (); + acc2 = pick_account (); + value = pick_value (); + account[acc1] += value; + account[acc2] -= value; + + rc = gpgrt_lock_unlock (&accounts_lock); + if (rc) + fail ("gpgrt_lock_unlock failed at %d: %s", __LINE__,gpg_strerror (rc)); + if (i && !(i%8)) + gpgrt_yield (); + } + return THREAD_RET_VALUE; +} + + +static void +run_test (void) +{ +#ifdef _WIN32 + HANDLE rthread; + HANDLE athreads[N_ACCOUNTANTS]; + int i; + int rc; + + stop_revision_thread = 0; + rthread = CreateThread (NULL, 0, revision_thread, NULL, 0, NULL); + if (!rthread) + die ("error creating revision thread: rc=%d", (int)GetLastError ()); + + for (i=0; i < N_ACCOUNTANTS; i++) + { + athreads[i] = CreateThread (NULL, 0, accountant_thread, NULL, 0, NULL); + if (!athreads[i]) + die ("error creating accountant thread %d: rc=%d", + i, (int)GetLastError ()); + } + + for (i=0; i < N_ACCOUNTANTS; i++) + { + rc = WaitForSingleObject (athreads[i], INFINITE); + if (rc == WAIT_OBJECT_0) + show ("accountant thread %d has terminated", i); + else + fail ("waiting for accountant thread %d failed: %d", + i, (int)GetLastError ()); + CloseHandle (athreads[i]); + } + stop_revision_thread = 1; + + rc = WaitForSingleObject (rthread, INFINITE); + if (rc == WAIT_OBJECT_0) + show ("revision thread has terminated"); + else + fail ("waiting for revision thread failed: %d", (int)GetLastError ()); + CloseHandle (rthread); + +#else /*!_WIN32*/ + pthread_t rthread; + pthread_t athreads[N_ACCOUNTANTS]; + int i; + + stop_revision_thread = 0; + pthread_create (&rthread, NULL, revision_thread, NULL); + + for (i=0; i < N_ACCOUNTANTS; i++) + pthread_create (&athreads[i], NULL, accountant_thread, NULL); + + for (i=0; i < N_ACCOUNTANTS; i++) + { + pthread_join (athreads[i], NULL); + show ("accountant thread %d has terminated", i); + } + + stop_revision_thread = 1; + pthread_join (rthread, NULL); + show ("revision thread has terminated"); + +#endif /*!_WIN32*/ + + gpgrt_lock_destroy (&accounts_lock); +} + + +int +main (int argc, char **argv) +{ + int last_argc = -1; + int rc; + + if (argc) + { + argc--; argv++; + } + while (argc && last_argc != argc ) + { + last_argc = argc; + if (!strcmp (*argv, "--help")) + { + puts ( +"usage: ./t-lock [options]\n" +"\n" +"Options:\n" +" --verbose Show what is going on\n" +" --debug Flyswatter\n" +); + exit (0); + } + if (!strcmp (*argv, "--verbose")) + { + verbose = 1; + argc--; argv++; + } + else if (!strcmp (*argv, "--debug")) + { + verbose = debug = 1; + argc--; argv++; + } + } + + srand (time(NULL)*getpid()); + + if (!gpg_error_check_version (GPG_ERROR_VERSION)) + { + die ("gpg_error_check_version returned an error"); + errorcount++; + } + + init_accounts (); + check_accounts (); + run_test (); + check_accounts (); + /* Run a second time to check deinit code. */ + run_test (); + check_accounts (); + /* And a third time to test an explicit init. */ + rc = gpgrt_lock_init (&accounts_lock); + if (rc) + fail ("gpgrt_lock_init failed at %d: %s", __LINE__, gpg_strerror (rc)); + run_test (); + check_accounts (); + if (verbose) + print_accounts (); + + return errorcount ? 1 : 0; +} commit 78a06348fb07f2dce861615cc6d19964818f7334 Author: Werner Koch Date: Thu Jan 9 19:14:09 2014 +0100 Improve maintainability by rewriting the mkheader helper. * src/mkheader.c: New. Based on the mkheader from Libassuan. * src/mkheader.awk: Remove. * src/errnos.in: Add trailing linefeed. * src/gpg-error.h.in: Change meta include directives for use with mkheader.c. * src/Makefile.am (EXTRA_DIST): Replace mkheader.awk by mkheader.c (BUILT_SOURCES): Remove extra-h.in. (CLEANFILES): Remove extra-h.in. Add mkheader.c. (parts_of_gpg_error_h): New. (extra-h.in): Remove rule. (mkheader): Add rule. (gpg-error.h): Change rule to use mkheader. Signed-off-by: Werner Koch diff --git a/src/Makefile.am b/src/Makefile.am index 7143dbd..74d89be 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,5 +1,5 @@ # Makefile.am for libgpg-error. -# Copyright (C) 2003, 2004 g10 Code GmbH +# Copyright (C) 2003, 2004, 2014 g10 Code GmbH # # This file is part of libgpg-error. # @@ -14,8 +14,7 @@ # GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public -# License along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA +# License along with this program; if not, see . # We distribute the generated sources err-sources.h and err-codes.h, # because they are needed to build the po directory, and they don't @@ -41,20 +40,20 @@ m4data_DATA = gpg-error.m4 EXTRA_DIST = mkstrtable.awk err-sources.h.in err-codes.h.in \ mkerrnos.awk errnos.in README \ mkerrcodes.awk mkerrcodes1.awk mkerrcodes2.awk mkerrcodes.c \ - mkheader.awk gpg-error.h.in mkw32errmap.c w32-add.h w32ce-add.h \ + mkheader.c gpg-error.h.in mkw32errmap.c w32-add.h w32ce-add.h \ err-sources.h err-codes.h gpg-error-config.in gpg-error.m4 \ gpg-error.def.in versioninfo.rc.in BUILT_SOURCES = err-sources.h err-codes.h code-to-errno.h code-from-errno.h \ err-sources-sym.h err-codes-sym.h errnos-sym.h gpg-error.h \ - gpg-error.def extra-h.in mkw32errmap.map.c + gpg-error.def mkw32errmap.map.c tmp_files = _mkerrcodes.h _gpg-error.def.h mkw32errmap.tab.h mkw32errmap.map.c CLEANFILES = err-sources.h err-codes.h code-to-errno.h code-from-errno.h \ gpg-error.h mkerrcodes mkerrcodes.h gpg-error.def mkw32errmap.tab.h \ mkw32errmap.map.c err-sources-sym.h err-codes-sym.h errnos-sym.h \ - gpg-extra/errno.h extra-h.in $(tmp_files) + gpg-extra/errno.h mkheader $(tmp_files) if HAVE_W32_SYSTEM arch_sources = w32-gettext.c @@ -99,6 +98,15 @@ libgpg_error_la_LDFLAGS = -version-info \ @LIBGPG_ERROR_LT_CURRENT@:@LIBGPG_ERROR_LT_REVISION@:@LIBGPG_ERROR_LT_AGE@ \ $(no_undefined) $(export_symbols) +parts_of_gpg_error_h = \ + gpg-error.h.in \ + err-sources.h.in \ + err-codes.h.in \ + errnos.in \ + w32-add.h \ + w32ce-add.h + + libgpg_error_la_SOURCES = gpg-error.h gettext.h $(arch_sources) \ init.c init.h version.c \ strsource.c strerror.c code-to-errno.c code-from-errno.c @@ -187,32 +195,14 @@ errnos-sym.h: Makefile mkstrtable.awk errnos.in -v prefix=GPG_ERR_ -v namespace=errnos_ \ $(srcdir)/errnos.in >$@ -# We depend on versioninfo.rc because that is build by config.status -# and thus has up-to-date version numbers. -extra-h.in: Makefile w32-add.h w32ce-add.h versioninfo.rc - -rm extra-h.in - echo "/* The version string of this header. */" >>extra-h.in - echo "#define GPG_ERROR_VERSION \"$(PACKAGE_VERSION)\"" >>extra-h.in - echo >>extra-h.in - echo "/* The version number of this header. */" >>extra-h.in - echo "#define GPG_ERROR_VERSION_NUMBER $(VERSION_NUMBER)" >>extra-h.in - echo >>extra-h.in -if HAVE_W32_SYSTEM - cat $(srcdir)/w32-add.h >>extra-h.in -endif -if HAVE_W32CE_SYSTEM - cat $(srcdir)/w32ce-add.h >>extra-h.in -endif - echo EOF >>extra-h.in - -gpg-error.h: Makefile mkheader.awk err-sources.h.in err-codes.h.in \ - errnos.in extra-h.in gpg-error.h.in - $(AWK) -f $(srcdir)/mkheader.awk \ - $(srcdir)/err-sources.h.in \ - $(srcdir)/err-codes.h.in \ - $(srcdir)/errnos.in \ - extra-h.in \ - $(srcdir)/gpg-error.h.in > $@ +mkheader: mkheader.c Makefile + $(CC_FOR_BUILD) -g -O0 -I. -I$(srcdir) -o $@ $(srcdir)/mkheader.c + +# We also depend on versioninfo.rc because that is build by +# config.status and thus has up-to-date version numbers. +gpg-error.h: Makefile mkheader $(parts_of_gpg_error_h) versioninfo.rc + ./mkheader $(host_os) $(srcdir)/gpg-error.h.in \ + $(PACKAGE_VERSION) $(VERSION_NUMBER) >$@ install-data-local: diff --git a/src/errnos.in b/src/errnos.in index 0688047..018fb9a 100644 --- a/src/errnos.in +++ b/src/errnos.in @@ -1,5 +1,5 @@ -# errnos.h.in - List of system error values input file. -/* errnos.h - List of system error values. +# errnos.in - List of system error values input file. +/* errnos.in - List of system error values. Copyright (C) 2003, 2004 g10 Code GmbH This file is part of libgpg-error. @@ -8,12 +8,12 @@ modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. - + libgpg-error 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 libgpg-error; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA @@ -169,4 +169,4 @@ 137 EUSERS 138 EWOULDBLOCK 139 EXDEV -140 EXFULL \ No newline at end of file +140 EXFULL diff --git a/src/gpg-error.h.in b/src/gpg-error.h.in index 303fac0..a2fb044 100644 --- a/src/gpg-error.h.in +++ b/src/gpg-error.h.in @@ -1,5 +1,5 @@ -/* gpg-error.h - Public interface to libgpg-error. - Copyright (C) 2003, 2004, 2010, 2013 g10 Code GmbH +/* gpg-error.h - Public interface to libgpg-error. -*- c -*- + Copyright (C) 2003, 2004, 2010, 2013, 2014 g10 Code GmbH This file is part of libgpg-error. @@ -15,6 +15,8 @@ You should have received a copy of the GNU Lesser General Public License along with this program; if not, see . + + @configure_input@ */ @@ -77,7 +79,7 @@ extern "C" { entries. */ typedef enum { - at include err-sources.h.in + at include:err-sources@ /* This is one more than the largest allowed entry. */ GPG_ERR_SOURCE_DIM = 128 @@ -90,11 +92,11 @@ typedef enum entries. */ typedef enum { - at include err-codes.h.in + at include:err-codes@ /* The following error codes are used to map system errors. */ #define GPG_ERR_SYSTEM_ERROR (1 << 15) - at include errnos.in + at include:errnos@ /* This is one more than the largest allowed entry. */ GPG_ERR_CODE_DIM = 65536 @@ -248,7 +250,13 @@ void gpg_err_set_errno (int err); /* Return or check the version. */ const char *gpg_error_check_version (const char *req_version); - at include extra-h.in +/* The version string of this header. */ +#define GPG_ERROR_VERSION @version@ + +/* The version number of this header. */ +#define GPG_ERROR_VERSION_NUMBER @version-number@ + + at include:os-add@ /* Self-documenting convenience functions. */ diff --git a/src/mkheader.awk b/src/mkheader.awk deleted file mode 100644 index 0ff08f9..0000000 --- a/src/mkheader.awk +++ /dev/null @@ -1,218 +0,0 @@ -# mkheader.awk -# Copyright (C) 2003, 2004 g10 Code GmbH -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of -# the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. -# -# As a special exception, g10 Code GmbH gives unlimited permission to -# copy, distribute and modify the C source files that are the output -# of mkheader.awk. You need not follow the terms of the GNU General -# Public License when using or distributing such scripts, even though -# portions of the text of mkheader.awk appear in them. The GNU -# General Public License (GPL) does govern all other use of the material -# that constitutes the mkheader.awk program. -# -# Certain portions of the mkheader.awk source text are designed to be -# copied (in certain cases, depending on the input) into the output of -# mkheader.awk. We call these the "data" portions. The rest of the -# mkheader.awk source text consists of comments plus executable code -# that decides which of the data portions to output in any given case. -# We call these comments and executable code the "non-data" portions. -# mkheader.h never copies any of the non-data portions into its output. -# -# This special exception to the GPL applies to versions of mkheader.awk -# released by g10 Code GmbH. When you make and distribute a modified version -# of mkheader.awk, you may extend this special exception to the GPL to -# apply to your modified version as well, *unless* your modified version -# has the potential to copy into its output some of the text that was the -# non-data portion of the version that you started with. (In other words, -# unless your change moves or copies text from the non-data portions to the -# data portions.) If your modification has such potential, you must delete -# any notice of this special exception to the GPL from your modified version. - -# This script processes gpg-error.h.in in an awful way. -# Its input is, one after another, the content of the err-sources.h.in file, -# the err-codes.h.in file, the errnos.in file, and then gpg-error.h.in. -# There is nothing fancy about this. -# -# An alternative would be to use getline to get the content of the first three files, -# but then we need to pre-process gpg-error.h.in with configure to get -# at the full path of the files in @srcdir at . - -BEGIN { - FS = "[\t]+"; -# sources_nr holds the number of error sources. - sources_nr = 0; -# codes_nr holds the number of error codes. - codes_nr = 0; -# errnos_nr holds the number of system errors. - errnos_nr = 0; -# extra_nr holds the number of extra lines to be included. - extra_nr = 0 - -# These variables walk us through our input. - sources_header = 1; - sources_body = 0; - between_sources_and_codes = 0; - codes_body = 0; - between_codes_and_errnos = 0; - errnos_body = 0; - extra_body = 0; - gpg_error_h = 0; - - print "/* Output of mkheader.awk. DO NOT EDIT. -*- buffer-read-only: t -*- */"; - print ""; - -} - - -sources_header { - if ($1 ~ /^[0123456789]+$/) - { - sources_header = 0; - sources_body = 1; - } -} - -sources_body { - sub (/\#.+/, ""); - sub (/[ ]+$/, ""); # Strip trailing space and tab characters. - - if (/^$/) - next; - - if ($1 == "") - { - sources_body = 0; - between_sources_and_codes = 1; - } - else - { -# Remember the error source number and symbol of each error source. - sources_idx[sources_nr] = $1; - sources_sym[sources_nr] = $2; - sources_nr++; - } -} - -between_sources_and_codes { - if ($1 ~ /^[0123456789]+$/) - { - between_sources_and_codes = 0; - codes_body = 1; - } -} - -codes_body { - sub (/\#.+/, ""); - sub (/[ ]+$/, ""); # Strip trailing space and tab characters. - - if (/^$/) - next; - - if ($1 == "") - { - codes_body = 0; - between_codes_and_errnos = 1; - } - else - { -# Remember the error code number and symbol of each error source. - codes_idx[codes_nr] = $1; - codes_sym[codes_nr] = $2; - codes_nr++; - } -} - -between_codes_and_errnos { - if ($1 ~ /^[0-9]/) - { - between_codes_and_errnos = 0; - errnos_body = 1; - } -} - -errnos_body { - sub (/\#.+/, ""); - sub (/[ ]+$/, ""); # Strip trailing space and tab characters. - - if (/^$/) - next; - - if ($1 !~ /^[0-9]/) - { -# Note that this assumes that extra_body.in doesn't start with a digit. - errnos_body = 0; - extra_body = 1; - } - else - { - errnos_idx[errnos_nr] = "GPG_ERR_SYSTEM_ERROR | " $1; - errnos_sym[errnos_nr] = "GPG_ERR_" $2; - errnos_nr++; - } -} - -extra_body { - if (/^##/) - next - - if (/^EOF/) - { - extra_body = 0; - gpg_error_h = 1; - next; - } - else - { - extra_line[extra_nr] = $0; - extra_nr++; - } -} - -gpg_error_h { - if ($0 ~ /^@include err-sources/) - { - for (i = 0; i < sources_nr; i++) - { - print " " sources_sym[i] " = " sources_idx[i] ","; -# print "#define " sources_sym[i] " (" sources_idx[i] ")"; - } - } - else if ($0 ~ /^@include err-codes/) - { - for (i = 0; i < codes_nr; i++) - { - print " " codes_sym[i] " = " codes_idx[i] ","; -# print "#define " codes_sym[i] " (" codes_idx[i] ")"; - } - } - else if ($0 ~ /^@include errnos/) - { - for (i = 0; i < errnos_nr; i++) - { - print " " errnos_sym[i] " = " errnos_idx[i] ","; -# print "#define " errnos_sym[i] " (" errnos_idx[i] ")"; - } - } - else if ($0 ~ /^@include extra-h.in/) - { - for (i = 0; i < extra_nr; i++) - { - print extra_line[i]; - } - } - else - print; -} diff --git a/src/mkheader.c b/src/mkheader.c new file mode 100644 index 0000000..eea7914 --- /dev/null +++ b/src/mkheader.c @@ -0,0 +1,363 @@ +/* mkheader.c - Create a header file for libgpg-error + * Copyright (C) 2010 Free Software Foundation, Inc. + * Copyright (C) 2014 g10 Code GmbH + * + * This file is free software; as a special exception the author gives + * unlimited permission to copy and/or distribute it, with or without + * modifications, as long as this notice is preserved. + * + * This file is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY, to the extent permitted by law; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + */ + + +#include +#include +#include +#include + +#define PGM "mkheader" + +#define LINESIZE 1024 + +static const char *host_os; +static char *srcdir; +static const char *hdr_version; +static const char *hdr_version_number; + + +/* Write LINE to stdout. The function is allowed to modify LINE. */ +static void +write_str (char *line) +{ + if (fputs (line, stdout) == EOF) + { + fprintf (stderr, PGM ": error writing to stdout: %s\n", strerror (errno)); + exit (1); + } +} + +static void +write_line (char *line) +{ + if (puts (line) == EOF) + { + fprintf (stderr, PGM ": error writing to stdout: %s\n", strerror (errno)); + exit (1); + } +} + + +/* Write SOURCE or CODES line to stdout. The function is allowed to + modify LINE. Trailing white space is already removed. Passing + NULL resets the internal state. */ +static void +write_sources_or_codes (char *line) +{ + static int in_intro; + char *p1, *p2; + + if (!line) + { + in_intro = 1; + return; + } + + if (!*line) + return; + + if (in_intro) + { + if (!strchr ("0123456789", *line)) + return; + in_intro = 0; + } + + p1 = strtok (line, " \t"); + p2 = p1? strtok (NULL, " \t") : NULL; + + if (p1 && p2 && strchr ("0123456789", *p1) && *p2) + { + write_str (" "); + write_str (p2); + write_str (" = "); + write_str (p1); + write_str (",\n"); + } +} + + +/* Write system errnos to stdout. The function is allowed to + modify LINE. Trailing white space is already removed. Passing + NULL resets the internal state. */ +static void +write_errnos_in (char *line) +{ + static int state; + char *p1, *p2; + + if (!line) + { + state = 0; + return; + } + + if (!*line) + return; + + if (!state && strchr ("0123456789", *line)) + state = 1; + else if (state == 1 && !strchr ("0123456789", *line)) + state = 2; + + if (state != 1) + return; + + p1 = strtok (line, " \t"); + p2 = p1? strtok (NULL, " \t") : NULL; + + if (p1 && p2 && strchr ("0123456789", *p1) && *p2) + { + write_str (" GPG_ERR_"); + write_str (p2); + write_str (" = GPG_ERR_SYSTEM_ERROR | "); + write_str (p1); + write_str (",\n"); + } +} + + +/* Include the file NAME from the source directory. The included file + is not further expanded. It may have comments indicated by a + double hash mark at the begin of a line. OUTF is called for each + read line and passed a buffer with the content of line sans line + line endings. */ +static void +include_file (const char *fname, int lnr, const char *name, void (*outf)(char*)) +{ + FILE *fp; + char *incfname; + int inclnr; + char line[LINESIZE]; + + incfname = malloc (strlen (srcdir) + strlen (name) + 1); + if (!incfname) + { + fputs (PGM ": out of core\n", stderr); + exit (1); + } + strcpy (incfname, srcdir); + strcat (incfname, name); + + fp = fopen (incfname, "r"); + if (!fp) + { + fprintf (stderr, "%s:%d: error including `%s': %s\n", + fname, lnr, incfname, strerror (errno)); + exit (1); + } + + inclnr = 0; + while (fgets (line, LINESIZE, fp)) + { + size_t n = strlen (line); + + inclnr++; + if (!n || line[n-1] != '\n') + { + fprintf (stderr, + "%s:%d: trailing linefeed missing, line too long or " + "embedded nul character\n", incfname, inclnr); + fprintf (stderr,"%s:%d: note: file '%s' included from here\n", + fname, lnr, incfname); + exit (1); + } + line[--n] = 0; + while (line[n] == ' ' || line[n] == '\t' || line[n] == '\r') + { + line[n] = 0; + if (!n) + break; + n--; + } + + if (line[0] == '#' && line[1] == '#') + { + if (!strncmp (line+2, "EOF##", 5)) + break; /* Forced EOF. */ + } + else + outf (line); + } + if (ferror (fp)) + { + fprintf (stderr, "%s:%d: error reading `%s': %s\n", + fname, lnr, incfname, strerror (errno)); + exit (1); + } + fclose (fp); + free (incfname); +} + + +static int +write_special (const char *fname, int lnr, const char *tag) +{ + if (!strcmp (tag, "version")) + { + putchar ('\"'); + fputs (hdr_version, stdout); + putchar ('\"'); + putchar ('\n'); + } + else if (!strcmp (tag, "version-number")) + { + fputs (hdr_version_number, stdout); + putchar ('\n'); + } + else if (!strcmp (tag, "include:err-sources")) + { + write_sources_or_codes (NULL); + include_file (fname, lnr, "err-sources.h.in", write_sources_or_codes); + } + else if (!strcmp (tag, "include:err-codes")) + { + write_sources_or_codes (NULL); + include_file (fname, lnr, "err-codes.h.in", write_sources_or_codes); + } + else if (!strcmp (tag, "include:errnos")) + { + include_file (fname, lnr, "errnos.in", write_errnos_in); + } + else if (!strcmp (tag, "include:os-add")) + { + if (!strcmp (host_os, "mingw32")) + { + include_file (fname, lnr, "w32-add.h", write_line); + } + else if (!strcmp (host_os, "mingw32ce")) + { + include_file (fname, lnr, "w32-add.h", write_line); + include_file (fname, lnr, "w32ce-add.h", write_line); + } + } + else + return 0; /* Unknown tag. */ + + return 1; /* Tag processed. */ +} + + +int +main (int argc, char **argv) +{ + FILE *fp; + char line[LINESIZE]; + int lnr = 0; + const char *fname, *s; + char *p1, *p2; + + if (argc) + { + argc--; argv++; + } + + if (argc != 4) + { + fputs ("usage: " PGM " host_os template.h version version_number\n", + stderr); + return 1; + } + host_os = argv[0]; + fname = argv[1]; + hdr_version = argv[2]; + hdr_version_number = argv[3]; + + srcdir = malloc (strlen (fname) + 2 + 1); + if (!srcdir) + { + fputs (PGM ": out of core\n", stderr); + return 1; + } + strcpy (srcdir, fname); + p1 = strrchr (srcdir, '/'); + if (p1) + p1[1] = 0; + else + strcpy (srcdir, "./"); + + fp = fopen (fname, "r"); + if (!fp) + { + fprintf (stderr, "%s:%d: can't open file: %s", + fname, lnr, strerror (errno)); + return 1; + } + + while (fgets (line, LINESIZE, fp)) + { + size_t n = strlen (line); + + lnr++; + if (!n || line[n-1] != '\n') + { + fprintf (stderr, + "%s:%d: trailing linefeed missing, line too long or " + "embedded nul character\n", fname, lnr); + break; + } + line[--n] = 0; + + p1 = strchr (line, '@'); + p2 = p1? strchr (p1+1, '@') : NULL; + if (!p1 || !p2 || p2-p1 == 1) + { + puts (line); + continue; + } + *p1++ = 0; + *p2++ = 0; + fputs (line, stdout); + + if (!strcmp (p1, "configure_input")) + { + s = strrchr (fname, '/'); + printf ("Do not edit. Generated from %s by %s for %s.", + s? s+1 : fname, PGM, host_os); + fputs (p2, stdout); + putchar ('\n'); + } + else if (!write_special (fname, lnr, p1)) + { + putchar ('@'); + fputs (p1, stdout); + putchar ('@'); + fputs (p2, stdout); + putchar ('\n'); + } + } + + if (ferror (fp)) + { + fprintf (stderr, "%s:%d: error reading file: %s\n", + fname, lnr, strerror (errno)); + return 1; + } + + fputs ("/*\n" + "Loc" "al Variables:\n" + "buffer-read-only: t\n" + "End:\n" + "*/\n", stdout); + + if (ferror (stdout)) + { + fprintf (stderr, PGM ": error writing to stdout: %s\n", strerror (errno)); + return 1; + } + + fclose (fp); + + return 0; +} ----------------------------------------------------------------------- Summary of changes: NEWS | 13 +- configure.ac | 18 ++ m4/lock.m4 | 301 +++----------------------- m4/threadlib.m4 | 341 +++++++++++++++++++++++++++++ src/Makefile.am | 82 +++---- src/err-codes.h.in | 6 +- src/errnos.in | 10 +- src/gen-posix-lock-obj.c | 95 +++++++++ src/gen-w32-lock-obj.c | 55 +++++ src/gpg-error.def.in | 6 + src/gpg-error.h.in | 55 ++++- src/lock.h | 24 +++ src/mkheader.awk | 218 ------------------- src/mkheader.c | 377 +++++++++++++++++++++++++++++++++ src/{strsource.c => posix-lock-obj.h} | 39 ++-- src/posix-lock.c | 213 +++++++++++++++++++ src/posix-thread.c | 63 ++++++ src/thread.h | 24 +++ src/version.c | 4 +- src/w32-lock-obj-pub.in | 44 ++++ src/{strsource.c => w32-lock-obj.h} | 45 ++-- src/w32-lock.c | 119 +++++++++++ src/{strsource.c => w32-thread.c} | 39 ++-- tests/Makefile.am | 9 +- tests/t-common.h | 99 +++++++++ tests/t-lock.c | 318 +++++++++++++++++++++++++++ 26 files changed, 2008 insertions(+), 609 deletions(-) create mode 100644 m4/threadlib.m4 create mode 100644 src/gen-posix-lock-obj.c create mode 100644 src/gen-w32-lock-obj.c create mode 100644 src/lock.h delete mode 100644 src/mkheader.awk create mode 100644 src/mkheader.c copy src/{strsource.c => posix-lock-obj.h} (50%) create mode 100644 src/posix-lock.c create mode 100644 src/posix-thread.c create mode 100644 src/thread.h create mode 100644 src/w32-lock-obj-pub.in copy src/{strsource.c => w32-lock-obj.h} (50%) create mode 100644 src/w32-lock.c copy src/{strsource.c => w32-thread.c} (55%) create mode 100644 tests/t-common.h create mode 100644 tests/t-lock.c hooks/post-receive -- Error codes used by GnuPG et al. http://git.gnupg.org From cvs at cvs.gnupg.org Thu Jan 16 15:41:19 2014 From: cvs at cvs.gnupg.org (by Werner Koch) Date: Thu, 16 Jan 2014 15:41:19 +0100 Subject: [git] GPG-ERROR - branch, master, updated. libgpg-error-1.12-12-g4f9b13e Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Error codes used by GnuPG et al.". The branch, master has been updated via 4f9b13e99bdfed886dadfd1b70a69af3747ebc98 (commit) from ff937c39febe63d52c55590d8e3bd3a460f26651 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 4f9b13e99bdfed886dadfd1b70a69af3747ebc98 Author: Werner Koch Date: Thu Jan 9 19:14:09 2014 +0100 Fix linking for last change on non-ELF platforms. * src/Makefile.am (libgpg_error_la_LIBADD): Add LIBTHREAD. -- If configure told us to link with -lpthread we need to pass that library to the libgpg-error.la build rule. Which is the right thing to do. Without that we may run into strange errors; for example on AIX pthread_mutex_lock is silently not resolved and thus any use of gpgrt_lock_lock will immediately lead to segv. Signed-off-by: Werner Koch diff --git a/src/Makefile.am b/src/Makefile.am index 51b2ea9..9ced1e5 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -128,7 +128,7 @@ libgpg_error_la_SOURCES = gpg-error.h gettext.h $(arch_sources) \ # without the extra_cppflags because they may include am -idirafter # which is not supported by the RC compiler. libgpg_error_la_CPPFLAGS = -DLOCALEDIR=\"$(localedir)\" $(extra_cppflags) -libgpg_error_la_LIBADD = $(gpg_error_res) $(intllibs) +libgpg_error_la_LIBADD = $(gpg_error_res) $(intllibs) $(LIBTHREAD) gpg_error_SOURCES = strsource-sym.c strerror-sym.c gpg-error.c gpg_error_CPPFLAGS = -DLOCALEDIR=\"$(localedir)\" $(extra_cppflags) ----------------------------------------------------------------------- Summary of changes: src/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- Error codes used by GnuPG et al. http://git.gnupg.org From cvs at cvs.gnupg.org Thu Jan 16 16:17:23 2014 From: cvs at cvs.gnupg.org (by Milan Broz) Date: Thu, 16 Jan 2014 16:17:23 +0100 Subject: [git] GCRYPT - branch, LIBGCRYPT-1-6-BRANCH, updated. libgcrypt-1.6.0-10-gead3a09 Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The GNU crypto library". The branch, LIBGCRYPT-1-6-BRANCH has been updated via ead3a097a9ee5908e562e6ec683707c38191acf3 (commit) from 0f75a2a939cf57997a44868826ef3390f7a5c913 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit ead3a097a9ee5908e562e6ec683707c38191acf3 Author: Milan Broz Date: Mon Jan 13 21:30:42 2014 +0100 PBKDF2: Use gcry_md_reset to speed up calculation. * cipher/kdf.c (_gcry_kdf_pkdf2): Use gcry_md_reset to speed up calculation. -- Current PBKDF2 implementation uses gcry_md_set_key in every iteration which is extremely slow (even in comparison with other implementations). Use gcry_md_reset instead and set key only once. With this test program: char input[32000], salt[8], key[16]; gcry_kdf_derive(input, sizeof(input), GCRY_KDF_PBKDF2, gcry_md_map_name("sha1"), salt, sizeof(salt), 100000, sizeof(key), key); running time without patch: real 0m11.165s user 0m11.136s sys 0m0.000s and with patch applied real 0m0.230s user 0m0.184s sys 0m0.024s (The problem was found when cryptsetup started to use gcrypt internal PBKDF2 and for very long keyfiles unlocking time increased drastically. See https://bugzilla.redhat.com/show_bug.cgi?id=1051733) Signed-off-by: Milan Broz (cherry picked from commit 04cda6b7cc16f3f52c12d9d3e46c56701003496e) diff --git a/cipher/kdf.c b/cipher/kdf.c index 503f068..af0dc48 100644 --- a/cipher/kdf.c +++ b/cipher/kdf.c @@ -175,19 +175,21 @@ _gcry_kdf_pkdf2 (const void *passphrase, size_t passphraselen, return ec; } + ec = _gcry_md_setkey (md, passphrase, passphraselen); + if (ec) + { + _gcry_md_close (md); + xfree (sbuf); + return ec; + } + /* Step 3 and 4. */ memcpy (sbuf, salt, saltlen); for (lidx = 1; lidx <= l; lidx++) { for (iter = 0; iter < iterations; iter++) { - ec = _gcry_md_setkey (md, passphrase, passphraselen); - if (ec) - { - _gcry_md_close (md); - xfree (sbuf); - return ec; - } + _gcry_md_reset (md); if (!iter) /* Compute U_1: */ { sbuf[saltlen] = (lidx >> 24); ----------------------------------------------------------------------- Summary of changes: cipher/kdf.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) hooks/post-receive -- The GNU crypto library http://git.gnupg.org From cvs at cvs.gnupg.org Thu Jan 16 17:25:19 2014 From: cvs at cvs.gnupg.org (by Werner Koch) Date: Thu, 16 Jan 2014 17:25:19 +0100 Subject: [git] GCRYPT - branch, master, updated. libgcrypt-1.6.0-35-gcfc151b Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The GNU crypto library". The branch, master has been updated via cfc151ba637200e4fc05d9481a8df2071b2f9a47 (commit) from 49edeebb43174865cf4fa2c170a42a8e4274c4f0 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit cfc151ba637200e4fc05d9481a8df2071b2f9a47 Author: Werner Koch Date: Thu Jan 9 19:14:09 2014 +0100 Replace ath based mutexes by gpgrt based locks. * configure.ac (NEED_GPG_ERROR_VERSION): Require 1.13. (gl_LOCK): Remove. * src/ath.c, src/ath.h: Remove. Remove from all files. Replace all mutexes by gpgrt based statically initialized locks. * src/global.c (global_init): Remove ath_init. (_gcry_vcontrol): Make ath install a dummy function. (print_config): Remove threads info line. * doc/gcrypt.texi: Simplify the multi-thread related documentation. -- The current code does only work on ELF systems with weak symbol support. In particular no locks were used under Windows. With the new gpgrt_lock functions from the soon to be released libgpg-error 1.13 we have a better portable scheme which also allows for static initialized mutexes. Signed-off-by: Werner Koch diff --git a/cipher/cipher-aeswrap.c b/cipher/cipher-aeswrap.c index 50ac107..698742d 100644 --- a/cipher/cipher-aeswrap.c +++ b/cipher/cipher-aeswrap.c @@ -25,7 +25,6 @@ #include "g10lib.h" #include "cipher.h" -#include "ath.h" #include "bufhelp.h" #include "./cipher-internal.h" diff --git a/cipher/cipher-cbc.c b/cipher/cipher-cbc.c index 4b929da..67814b7 100644 --- a/cipher/cipher-cbc.c +++ b/cipher/cipher-cbc.c @@ -26,7 +26,6 @@ #include "g10lib.h" #include "cipher.h" -#include "ath.h" #include "./cipher-internal.h" #include "bufhelp.h" diff --git a/cipher/cipher-ccm.c b/cipher/cipher-ccm.c index 9d0bf0a..3d5f220 100644 --- a/cipher/cipher-ccm.c +++ b/cipher/cipher-ccm.c @@ -25,7 +25,6 @@ #include "g10lib.h" #include "cipher.h" -#include "ath.h" #include "bufhelp.h" #include "./cipher-internal.h" diff --git a/cipher/cipher-cfb.c b/cipher/cipher-cfb.c index 8539f54..f289ed3 100644 --- a/cipher/cipher-cfb.c +++ b/cipher/cipher-cfb.c @@ -26,7 +26,6 @@ #include "g10lib.h" #include "cipher.h" -#include "ath.h" #include "bufhelp.h" #include "./cipher-internal.h" diff --git a/cipher/cipher-ctr.c b/cipher/cipher-ctr.c index 1e7133c..4bbfaae 100644 --- a/cipher/cipher-ctr.c +++ b/cipher/cipher-ctr.c @@ -26,7 +26,6 @@ #include "g10lib.h" #include "cipher.h" -#include "ath.h" #include "bufhelp.h" #include "./cipher-internal.h" diff --git a/cipher/cipher-gcm.c b/cipher/cipher-gcm.c index cdd35ad..0534761 100644 --- a/cipher/cipher-gcm.c +++ b/cipher/cipher-gcm.c @@ -26,7 +26,6 @@ #include "g10lib.h" #include "cipher.h" -#include "ath.h" #include "bufhelp.h" #include "./cipher-internal.h" diff --git a/cipher/cipher-ofb.c b/cipher/cipher-ofb.c index 3842774..7db7658 100644 --- a/cipher/cipher-ofb.c +++ b/cipher/cipher-ofb.c @@ -26,7 +26,6 @@ #include "g10lib.h" #include "cipher.h" -#include "ath.h" #include "bufhelp.h" #include "./cipher-internal.h" diff --git a/cipher/cipher.c b/cipher/cipher.c index 8c5a0b4..baa4720 100644 --- a/cipher/cipher.c +++ b/cipher/cipher.c @@ -27,7 +27,6 @@ #include "g10lib.h" #include "cipher.h" -#include "ath.h" #include "./cipher-internal.h" diff --git a/cipher/kdf.c b/cipher/kdf.c index af0dc48..ad5c46e 100644 --- a/cipher/kdf.c +++ b/cipher/kdf.c @@ -26,7 +26,6 @@ #include "g10lib.h" #include "cipher.h" -#include "ath.h" #include "kdf-internal.h" diff --git a/cipher/md.c b/cipher/md.c index 1b59765..f4fb129 100644 --- a/cipher/md.c +++ b/cipher/md.c @@ -27,7 +27,6 @@ #include "g10lib.h" #include "cipher.h" -#include "ath.h" #include "rmd.h" diff --git a/cipher/primegen.c b/cipher/primegen.c index 645b0f8..9f6ec70 100644 --- a/cipher/primegen.c +++ b/cipher/primegen.c @@ -29,7 +29,6 @@ #include "g10lib.h" #include "mpi.h" #include "cipher.h" -#include "ath.h" static gcry_mpi_t gen_prime (unsigned int nbits, int secret, int randomlevel, int (*extra_check)(void *, gcry_mpi_t), @@ -141,18 +140,15 @@ struct primepool_s }; struct primepool_s *primepool; /* Mutex used to protect access to the primepool. */ -static ath_mutex_t primepool_lock; +GPGRT_LOCK_DEFINE (primepool_lock); gcry_err_code_t _gcry_primegen_init (void) { - gcry_err_code_t ec; - - ec = ath_mutex_init (&primepool_lock); - if (ec) - return gpg_err_code_from_errno (ec); - return ec; + /* This function was formerly used to initialize the primepool + Mutex. This has been replace by a static initialization. */ + return 0; } @@ -446,12 +442,11 @@ prime_generate_internal (int need_q_factor, goto leave; } - if (ath_mutex_lock (&primepool_lock)) - { - err = GPG_ERR_INTERNAL; - goto leave; - } + err = gpgrt_lock_lock (&primepool_lock); + if (err) + goto leave; is_locked = 1; + for (i = 0; i < n; i++) { perms[i] = 1; @@ -470,11 +465,9 @@ prime_generate_internal (int need_q_factor, pool[i] = get_pool_prime (fbits, poolrandomlevel); if (!pool[i]) { - if (ath_mutex_unlock (&primepool_lock)) - { - err = GPG_ERR_INTERNAL; - goto leave; - } + err = gpgrt_lock_unlock (&primepool_lock); + if (err) + goto leave; is_locked = 0; } } @@ -483,23 +476,20 @@ prime_generate_internal (int need_q_factor, pool_in_use[i] = i; factors[i] = pool[i]; } - if (is_locked && ath_mutex_unlock (&primepool_lock)) - { - err = GPG_ERR_INTERNAL; - goto leave; - } + + if (is_locked && (err = gpgrt_lock_unlock (&primepool_lock))) + goto leave; is_locked = 0; } else { /* Get next permutation. */ m_out_of_n ( (char*)perms, n, m); - if (ath_mutex_lock (&primepool_lock)) - { - err = GPG_ERR_INTERNAL; - goto leave; - } + + if ((err = gpgrt_lock_lock (&primepool_lock))) + goto leave; is_locked = 1; + for (i = j = 0; (i < m) && (j < n); i++) if (perms[i]) { @@ -509,11 +499,8 @@ prime_generate_internal (int need_q_factor, pool[i] = get_pool_prime (fbits, poolrandomlevel); if (!pool[i]) { - if (ath_mutex_unlock (&primepool_lock)) - { - err = GPG_ERR_INTERNAL; - goto leave; - } + if ((err = gpgrt_lock_unlock (&primepool_lock))) + goto leave; is_locked = 0; } } @@ -522,12 +509,11 @@ prime_generate_internal (int need_q_factor, pool_in_use[j] = i; factors[j++] = pool[i]; } - if (is_locked && ath_mutex_unlock (&primepool_lock)) - { - err = GPG_ERR_INTERNAL; - goto leave; - } + + if (is_locked && (err = gpgrt_lock_unlock (&primepool_lock))) + goto leave; is_locked = 0; + if (i == n) { /* Ran out of permutations: Allocate new primes. */ @@ -686,7 +672,7 @@ prime_generate_internal (int need_q_factor, leave: if (pool) { - is_locked = !ath_mutex_lock (&primepool_lock); + is_locked = !gpgrt_lock_lock (&primepool_lock); for(i = 0; i < m; i++) { if (pool[i]) @@ -703,8 +689,8 @@ prime_generate_internal (int need_q_factor, mpi_free (pool[i]); } } - if (is_locked && ath_mutex_unlock (&primepool_lock)) - err = GPG_ERR_INTERNAL; + if (is_locked) + err = gpgrt_lock_unlock (&primepool_lock); is_locked = 0; xfree (pool); } diff --git a/cipher/pubkey.c b/cipher/pubkey.c index d130388..9aeaced 100644 --- a/cipher/pubkey.c +++ b/cipher/pubkey.c @@ -28,7 +28,6 @@ #include "g10lib.h" #include "mpi.h" #include "cipher.h" -#include "ath.h" #include "context.h" #include "pubkey-internal.h" diff --git a/compat/compat.c b/compat/compat.c index 5678067..39d6498 100644 --- a/compat/compat.c +++ b/compat/compat.c @@ -31,8 +31,8 @@ _gcry_compat_identification (void) "\n\n" "This is Libgcrypt " PACKAGE_VERSION " - The GNU Crypto Library\n" "Copyright (C) 2000-2012 Free Software Foundation, Inc.\n" - "Copyright (C) 2012-2013 g10 Code GmbH\n" - "Copyright (C) 2013 Jussi Kivilinna\n" + "Copyright (C) 2012-2014 g10 Code GmbH\n" + "Copyright (C) 2013-2014 Jussi Kivilinna\n" "\n" "(" BUILD_REVISION " " BUILD_TIMESTAMP ")\n" "\n\n"; diff --git a/configure.ac b/configure.ac index 7d37f94..6272871 100644 --- a/configure.ac +++ b/configure.ac @@ -67,7 +67,7 @@ LIBGCRYPT_CONFIG_API_VERSION=1 # If you change the required gpg-error version, please remove # unnecessary error code defines in src/gcrypt-int.h. -NEED_GPG_ERROR_VERSION=1.11 +NEED_GPG_ERROR_VERSION=1.13 PACKAGE=$PACKAGE_NAME VERSION=$PACKAGE_VERSION @@ -733,11 +733,6 @@ if test "$have_pthread" = yes; then AC_DEFINE(HAVE_PTHREAD, ,[Define if we have pthread.]) fi -# -# See which thread system we have -# FIXME: Thus duplicates the above check. -# -gl_LOCK # Solaris needs -lsocket and -lnsl. Unisys system includes # gethostbyname in libsocket but needs libnsl for socket. diff --git a/doc/gcrypt.texi b/doc/gcrypt.texi index 25d8227..7712b80 100644 --- a/doc/gcrypt.texi +++ b/doc/gcrypt.texi @@ -188,8 +188,8 @@ the same handle, he has to take care of the serialization of such functions himself. If not described otherwise, every function is thread-safe. -Libgcrypt depends on the library `libgpg-error', which -contains common error handling related code for GnuPG components. +Libgcrypt depends on the library `libgpg-error', which contains some +common code used by other GnuPG components. @c ********************************************************** @c ******************* Preparation ************************ @@ -343,8 +343,7 @@ after program startup. The function @code{gcry_check_version} initializes some subsystems used by Libgcrypt and must be invoked before any other function in the -library, with the exception of the @code{GCRYCTL_SET_THREAD_CBS} command -(called via the @code{gcry_control} function). +library. @xref{Multi-Threading}. Furthermore, this function returns the version number of the library. @@ -450,51 +449,16 @@ thread-safe if you adhere to the following requirements: @itemize @bullet @item -If your application is multi-threaded, you must set the thread support -callbacks with the @code{GCRYCTL_SET_THREAD_CBS} command - at strong{before} any other function in the library. - -This is easy enough if you are indeed writing an application using -Libgcrypt. It is rather problematic if you are writing a library -instead. Here are some tips what to do if you are writing a library: - -If your library requires a certain thread package, just initialize -Libgcrypt to use this thread package. If your library supports multiple -thread packages, but needs to be configured, you will have to -implement a way to determine which thread package the application -wants to use with your library anyway. Then configure Libgcrypt to use -this thread package. - -If your library is fully reentrant without any special support by a -thread package, then you are lucky indeed. Unfortunately, this does -not relieve you from doing either of the two above, or use a third -option. The third option is to let the application initialize Libgcrypt -for you. Then you are not using Libgcrypt transparently, though. - -As if this was not difficult enough, a conflict may arise if two -libraries try to initialize Libgcrypt independently of each others, and -both such libraries are then linked into the same application. To -make it a bit simpler for you, this will probably work, but only if -both libraries have the same requirement for the thread package. This -is currently only supported for the non-threaded case, GNU Pth and -pthread. - If you use pthread and your applications forks and does not directly call exec (even calling stdio functions), all kind of problems may occur. Future versions of Libgcrypt will try to cleanup using pthread_atfork but even that may lead to problems. This is a common problem with almost all applications using pthread and fork. -Note that future versions of Libgcrypt will drop this flexible thread -support and instead only support the platforms standard thread -implementation. - @item The function @code{gcry_check_version} must be called before any other -function in the library, except the @code{GCRYCTL_SET_THREAD_CBS} -command (called via the @code{gcry_control} function), because it -initializes the thread support subsystem in Libgcrypt. To +function in the library. To achieve this in multi-threaded programs, you must synchronize the memory with respect to other threads that also want to use Libgcrypt. For this, it is sufficient to call @@ -515,52 +479,6 @@ Just like the function @code{gpg_strerror}, the function @end itemize -Libgcrypt contains convenient macros, which define the -necessary thread callbacks for PThread and for GNU Pth: - - at table @code - at item GCRY_THREAD_OPTION_PTH_IMPL - -This macro defines the following (static) symbols: - at code{gcry_pth_init}, @code{gcry_pth_mutex_init}, - at code{gcry_pth_mutex_destroy}, @code{gcry_pth_mutex_lock}, - at code{gcry_pth_mutex_unlock}, @code{gcry_pth_read}, - at code{gcry_pth_write}, @code{gcry_pth_select}, - at code{gcry_pth_waitpid}, @code{gcry_pth_accept}, - at code{gcry_pth_connect}, @code{gcry_threads_pth}. - -After including this macro, @code{gcry_control()} shall be used with a -command of @code{GCRYCTL_SET_THREAD_CBS} in order to register the -thread callback structure named ``gcry_threads_pth''. Example: - - at smallexample - ret = gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pth); - at end smallexample - - - at item GCRY_THREAD_OPTION_PTHREAD_IMPL - -This macro defines the following (static) symbols: - at code{gcry_pthread_mutex_init}, @code{gcry_pthread_mutex_destroy}, - at code{gcry_pthread_mutex_lock}, @code{gcry_pthread_mutex_unlock}, - at code{gcry_threads_pthread}. - -After including this macro, @code{gcry_control()} shall be used with a -command of @code{GCRYCTL_SET_THREAD_CBS} in order to register the -thread callback structure named ``gcry_threads_pthread''. Example: - - at smallexample - ret = gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread); - at end smallexample - - - at end table - -Note that these macros need to be terminated with a semicolon. Keep -in mind that these are convenient macros for C programmers; C++ -programmers might have to wrap these macros in an ``extern C'' body. - - @node Enabling FIPS mode @section How to enable the FIPS mode @cindex FIPS mode @@ -863,8 +781,7 @@ This command returns true if the command@* GCRYCTL_INITIALIZATION_FINISHED has already been run. @item GCRYCTL_SET_THREAD_CBS; Arguments: struct ath_ops *ath_ops -This command registers a thread-callback structure. - at xref{Multi-Threading}. +This command is obsolete since version 1.6. @item GCRYCTL_FAST_POLL; Arguments: none Run a fast random poll. @@ -2762,7 +2679,7 @@ operations. @var{cmd} controls what is to be done. The return value is Disable the algorithm given as an algorithm id in @var{buffer}. @var{buffer} must point to an @code{int} variable with the algorithm id and @var{buflen} must have the value @code{sizeof (int)}. This -fucntion is not thread safe and should thus be used before any other +function is not thread safe and should thus be used before any other threads are started. @end table diff --git a/random/random-csprng.c b/random/random-csprng.c index 87235d8..429c84f 100644 --- a/random/random-csprng.c +++ b/random/random-csprng.c @@ -60,7 +60,6 @@ #include "random.h" #include "rand-internal.h" #include "cipher.h" /* Required for the rmd160_hash_buffer() prototype. */ -#include "ath.h" #ifndef RAND_MAX /* For SunOS. */ #define RAND_MAX 32767 @@ -181,7 +180,7 @@ static int quick_test; static int faked_rng; /* This is the lock we use to protect all pool operations. */ -static ath_mutex_t pool_lock; +GPGRT_LOCK_DEFINE (pool_lock); /* This is a helper for assert calls. These calls are used to assert that functions are called in a locked state. It is not meant to be @@ -259,14 +258,10 @@ static void initialize_basics(void) { static int initialized; - int err; if (!initialized) { initialized = 1; - err = ath_mutex_init (&pool_lock); - if (err) - log_fatal ("failed to create the pool lock: %s\n", strerror (err) ); #ifdef USE_RANDOM_DAEMON _gcry_daemon_initialize_basics (); @@ -286,9 +281,9 @@ lock_pool (void) { int err; - err = ath_mutex_lock (&pool_lock); + err = gpgrt_lock_lock (&pool_lock); if (err) - log_fatal ("failed to acquire the pool lock: %s\n", strerror (err)); + log_fatal ("failed to acquire the pool lock: %s\n", gpg_strerror (err)); pool_is_locked = 1; } @@ -299,9 +294,9 @@ unlock_pool (void) int err; pool_is_locked = 0; - err = ath_mutex_unlock (&pool_lock); + err = gpgrt_lock_unlock (&pool_lock); if (err) - log_fatal ("failed to release the pool lock: %s\n", strerror (err)); + log_fatal ("failed to release the pool lock: %s\n", gpg_strerror (err)); } diff --git a/random/random-daemon.c b/random/random-daemon.c index 98a0153..8ea4df2 100644 --- a/random/random-daemon.c +++ b/random/random-daemon.c @@ -28,8 +28,6 @@ sensitive data. */ -#error This dameon needs to be fixed due to the ath changes - #include #include #include @@ -42,7 +40,6 @@ #include "g10lib.h" #include "random.h" -#include "ath.h" @@ -51,7 +48,7 @@ #define RANDOM_DAEMON_SOCKET "/var/run/libgcrypt/S.gcryptrnd" /* The lock serializing access to the daemon. */ -static ath_mutex_t daemon_lock = ATH_MUTEX_INITIALIZER; +GPGRT_LOCK_DEFINE (daemon_lock); /* The socket connected to the daemon. */ static int daemon_socket = -1; @@ -129,16 +126,7 @@ connect_to_socket (const char *socketname, int *sock) void _gcry_daemon_initialize_basics (void) { - static int initialized; - int err; - - if (!initialized) - { - initialized = 1; - err = ath_mutex_init (&daemon_lock); - if (err) - log_fatal ("failed to create the daemon lock: %s\n", strerror (err) ); - } + /* Not anymore required. */ } @@ -213,7 +201,7 @@ call_daemon (const char *socketname, if (!req_nbytes) return 0; - ath_mutex_lock (&daemon_lock); + gpgrt_lock_lock (&daemon_lock); /* Open the socket if that has not been done. */ if (!initialized) @@ -225,7 +213,7 @@ call_daemon (const char *socketname, { daemon_socket = -1; log_info ("not using random daemon\n"); - ath_mutex_unlock (&daemon_lock); + gpgrt_lock_unlock (&daemon_lock); return err; } } @@ -233,7 +221,7 @@ call_daemon (const char *socketname, /* Check that we have a valid socket descriptor. */ if ( daemon_socket == -1 ) { - ath_mutex_unlock (&daemon_lock); + gpgrt_lock_unlock (&daemon_lock); return gcry_error (GPG_ERR_INTERNAL); } @@ -325,7 +313,7 @@ call_daemon (const char *socketname, } while (req_nbytes); - ath_mutex_unlock (&daemon_lock); + gpgrt_lock_unlock (&daemon_lock); return err; } diff --git a/random/random-fips.c b/random/random-fips.c index d00825e..0a76362 100644 --- a/random/random-fips.c +++ b/random/random-fips.c @@ -66,13 +66,12 @@ #include "g10lib.h" #include "random.h" #include "rand-internal.h" -#include "ath.h" /* This is the lock we use to serialize access to this RNG. The extra integer variable is only used to check the locking state; that is, it is not meant to be thread-safe but merely as a failsafe feature to assert proper locking. */ -static ath_mutex_t fips_rng_lock; +GPGRT_LOCK_DEFINE (fips_rng_lock); static int fips_rng_is_locked; @@ -190,15 +189,11 @@ static void basic_initialization (void) { static int initialized; - int my_errno; if (initialized) return; initialized = 1; - my_errno = ath_mutex_init (&fips_rng_lock); - if (my_errno) - log_fatal ("failed to create the RNG lock: %s\n", strerror (my_errno)); fips_rng_is_locked = 0; /* Make sure that we are still using the values we have @@ -214,11 +209,11 @@ basic_initialization (void) static void lock_rng (void) { - int my_errno; + gpg_err_code_t rc; - my_errno = ath_mutex_lock (&fips_rng_lock); - if (my_errno) - log_fatal ("failed to acquire the RNG lock: %s\n", strerror (my_errno)); + rc = gpgrt_lock_lock (&fips_rng_lock); + if (rc) + log_fatal ("failed to acquire the RNG lock: %s\n", gpg_strerror (rc)); fips_rng_is_locked = 1; } @@ -227,12 +222,12 @@ lock_rng (void) static void unlock_rng (void) { - int my_errno; + gpg_err_code_t rc; fips_rng_is_locked = 0; - my_errno = ath_mutex_unlock (&fips_rng_lock); - if (my_errno) - log_fatal ("failed to release the RNG lock: %s\n", strerror (my_errno)); + rc = gpgrt_lock_unlock (&fips_rng_lock); + if (rc) + log_fatal ("failed to release the RNG lock: %s\n", gpg_strerror (rc)); } static void diff --git a/random/random-system.c b/random/random-system.c index 3962ab8..8b79511 100644 --- a/random/random-system.c +++ b/random/random-system.c @@ -35,13 +35,12 @@ #include "g10lib.h" #include "random.h" #include "rand-internal.h" -#include "ath.h" /* This is the lock we use to serialize access to this RNG. The extra integer variable is only used to check the locking state; that is, it is not meant to be thread-safe but merely as a failsafe feature to assert proper locking. */ -static ath_mutex_t system_rng_lock; +GPGRT_LOCK_DEFINE (system_rng_lock); static int system_rng_is_locked; @@ -58,16 +57,11 @@ static void basic_initialization (void) { static int initialized; - int my_errno; if (initialized) return; initialized = 1; - my_errno = ath_mutex_init (&system_rng_lock); - if (my_errno) - log_fatal ("failed to create the System RNG lock: %s\n", - strerror (my_errno)); system_rng_is_locked = 0; /* Make sure that we are still using the values we traditionally @@ -83,12 +77,12 @@ basic_initialization (void) static void lock_rng (void) { - int my_errno; + gpg_err_code_t rc; - my_errno = ath_mutex_lock (&system_rng_lock); - if (my_errno) + rc = gpgrt_lock_lock (&system_rng_lock); + if (rc) log_fatal ("failed to acquire the System RNG lock: %s\n", - strerror (my_errno)); + gpg_strerror (rc)); system_rng_is_locked = 1; } @@ -97,13 +91,13 @@ lock_rng (void) static void unlock_rng (void) { - int my_errno; + gpg_err_code_t rc; system_rng_is_locked = 0; - my_errno = ath_mutex_unlock (&system_rng_lock); - if (my_errno) + rc = gpgrt_lock_unlock (&system_rng_lock); + if (rc) log_fatal ("failed to release the System RNG lock: %s\n", - strerror (my_errno)); + gpg_strerror (rc)); } diff --git a/random/random.c b/random/random.c index ff9d6d2..41d4cb3 100644 --- a/random/random.c +++ b/random/random.c @@ -34,7 +34,6 @@ #include "random.h" #include "rand-internal.h" #include "cipher.h" /* For _gcry_sha1_hash_buffer(). */ -#include "ath.h" /* If not NULL a progress function called from certain places and the @@ -54,7 +53,7 @@ static struct /* This is the lock we use to protect the buffer used by the nonce generation. */ -static ath_mutex_t nonce_buffer_lock; +GPGRT_LOCK_DEFINE (nonce_buffer_lock); @@ -140,18 +139,6 @@ _gcry_set_preferred_rng_type (int type) void _gcry_random_initialize (int full) { - static int nonce_initialized; - int err; - - if (!nonce_initialized) - { - nonce_initialized = 1; - err = ath_mutex_init (&nonce_buffer_lock); - if (err) - log_fatal ("failed to create the nonce buffer lock: %s\n", - strerror (err) ); - } - if (fips_mode ()) _gcry_rngfips_initialize (full); else if (rng_types.standard) @@ -450,10 +437,10 @@ _gcry_create_nonce (void *buffer, size_t length) _gcry_random_initialize (1); /* Acquire the nonce buffer lock. */ - err = ath_mutex_lock (&nonce_buffer_lock); + err = gpgrt_lock_lock (&nonce_buffer_lock); if (err) log_fatal ("failed to acquire the nonce buffer lock: %s\n", - strerror (err)); + gpg_strerror (err)); apid = getpid (); /* The first time initialize our buffer. */ @@ -501,10 +488,10 @@ _gcry_create_nonce (void *buffer, size_t length) } /* Release the nonce buffer lock. */ - err = ath_mutex_unlock (&nonce_buffer_lock); + err = gpgrt_lock_unlock (&nonce_buffer_lock); if (err) log_fatal ("failed to release the nonce buffer lock: %s\n", - strerror (err)); + gpg_strerror (err)); } diff --git a/src/Makefile.am b/src/Makefile.am index c020239..b764852 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -61,8 +61,7 @@ libgcrypt_la_SOURCES = \ stdmem.c stdmem.h secmem.c secmem.h \ mpi.h missing-string.c fips.c \ hmac256.c hmac256.h context.c context.h \ - ec-context.h \ - ath.h ath.c + ec-context.h EXTRA_libgcrypt_la_SOURCES = hwf-x86.c hwf-arm.c gcrypt_hwf_modules = @GCRYPT_HWF_MODULES@ diff --git a/src/ath.c b/src/ath.c deleted file mode 100644 index 7a7035d..0000000 --- a/src/ath.c +++ /dev/null @@ -1,333 +0,0 @@ -/* ath.c - A Thread-safeness library. - * Copyright (C) 2002, 2003, 2004, 2011 Free Software Foundation, Inc. - * - * This file is part of Libgcrypt. - * - * Libgcrypt is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser general Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * Libgcrypt 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 . - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#if USE_POSIX_THREADS_WEAK -# include -#endif - -#include "ath.h" - - - -/* On an ELF system it is easy to use pthreads using weak references. - Take care not to test the address of a weak referenced function we - actually use; some GCC versions have a bug were &foo != NULL is - always evaluated to true in PIC mode. USING_PTHREAD_AS_DEFAULT is - used by ath_install to detect the default usage of pthread. */ -#if USE_POSIX_THREADS_WEAK -# pragma weak pthread_cancel -# pragma weak pthread_mutex_init -# pragma weak pthread_mutex_lock -# pragma weak pthread_mutex_unlock -# pragma weak pthread_mutex_destroy -#endif - -/* For the dummy interface. The MUTEX_NOTINIT value is used to check - that a mutex has been initialized. */ -#define MUTEX_NOTINIT ((ath_mutex_t) 0) -#define MUTEX_UNLOCKED ((ath_mutex_t) 1) -#define MUTEX_LOCKED ((ath_mutex_t) 2) -#define MUTEX_DESTROYED ((ath_mutex_t) 3) - - -/* Return the thread type from the option field. */ -#define GET_OPTION(a) ((a) & 0xff) - - - -enum ath_thread_model { - ath_model_undefined = 0, - ath_model_none, /* No thread support. */ - ath_model_pthreads_weak, /* POSIX threads using weak symbols. */ - ath_model_pthreads, /* POSIX threads directly linked. */ - ath_model_w32 /* Microsoft Windows threads. */ -}; - - -/* The thread model in use. */ -static enum ath_thread_model thread_model; - - -/* Initialize the ath subsystem. This is called as part of the - Libgcrypt initialization. It's purpose is to initialize the - locking system. It returns 0 on sucess or an ERRNO value on error. - In the latter case it is not defined whether ERRNO was changed. - - Note: This should be called as early as possible because it is not - always possible to detect the thread model to use while already - running multi threaded. */ -int -ath_init (void) -{ - int err = 0; - - if (thread_model) - return 0; /* Already initialized - no error. */ - - if (0) - ; -#if USE_POSIX_THREADS_WEAK - else if (pthread_cancel) - { - thread_model = ath_model_pthreads_weak; - } -#endif - else - { - /* Assume a single threaded application. */ - thread_model = ath_model_none; - } - - return err; -} - - -/* Return the used thread model as string for display purposes an if - R_MODEL is not null store its internal number at R_MODEL. */ -const char * -ath_get_model (int *r_model) -{ - if (r_model) - *r_model = thread_model; - switch (thread_model) - { - case ath_model_undefined: return "undefined"; - case ath_model_none: return "none"; - case ath_model_pthreads_weak: return "pthread(weak)"; - case ath_model_pthreads: return "pthread"; - case ath_model_w32: return "w32"; - default: return "?"; - } -} - - -/* This function was used in old Libgcrypt versions (via - GCRYCTL_SET_THREAD_CBS) to register the thread callback functions. - It is not anymore required. However to allow existing code to - continue to work, we keep this function and check that no user - defined callbacks are used and that the requested thread system - matches the one Libgcrypt is using. */ -gpg_err_code_t -ath_install (struct ath_ops *ath_ops) -{ - gpg_err_code_t rc; - unsigned int thread_option; - - /* Fist call ath_init so that we know our thread model. */ - rc = ath_init (); - if (rc) - return rc; - - /* Check if the requested thread option is compatible to the - thread option we are already committed to. */ - thread_option = ath_ops? GET_OPTION (ath_ops->option) : 0; - - /* Return an error if the requested thread model does not match the - configured one. */ - if (0) - ; -#if USE_POSIX_THREADS_WEAK - else if (thread_model == ath_model_pthreads_weak) - { - if (thread_option == ATH_THREAD_OPTION_PTHREAD) - return 0; /* Okay - compatible. */ - if (thread_option == ATH_THREAD_OPTION_PTH) - return 0; /* Okay - compatible. */ - } -#endif /*USE_POSIX_THREADS_WEAK*/ - else if (thread_option == ATH_THREAD_OPTION_PTH) - { - if (thread_model == ath_model_none) - return 0; /* Okay - compatible. */ - } - else if (thread_option == ATH_THREAD_OPTION_DEFAULT) - return 0; /* No thread support requested. */ - - return GPG_ERR_NOT_SUPPORTED; -} - - -/* Initialize a new mutex. This function returns 0 on success or an - system error code (i.e. an ERRNO value). ERRNO may or may not be - changed on error. */ -int -ath_mutex_init (ath_mutex_t *lock) -{ - int err; - - switch (thread_model) - { - case ath_model_none: - *lock = MUTEX_UNLOCKED; - err = 0; - break; - -#if USE_POSIX_THREADS_WEAK - case ath_model_pthreads_weak: - { - pthread_mutex_t *plck; - - plck = malloc (sizeof *plck); - if (!plck) - err = errno? errno : ENOMEM; - else - { - err = pthread_mutex_init (plck, NULL); - if (err) - free (plck); - else - *lock = (void*)plck; - } - } - break; -#endif /*USE_POSIX_THREADS_WEAK*/ - - default: - err = EINVAL; - break; - } - - return err; -} - - -/* Destroy a mutex. This function is a NOP if LOCK is NULL. If the - mutex is still locked it can't be destroyed and the function - returns EBUSY. ERRNO may or may not be changed on error. */ -int -ath_mutex_destroy (ath_mutex_t *lock) -{ - int err; - - if (!*lock) - return 0; - - switch (thread_model) - { - case ath_model_none: - if (*lock != MUTEX_UNLOCKED) - err = EBUSY; - else - { - *lock = MUTEX_DESTROYED; - err = 0; - } - break; - -#if USE_POSIX_THREADS_WEAK - case ath_model_pthreads_weak: - { - pthread_mutex_t *plck = (pthread_mutex_t*) (*lock); - - err = pthread_mutex_destroy (plck); - if (!err) - { - free (plck); - lock = NULL; - } - } - break; -#endif /*USE_POSIX_THREADS_WEAK*/ - - default: - err = EINVAL; - break; - } - - return err; -} - - -/* Lock the mutex LOCK. On success the function returns 0; on error - an error code. ERRNO may or may not be changed on error. */ -int -ath_mutex_lock (ath_mutex_t *lock) -{ - int err; - - switch (thread_model) - { - case ath_model_none: - if (*lock == MUTEX_NOTINIT) - err = EINVAL; - else if (*lock == MUTEX_UNLOCKED) - { - *lock = MUTEX_LOCKED; - err = 0; - } - else - err = EDEADLK; - break; - -#if USE_POSIX_THREADS_WEAK - case ath_model_pthreads_weak: - err = pthread_mutex_lock ((pthread_mutex_t*)(*lock)); - break; -#endif /*USE_POSIX_THREADS_WEAK*/ - - default: - err = EINVAL; - break; - } - - return err; -} - -/* Unlock the mutex LOCK. On success the function returns 0; on error - an error code. ERRNO may or may not be changed on error. */ -int -ath_mutex_unlock (ath_mutex_t *lock) -{ - int err; - - switch (thread_model) - { - case ath_model_none: - if (*lock == MUTEX_NOTINIT) - err = EINVAL; - else if (*lock == MUTEX_LOCKED) - { - *lock = MUTEX_UNLOCKED; - err = 0; - } - else - err = EPERM; - break; - -#if USE_POSIX_THREADS_WEAK - case ath_model_pthreads_weak: - err = pthread_mutex_unlock ((pthread_mutex_t*)(*lock)); - break; -#endif /*USE_POSIX_THREADS_WEAK*/ - - default: - err = EINVAL; - break; - } - - return err; -} diff --git a/src/ath.h b/src/ath.h deleted file mode 100644 index a132e0b..0000000 --- a/src/ath.h +++ /dev/null @@ -1,93 +0,0 @@ -/* ath.h - Thread-safeness library. - * Copyright (C) 2002, 2003, 2004, 2011 Free Software Foundation, Inc. - * - * This file is part of Libgcrypt. - * - * Libgcrypt is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser general Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * Libgcrypt 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 ATH_H -#define ATH_H - -#include - -#ifdef _WIN32 -# include -# include -#else /* !_WIN32 */ -# ifdef HAVE_SYS_SELECT_H -# include -# else -# include -# endif -# include -# ifdef HAVE_SYS_MSG_H -# include /* (e.g. for zOS) */ -# endif -# include -#endif /* !_WIN32 */ -#include - - - -/* Define _ATH_EXT_SYM_PREFIX if you want to give all external symbols - a prefix. */ -#define _ATH_EXT_SYM_PREFIX _gcry_ - -#ifdef _ATH_EXT_SYM_PREFIX -#define _ATH_PREFIX1(x,y) x ## y -#define _ATH_PREFIX2(x,y) _ATH_PREFIX1(x,y) -#define _ATH_PREFIX(x) _ATH_PREFIX2(_ATH_EXT_SYM_PREFIX,x) -#define ath_install _ATH_PREFIX(ath_install) -#define ath_init _ATH_PREFIX(ath_init) -#define ath_get_model _ATH_PREFIX(ath_get_model) -#define ath_mutex_init _ATH_PREFIX(ath_mutex_init) -#define ath_mutex_destroy _ATH_PREFIX(ath_mutex_destroy) -#define ath_mutex_lock _ATH_PREFIX(ath_mutex_lock) -#define ath_mutex_unlock _ATH_PREFIX(ath_mutex_unlock) -#endif - - -enum ath_thread_option - { - ATH_THREAD_OPTION_DEFAULT = 0, - ATH_THREAD_OPTION_USER = 1, - ATH_THREAD_OPTION_PTH = 2, - ATH_THREAD_OPTION_PTHREAD = 3 - }; - -struct ath_ops -{ - /* The OPTION field encodes the thread model and the version number - of this structure. - Bits 7 - 0 are used for the thread model - Bits 15 - 8 are used for the version number. - */ - unsigned int option; - -}; - -gpg_err_code_t ath_install (struct ath_ops *ath_ops); -int ath_init (void); -const char *ath_get_model (int *r_model); - -/* Functions for mutual exclusion. */ -typedef void *ath_mutex_t; - -int ath_mutex_init (ath_mutex_t *mutex); -int ath_mutex_destroy (ath_mutex_t *mutex); -int ath_mutex_lock (ath_mutex_t *mutex); -int ath_mutex_unlock (ath_mutex_t *mutex); - -#endif /* ATH_H */ diff --git a/src/fips.c b/src/fips.c index 3ab33f9..c90e4b6 100644 --- a/src/fips.c +++ b/src/fips.c @@ -31,7 +31,6 @@ #endif /*HAVE_SYSLOG*/ #include "g10lib.h" -#include "ath.h" #include "cipher-proto.h" #include "hmac256.h" @@ -69,7 +68,7 @@ static int enforced_fips_mode; static int inactive_fips_mode; /* This is the lock we use to protect the FSM. */ -static ath_mutex_t fsm_lock; +GPGRT_LOCK_DEFINE (fsm_lock); /* The current state of the FSM. The whole state machinery is only used while in fips mode. Change this only while holding fsm_lock. */ @@ -181,18 +180,18 @@ _gcry_initialize_fips_mode (int force) FILE *fp; /* Intitialize the lock to protect the FSM. */ - err = ath_mutex_init (&fsm_lock); + err = gpgrt_lock_init (&fsm_lock); if (err) { /* If that fails we can't do anything but abort the process. We need to use log_info so that the FSM won't get involved. */ log_info ("FATAL: failed to create the FSM lock in libgcrypt: %s\n", - strerror (err)); + gpg_strerror (err)); #ifdef HAVE_SYSLOG syslog (LOG_USER|LOG_ERR, "Libgcrypt error: " "creating FSM lock failed: %s - abort", - strerror (err)); + gpg_strerror (err)); #endif /*HAVE_SYSLOG*/ abort (); } @@ -222,15 +221,15 @@ lock_fsm (void) { gpg_error_t err; - err = ath_mutex_lock (&fsm_lock); + err = gpgrt_lock_lock (&fsm_lock); if (err) { log_info ("FATAL: failed to acquire the FSM lock in libgrypt: %s\n", - strerror (err)); + gpg_strerror (err)); #ifdef HAVE_SYSLOG syslog (LOG_USER|LOG_ERR, "Libgcrypt error: " "acquiring FSM lock failed: %s - abort", - strerror (err)); + gpg_strerror (err)); #endif /*HAVE_SYSLOG*/ abort (); } @@ -241,15 +240,15 @@ unlock_fsm (void) { gpg_error_t err; - err = ath_mutex_unlock (&fsm_lock); + err = gpgrt_lock_unlock (&fsm_lock); if (err) { log_info ("FATAL: failed to release the FSM lock in libgrypt: %s\n", - strerror (err)); + gpg_strerror (err)); #ifdef HAVE_SYSLOG syslog (LOG_USER|LOG_ERR, "Libgcrypt error: " "releasing FSM lock failed: %s - abort", - strerror (err)); + gpg_strerror (err)); #endif /*HAVE_SYSLOG*/ abort (); } diff --git a/src/global.c b/src/global.c index 9af499e..b2b1de6 100644 --- a/src/global.c +++ b/src/global.c @@ -2,7 +2,7 @@ * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 * 2004, 2005, 2006, 2008, 2011, * 2012 Free Software Foundation, Inc. - * Copyright (C) 2013 g10 Code GmbH + * Copyright (C) 2013, 2014 g10 Code GmbH * * This file is part of Libgcrypt. * @@ -38,7 +38,7 @@ #include "cipher.h" #include "stdmem.h" /* our own memory allocator */ #include "secmem.h" /* our own secmem allocator */ -#include "ath.h" + @@ -86,14 +86,6 @@ global_init (void) /* Tell the random module that we have seen an init call. */ _gcry_set_preferred_rng_type (0); - /* Initialize our portable thread/mutex wrapper. */ - err = ath_init (); - if (err) - { - err = gpg_error_from_errno (err); - goto fail; - } - /* See whether the system is in FIPS mode. This needs to come as early as possible but after ATH has been initialized. */ _gcry_initialize_fips_mode (force_fips_mode); @@ -304,7 +296,6 @@ print_config ( int (*fnc)(FILE *fp, const char *format, ...), FILE *fp) #endif ":\n"); fnc (fp, "mpi-asm:%s:\n", _gcry_mpi_get_hw_config ()); - fnc (fp, "threads:%s:\n", ath_get_model (NULL)); hwfeatures = _gcry_get_hw_features (); fnc (fp, "hwflist:"); for (i=0; (s = _gcry_enum_hw_features (i, &afeature)); i++) @@ -476,10 +467,10 @@ _gcry_vcontrol (enum gcry_ctl_cmds cmd, va_list arg_ptr) break; case GCRYCTL_SET_THREAD_CBS: + /* This is now a dummy call. We used to install our own thread + library here. */ _gcry_set_preferred_rng_type (0); - rc = ath_install (va_arg (arg_ptr, void *)); - if (!rc) - global_init (); + global_init (); break; case GCRYCTL_FAST_POLL: diff --git a/src/secmem.c b/src/secmem.c index 2bf7d8c..cfea921 100644 --- a/src/secmem.c +++ b/src/secmem.c @@ -37,7 +37,6 @@ #endif #endif -#include "ath.h" #include "g10lib.h" #include "secmem.h" @@ -86,11 +85,11 @@ static int no_priv_drop; static unsigned int cur_alloced, cur_blocks; /* Lock protecting accesses to the memory pool. */ -static ath_mutex_t secmem_lock; +GPGRT_LOCK_DEFINE (secmem_lock); /* Convenient macros. */ -#define SECMEM_LOCK ath_mutex_lock (&secmem_lock) -#define SECMEM_UNLOCK ath_mutex_unlock (&secmem_lock) +#define SECMEM_LOCK gpgrt_lock_lock (&secmem_lock) +#define SECMEM_UNLOCK gpgrt_lock_unlock (&secmem_lock) /* The size of the memblock structure; this does not include the memory that is available to the user. */ @@ -536,12 +535,7 @@ _gcry_secmem_init (size_t n) gcry_err_code_t _gcry_secmem_module_init () { - int err; - - err = ath_mutex_init (&secmem_lock); - if (err) - log_fatal ("could not allocate secmem lock\n"); - + /* No anymore needed. */ return 0; } ----------------------------------------------------------------------- Summary of changes: cipher/cipher-aeswrap.c | 1 - cipher/cipher-cbc.c | 1 - cipher/cipher-ccm.c | 1 - cipher/cipher-cfb.c | 1 - cipher/cipher-ctr.c | 1 - cipher/cipher-gcm.c | 1 - cipher/cipher-ofb.c | 1 - cipher/cipher.c | 1 - cipher/kdf.c | 1 - cipher/md.c | 1 - cipher/primegen.c | 68 ++++------ cipher/pubkey.c | 1 - compat/compat.c | 4 +- configure.ac | 7 +- doc/gcrypt.texi | 95 +------------- random/random-csprng.c | 15 +-- random/random-daemon.c | 24 +--- random/random-fips.c | 23 ++-- random/random-system.c | 24 ++-- random/random.c | 23 +--- src/Makefile.am | 3 +- src/ath.c | 333 ----------------------------------------------- src/ath.h | 93 ------------- src/fips.c | 21 ++- src/global.c | 19 +-- src/secmem.c | 14 +- 26 files changed, 90 insertions(+), 687 deletions(-) delete mode 100644 src/ath.c delete mode 100644 src/ath.h hooks/post-receive -- The GNU crypto library http://git.gnupg.org From cvs at cvs.gnupg.org Fri Jan 17 18:08:46 2014 From: cvs at cvs.gnupg.org (by Werner Koch) Date: Fri, 17 Jan 2014 18:08:46 +0100 Subject: [git] GPG-ERROR - branch, master, updated. libgpg-error-1.12-14-ge07538c Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Error codes used by GnuPG et al.". The branch, master has been updated via e07538c0ed3c5cb3d870a490a4c12bef4375278a (commit) via d83b12213231443b93de39863b916ada6232035a (commit) from 4f9b13e99bdfed886dadfd1b70a69af3747ebc98 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit e07538c0ed3c5cb3d870a490a4c12bef4375278a Author: Werner Koch Date: Thu Jan 9 19:14:09 2014 +0100 Move version number first in the Posix lock-obj. * src/posix-lock-obj.h (_gpgrt_lock_t): Swap VERS and MTX and put MTX into a union. * src/posix-lock.c (gpgrt_lock_lock): Adjust for this change. * src/gen-posix-lock-obj.c (main): Change output accordingly. Signed-off-by: Werner Koch diff --git a/src/gen-posix-lock-obj.c b/src/gen-posix-lock-obj.c index 5dbc6c6..7644c6f 100644 --- a/src/gen-posix-lock-obj.c +++ b/src/gen-posix-lock-obj.c @@ -70,30 +70,31 @@ main (void) "## File created by " PGM " - DO NOT EDIT\n" "## To be included by mkheader into gpg-error.h\n" "\n" - "typedef union\n" + "typedef struct\n" "{\n" - " struct {\n" + " long _vers;\n" + " union {\n" " volatile char _priv[%d];\n" - " long _vers;\n" - " } d;\n" - " long _x_align;\n" - " long *_xp_align;\n" + " long _x_align;\n" + " long *_xp_align;\n" + " } u;\n" "} gpgrt_lock_t;\n" "\n" - "#define GPGRT_LOCK_INITIALIZER {{{", + "#define GPGRT_LOCK_INITIALIZER {%d,{{", HOST_TRIPLET_STRING, - SIZEOF_PTHREAD_MUTEX_T); + SIZEOF_PTHREAD_MUTEX_T, + LOCK_ABI_VERSION); p = (unsigned char *)&mtx; for (i=0; i < sizeof mtx; i++) { if (i && !(i % 8)) - printf (" \\\n%*s", 34, ""); + printf (" \\\n%*s", 36, ""); printf ("%u", p[i]); if (i < sizeof mtx - 1) putchar (','); } - printf ("},%d}}\n", LOCK_ABI_VERSION); - fputs ("##\n" + fputs ("}}}\n" + "##\n" "## Loc" "al Variables:\n" "## mode: c\n" "## buffer-read-only: t\n" diff --git a/src/posix-lock-obj.h b/src/posix-lock-obj.h index a5a9ee7..7714d3c 100644 --- a/src/posix-lock-obj.h +++ b/src/posix-lock-obj.h @@ -24,8 +24,11 @@ typedef struct { - pthread_mutex_t mtx; long vers; + union { + pthread_mutex_t mtx; + long *dummy; + } u; } _gpgrt_lock_t; diff --git a/src/posix-lock.c b/src/posix-lock.c index 46e3a84..363cc09 100644 --- a/src/posix-lock.c +++ b/src/posix-lock.c @@ -122,7 +122,7 @@ gpgrt_lock_init (gpgrt_lock_t *lockhd) #if USE_POSIX_THREADS if (use_pthread_p()) { - rc = pthread_mutex_init (&lock->mtx, NULL); + rc = pthread_mutex_init (&lock->u.mtx, NULL); if (rc) rc = gpg_err_code_from_errno (rc); } @@ -145,7 +145,7 @@ gpgrt_lock_lock (gpgrt_lock_t *lockhd) #if USE_POSIX_THREADS if (use_pthread_p()) { - rc = pthread_mutex_lock (&lock->mtx); + rc = pthread_mutex_lock (&lock->u.mtx); if (rc) rc = gpg_err_code_from_errno (rc); } @@ -168,7 +168,7 @@ gpgrt_lock_unlock (gpgrt_lock_t *lockhd) #if USE_POSIX_THREADS if (use_pthread_p()) { - rc = pthread_mutex_unlock (&lock->mtx); + rc = pthread_mutex_unlock (&lock->u.mtx); if (rc) rc = gpg_err_code_from_errno (rc); } @@ -193,7 +193,7 @@ gpgrt_lock_destroy (gpgrt_lock_t *lockhd) #if USE_POSIX_THREADS if (use_pthread_p()) { - rc = pthread_mutex_destroy (&lock->mtx); + rc = pthread_mutex_destroy (&lock->u.mtx); if (rc) rc = gpg_err_code_from_errno (rc); else commit d83b12213231443b93de39863b916ada6232035a Author: Werner Koch Date: Thu Jan 9 19:14:09 2014 +0100 Extend the platform dependent build rules. * src/mkheader.c (mk_include_name): New. (include_file): Implement '&' substitution. (try_include_file): New. (write_special): Use try_include_file and syscfg/. (main): Add a new arg. * configure.ac (CROSS_COMPILING): New am_conditional. (HOST_TRIPLET_STRING): New ac_define. * src/gen-posix-lock-obj.c (main): Print the host triplet. * src/w32-lock-obj-pub.in: Move to ... * src/syscfg/lock-obj-pub.mingw32.h: here. * src/Makefile.am (lock_obj_pub): New. (pre_mkheader_cmds): New. (gpg-error.h): Run pre_mkheader_cmds. (parts_of_gpg_error_h, lock-obj-pub.native.h): Do not use when cross-compiling. Signed-off-by: Werner Koch diff --git a/README b/README index 73af551..3d4640c 100644 --- a/README +++ b/README @@ -95,6 +95,30 @@ version: ./autogen.sh --build-w64 +Cross-Compiling +--------------- + +Libgpg-error needs to figure out some platform specific properties. +These are used to build the platform specific gpg-error.h file. The +detection is done during build time but can't be done when +cross-compiling. Thus if you run into an error during building you +need to figure out these values. You may use these commands: + + build="$(build-aux/config.guess)" + ./configure --prefix=TARGETDIR --host=TARGET --build=$build + cd src + make gen-posix-lock-obj + scp gen-posix-lock-obj TARGET: + ssh TARGET ./gen-posix-lock-obj >tmp.h + mv tmp.h "syscfg/$(awk 'NR==1 {print $2}' tmp.h)" + +If you are using a VPATH build adjust accordingly. If this all works +for you (make sure to run the test programs on the target platform), +please send the generated file to the gnupg-devel mailing list so that +we can include it in the next release. + + + Known Problems -------------- diff --git a/configure.ac b/configure.ac index 3d1e12f..21a36e9 100644 --- a/configure.ac +++ b/configure.ac @@ -202,6 +202,9 @@ fi AM_CONDITIONAL(HAVE_W32_SYSTEM, test "$have_w32_system" = yes) AM_CONDITIONAL(HAVE_W64_SYSTEM, test "$have_w64_system" = yes) AM_CONDITIONAL(HAVE_W32CE_SYSTEM, test "$have_w32ce_system" = yes) +AM_CONDITIONAL(CROSS_COMPILING, test x$cross_compiling = xyes) + +AC_DEFINE_UNQUOTED(HOST_TRIPLET_STRING, "$host", [The host triplet]) # diff --git a/src/Makefile.am b/src/Makefile.am index 9ced1e5..77ece16 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -39,6 +39,11 @@ else noinst_PROGRAMS = gen-posix-lock-obj endif +# Distributed lock object definitions for cross compilation. +lock_obj_pub = \ + syscfg/lock-obj-pub.mingw32.h + + lib_LTLIBRARIES = libgpg-error.la include_HEADERS = gpg-error.h bin_SCRIPTS = gpg-error-config @@ -51,7 +56,7 @@ EXTRA_DIST = mkstrtable.awk err-sources.h.in err-codes.h.in \ mkheader.c gpg-error.h.in mkw32errmap.c w32-add.h w32ce-add.h \ err-sources.h err-codes.h gpg-error-config.in gpg-error.m4 \ gpg-error.def.in versioninfo.rc.in \ - w32-lock-obj-pub.in + $(lock_obj_pub) BUILT_SOURCES = err-sources.h err-codes.h code-to-errno.h code-from-errno.h \ err-sources-sym.h err-codes-sym.h errnos-sym.h gpg-error.h \ @@ -62,7 +67,7 @@ tmp_files = _mkerrcodes.h _gpg-error.def.h mkw32errmap.tab.h mkw32errmap.map.c CLEANFILES = err-sources.h err-codes.h code-to-errno.h code-from-errno.h \ gpg-error.h mkerrcodes mkerrcodes.h gpg-error.def mkw32errmap.tab.h \ mkw32errmap.map.c err-sources-sym.h err-codes-sym.h errnos-sym.h \ - gpg-extra/errno.h mkheader $(tmp_files) posix-lock-obj-pub.in + gpg-extra/errno.h mkheader $(tmp_files) lock-obj-pub.native.h if HAVE_W32_SYSTEM arch_sources = w32-gettext.c w32-lock.c w32-lock-obj.h w32-thread.c @@ -106,20 +111,6 @@ libgpg_error_la_LDFLAGS = -version-info \ @LIBGPG_ERROR_LT_CURRENT@:@LIBGPG_ERROR_LT_REVISION@:@LIBGPG_ERROR_LT_AGE@ \ $(no_undefined) $(export_symbols) -parts_of_gpg_error_h = \ - gpg-error.h.in \ - err-sources.h.in \ - err-codes.h.in \ - errnos.in \ - w32-add.h \ - w32ce-add.h \ - w32-lock-obj-pub.in - -if ! HAVE_W32_SYSTEM -parts_of_gpg_error_h += posix-lock-obj-pub.in -endif - - libgpg_error_la_SOURCES = gpg-error.h gettext.h $(arch_sources) \ init.c init.h version.c lock.h thread.h \ strsource.c strerror.c code-to-errno.c code-from-errno.c @@ -212,14 +203,32 @@ errnos-sym.h: Makefile mkstrtable.awk errnos.in mkheader: mkheader.c Makefile $(CC_FOR_BUILD) -g -O0 -I. -I$(srcdir) -o $@ $(srcdir)/mkheader.c +parts_of_gpg_error_h = \ + gpg-error.h.in \ + err-sources.h.in \ + err-codes.h.in \ + errnos.in \ + w32-add.h \ + w32ce-add.h \ + $(lock_obj_pub) -posix-lock-obj-pub.in: Makefile gen-posix-lock-obj posix-lock-obj.h +# If we are cross-compiling we better make sure that no stale native +# lock include file will be found by mkheader. +if CROSS_COMPILING +pre_mkheader_cmds = -rm lock-obj-pub.native.h 2>/dev/null +else +pre_mkheader_cmds = : +parts_of_gpg_error_h += ./lock-obj-pub.native.h + +lock-obj-pub.native.h: Makefile gen-posix-lock-obj posix-lock-obj.h ./gen-posix-lock-obj >$@ +endif # We also depend on versioninfo.rc because that is build by # config.status and thus has up-to-date version numbers. gpg-error.h: Makefile mkheader $(parts_of_gpg_error_h) versioninfo.rc - ./mkheader $(host_os) $(srcdir)/gpg-error.h.in \ + $(pre_mkheader_cmds) + ./mkheader $(host_os) $(host_triplet) $(srcdir)/gpg-error.h.in \ $(PACKAGE_VERSION) $(VERSION_NUMBER) >$@ diff --git a/src/gen-posix-lock-obj.c b/src/gen-posix-lock-obj.c index b641fd0..5dbc6c6 100644 --- a/src/gen-posix-lock-obj.c +++ b/src/gen-posix-lock-obj.c @@ -27,6 +27,7 @@ #include #include +#include #include #include "posix-lock-obj.h" @@ -65,7 +66,8 @@ main (void) /* To force a probably suitable alignment of the structure we use a union and include a long and a pointer to a long. */ - printf ("## File created by " PGM " - DO NOT EDIT\n" + printf ("## lock-obj.%s.h\n" + "## File created by " PGM " - DO NOT EDIT\n" "## To be included by mkheader into gpg-error.h\n" "\n" "typedef union\n" @@ -79,6 +81,7 @@ main (void) "} gpgrt_lock_t;\n" "\n" "#define GPGRT_LOCK_INITIALIZER {{{", + HOST_TRIPLET_STRING, SIZEOF_PTHREAD_MUTEX_T); p = (unsigned char *)&mtx; for (i=0; i < sizeof mtx; i++) @@ -90,6 +93,18 @@ main (void) putchar (','); } printf ("},%d}}\n", LOCK_ABI_VERSION); + fputs ("##\n" + "## Loc" "al Variables:\n" + "## mode: c\n" + "## buffer-read-only: t\n" + "## End:\n" + "##\n", stdout); + + if (ferror (stdout)) + { + fprintf (stderr, PGM ": error writing to stdout: %s\n", strerror (errno)); + return 1; + } return 0; } diff --git a/src/mkheader.c b/src/mkheader.c index e7db729..43e7fd8 100644 --- a/src/mkheader.c +++ b/src/mkheader.c @@ -16,12 +16,14 @@ #include #include #include +#include #define PGM "mkheader" #define LINESIZE 1024 static const char *host_os; +static const char *host_triplet; static char *srcdir; static const char *hdr_version; static const char *hdr_version_number; @@ -128,6 +130,45 @@ write_errnos_in (char *line) } +/* Create the full file name for NAME and return a newly allocated + string with it. If name contains a '&' and REPL is not NULL + replace '&' with REPL. */ +static char * +mk_include_name (const char *name, const char *repl) +{ + FILE *fp; + char *incfname, *p; + const char *s; + + incfname = malloc (strlen (srcdir) + strlen (name) + + (repl?strlen (repl):0) + 1); + if (!incfname) + { + fputs (PGM ": out of core\n", stderr); + exit (1); + } + + if (*name == '.' && name[1] == '/') + *incfname = 0; + else + strcpy (incfname, srcdir); + p = incfname + strlen (incfname); + for (s=name; *s; s++) + { + if (*s == '&' && repl) + { + while (*repl) + *p++ = *repl++; + repl = NULL; /* Replace only once. */ + } + else + *p++ = *s; + } + *p = 0; + return incfname; +} + + /* Include the file NAME from the source directory. The included file is not further expanded. It may have comments indicated by a double hash mark at the begin of a line. OUTF is called for each @@ -141,21 +182,18 @@ include_file (const char *fname, int lnr, const char *name, void (*outf)(char*)) char *incfname; int inclnr; char line[LINESIZE]; + int repl_flag; - incfname = malloc (strlen (srcdir) + strlen (name) + 1); - if (!incfname) + repl_flag = !!strchr (name, '&'); + incfname = mk_include_name (name, repl_flag? host_triplet : NULL); + fp = fopen (incfname, "r"); + if (!fp && repl_flag) { - fputs (PGM ": out of core\n", stderr); - exit (1); + /* Try again using the OS string. */ + free (incfname); + incfname = mk_include_name (name, host_os); + fp = fopen (incfname, "r"); } - - if (*name == '.' && name[1] == '/') - *incfname = 0; - else - strcpy (incfname, srcdir); - strcat (incfname, name); - - fp = fopen (incfname, "r"); if (!fp) { fprintf (stderr, "%s:%d: error including `%s': %s\n", @@ -163,6 +201,10 @@ include_file (const char *fname, int lnr, const char *name, void (*outf)(char*)) exit (1); } + if (repl_flag) + fprintf (stderr,"%s:%d: note: including '%s'\n", + fname, lnr, incfname); + inclnr = 0; while (fgets (line, LINESIZE, fp)) { @@ -206,6 +248,33 @@ include_file (const char *fname, int lnr, const char *name, void (*outf)(char*)) } +/* Try to include the file NAME. Returns true if it does not + exist. */ +static int +try_include_file (const char *fname, int lnr, const char *name, + void (*outf)(char*)) +{ + int rc; + char *incfname; + int repl_flag; + + repl_flag = !!strchr (name, '&'); + incfname = mk_include_name (name, repl_flag? host_triplet : NULL); + rc = access (incfname, R_OK); + if (rc && repl_flag) + { + free (incfname); + incfname = mk_include_name (name, host_os); + rc = access (incfname, R_OK); + } + if (!rc) + include_file (fname, lnr, name, outf); + + free (incfname); + return rc; +} + + static int write_special (const char *fname, int lnr, const char *tag) { @@ -249,12 +318,8 @@ write_special (const char *fname, int lnr, const char *tag) } else if (!strcmp (tag, "include:lock-obj")) { - if (!strcmp (host_os, "mingw32")) - { - include_file (fname, lnr, "w32-lock-obj-pub.in", write_line); - } - else - include_file (fname, lnr, "./posix-lock-obj-pub.in", write_line); + if (try_include_file (fname, lnr, "./lock-obj-pub.native.h", write_line)) + include_file (fname, lnr, "syscfg/lock-obj-pub.&.h", write_line); } else return 0; /* Unknown tag. */ @@ -277,16 +342,18 @@ main (int argc, char **argv) argc--; argv++; } - if (argc != 4) + if (argc != 5) { - fputs ("usage: " PGM " host_os template.h version version_number\n", + fputs ("usage: " PGM + " host_os host_triplet template.h version version_number\n", stderr); return 1; } host_os = argv[0]; - fname = argv[1]; - hdr_version = argv[2]; - hdr_version_number = argv[3]; + host_triplet = argv[1]; + fname = argv[2]; + hdr_version = argv[3]; + hdr_version_number = argv[4]; srcdir = malloc (strlen (fname) + 2 + 1); if (!srcdir) @@ -337,8 +404,8 @@ main (int argc, char **argv) if (!strcmp (p1, "configure_input")) { s = strrchr (fname, '/'); - printf ("Do not edit. Generated from %s by %s for %s.", - s? s+1 : fname, PGM, host_os); + printf ("Do not edit. Generated from %s for %s.", + s? s+1 : fname, host_triplet); fputs (p2, stdout); putchar ('\n'); } diff --git a/src/w32-lock-obj-pub.in b/src/syscfg/lock-obj-pub.mingw32.h similarity index 100% rename from src/w32-lock-obj-pub.in rename to src/syscfg/lock-obj-pub.mingw32.h ----------------------------------------------------------------------- Summary of changes: README | 24 ++++ configure.ac | 3 + src/Makefile.am | 45 +++++--- src/gen-posix-lock-obj.c | 38 +++++-- src/mkheader.c | 117 +++++++++++++++----- src/posix-lock-obj.h | 5 +- src/posix-lock.c | 8 +- .../lock-obj-pub.mingw32.h} | 0 8 files changed, 181 insertions(+), 59 deletions(-) rename src/{w32-lock-obj-pub.in => syscfg/lock-obj-pub.mingw32.h} (100%) hooks/post-receive -- Error codes used by GnuPG et al. http://git.gnupg.org From cvs at cvs.gnupg.org Sun Jan 19 15:15:14 2014 From: cvs at cvs.gnupg.org (by Werner Koch) Date: Sun, 19 Jan 2014 15:15:14 +0100 Subject: [git] GCRYPT - branch, master, updated. libgcrypt-1.6.0-37-g94030e4 Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The GNU crypto library". The branch, master has been updated via 94030e44aaff805d754e368507f16dd51a531b72 (commit) via c3b30bae7d1e157f8b65e32ba1b3a516f2bbf58b (commit) from cfc151ba637200e4fc05d9481a8df2071b2f9a47 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 94030e44aaff805d754e368507f16dd51a531b72 Author: Werner Koch Date: Thu Jan 9 19:14:09 2014 +0100 md: Add Whirlpool bug emulation feature. * src/gcrypt.h.in (GCRY_MD_FLAG_BUGEMU1): New. * src/cipher-proto.h (gcry_md_init_t): Add arg FLAGS. Change all code to implement that flag. * cipher/md.c (gcry_md_context): Replace SECURE and FINALIZED by bit field FLAGS. Add flag BUGEMU1. Change all users. (md_open): Replace args SECURE and HMAC by FLAGS. Init flags.bugemu1. (_gcry_md_open): Add for GCRY_MD_FLAG_BUGEMU1. (md_enable): Pass bugemu1 flag to the hash init function. (_gcry_md_reset): Ditto. -- This problem is for example exhibited in the Linux cryptsetup tool. See https://bbs.archlinux.org/viewtopic.php?id=175737 . It has be been tracked down by Milan Broz. The suggested way of using the flag is: if (whirlpool_bug_assumed) { #if GCRYPT_VERSION_NUMBER >= 0x010601 err = gcry_md_open (&hd, GCRY_MD_WHIRLPOOL, GCRY_MD_FLAG_BUGEMU1) if (gpg_err_code (err) == GPG_ERR_INV_ARG) error ("Need at least Libggcrypt 1.6.1 for the fix"); else { do_hash (hd); gcry_md_close (hd); } #endif } Signed-off-by: Werner Koch diff --git a/NEWS b/NEWS index 4bf4a06..5e21eb6 100644 --- a/NEWS +++ b/NEWS @@ -8,10 +8,13 @@ Noteworthy changes in version 1.7.0 (unreleased) * Support curves GOST R 34.10-2001 and GOST R 34.10-2012. + * Add emulation from broken Whirlpool code prior to 1.6.0. + * Interface changes relative to the 1.6.0 release: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ gcry_mac_get_algo NEW. GCRY_MAC_HMAC_MD2 NEW. + GCRY_MD_FLAG_BUGEMU1 NEW. Noteworthy changes in version 1.6.0 (2013-12-16) diff --git a/cipher/crc.c b/cipher/crc.c index 4f72ffb..1322f0d 100644 --- a/cipher/crc.c +++ b/cipher/crc.c @@ -149,9 +149,12 @@ CRC_CONTEXT; /* CRC32 */ static void -crc32_init (void *context) +crc32_init (void *context, unsigned int flags) { CRC_CONTEXT *ctx = (CRC_CONTEXT *) context; + + (void)flags; + ctx->CRC = 0 ^ 0xffffffffL; } @@ -184,9 +187,12 @@ crc32_final (void *context) /* CRC32 a'la RFC 1510 */ static void -crc32rfc1510_init (void *context) +crc32rfc1510_init (void *context, unsigned int flags) { CRC_CONTEXT *ctx = (CRC_CONTEXT *) context; + + (void)flags; + ctx->CRC = 0; } @@ -237,9 +243,12 @@ crc32rfc1510_final (void *context) #define CRC24_POLY 0x1864cfbL static void -crc24rfc2440_init (void *context) +crc24rfc2440_init (void *context, unsigned int flags) { CRC_CONTEXT *ctx = (CRC_CONTEXT *) context; + + (void)flags; + ctx->CRC = CRC24_INIT; } diff --git a/cipher/gostr3411-94.c b/cipher/gostr3411-94.c index b3326aa..9a39733 100644 --- a/cipher/gostr3411-94.c +++ b/cipher/gostr3411-94.c @@ -44,10 +44,12 @@ static unsigned int transform (void *c, const unsigned char *data, size_t nblks); static void -gost3411_init (void *context) +gost3411_init (void *context, unsigned int flags) { GOSTR3411_CONTEXT *hd = context; + (void)flags; + memset (&hd->hd, 0, sizeof(hd->hd)); memset (hd->h, 0, 32); memset (hd->sigma, 0, 32); diff --git a/cipher/md.c b/cipher/md.c index f4fb129..a332e03 100644 --- a/cipher/md.c +++ b/cipher/md.c @@ -1,7 +1,7 @@ /* md.c - message digest dispatcher * Copyright (C) 1998, 1999, 2002, 2003, 2006, * 2008 Free Software Foundation, Inc. - * Copyright (C) 2013 g10 Code GmbH + * Copyright (C) 2013, 2014 g10 Code GmbH * * This file is part of Libgcrypt. * @@ -93,9 +93,12 @@ struct gcry_md_context { int magic; size_t actual_handle_size; /* Allocated size of this handle. */ - int secure; FILE *debug; - int finalized; + struct { + unsigned int secure: 1; + unsigned int finalized:1; + unsigned int bugemu1:1; + } flags; GcryDigestEntry *list; byte *macpads; int macpads_Bsize; /* Blocksize as used for the HMAC pads. */ @@ -269,9 +272,11 @@ check_digest_algo (int algorithm) * may be 0. */ static gcry_err_code_t -md_open (gcry_md_hd_t *h, int algo, int secure, int hmac) +md_open (gcry_md_hd_t *h, int algo, unsigned int flags) { - gcry_err_code_t err = GPG_ERR_NO_ERROR; + gcry_err_code_t err = 0; + int secure = !!(flags & GCRY_MD_FLAG_SECURE); + int hmac = !!(flags & GCRY_MD_FLAG_HMAC); int bufsize = secure ? 512 : 1024; struct gcry_md_context *ctx; gcry_md_hd_t hd; @@ -315,7 +320,8 @@ md_open (gcry_md_hd_t *h, int algo, int secure, int hmac) memset (hd->ctx, 0, sizeof *hd->ctx); ctx->magic = secure ? CTX_MAGIC_SECURE : CTX_MAGIC_NORMAL; ctx->actual_handle_size = n + sizeof (struct gcry_md_context); - ctx->secure = secure; + ctx->flags.secure = secure; + ctx->flags.bugemu1 = !!(flags & GCRY_MD_FLAG_BUGEMU1); if (hmac) { @@ -371,13 +377,12 @@ _gcry_md_open (gcry_md_hd_t *h, int algo, unsigned int flags) gcry_err_code_t rc; gcry_md_hd_t hd; - if ((flags & ~(GCRY_MD_FLAG_SECURE | GCRY_MD_FLAG_HMAC))) + if ((flags & ~(GCRY_MD_FLAG_SECURE + | GCRY_MD_FLAG_HMAC + | GCRY_MD_FLAG_BUGEMU1))) rc = GPG_ERR_INV_ARG; else - { - rc = md_open (&hd, algo, (flags & GCRY_MD_FLAG_SECURE), - (flags & GCRY_MD_FLAG_HMAC)); - } + rc = md_open (&hd, algo, flags); *h = rc? NULL : hd; return rc; @@ -423,7 +428,7 @@ md_enable (gcry_md_hd_t hd, int algorithm) - sizeof (entry->context)); /* And allocate a new list entry. */ - if (h->secure) + if (h->flags.secure) entry = xtrymalloc_secure (size); else entry = xtrymalloc (size); @@ -438,7 +443,8 @@ md_enable (gcry_md_hd_t hd, int algorithm) h->list = entry; /* And init this instance. */ - entry->spec->init (&entry->context.c); + entry->spec->init (&entry->context.c, + h->flags.bugemu1? GCRY_MD_FLAG_BUGEMU1:0); } } @@ -467,7 +473,7 @@ md_copy (gcry_md_hd_t ahd, gcry_md_hd_t *b_hd) md_write (ahd, NULL, 0); n = (char *) ahd->ctx - (char *) ahd; - if (a->secure) + if (a->flags.secure) bhd = xtrymalloc_secure (n + sizeof (struct gcry_md_context)); else bhd = xtrymalloc (n + sizeof (struct gcry_md_context)); @@ -505,7 +511,7 @@ md_copy (gcry_md_hd_t ahd, gcry_md_hd_t *b_hd) { for (ar = a->list; ar; ar = ar->next) { - if (a->secure) + if (a->flags.secure) br = xtrymalloc_secure (sizeof *br + ar->spec->contextsize - sizeof(ar->context)); @@ -560,12 +566,13 @@ _gcry_md_reset (gcry_md_hd_t a) /* Note: We allow this even in fips non operational mode. */ - a->bufpos = a->ctx->finalized = 0; + a->bufpos = a->ctx->flags.finalized = 0; for (r = a->ctx->list; r; r = r->next) { memset (r->context.c, 0, r->spec->contextsize); - (*r->spec->init) (&r->context.c); + (*r->spec->init) (&r->context.c, + a->ctx->flags.bugemu1? GCRY_MD_FLAG_BUGEMU1:0); } if (a->ctx->macpads) md_write (a, a->ctx->macpads, a->ctx->macpads_Bsize); /* inner pad */ @@ -642,7 +649,7 @@ md_final (gcry_md_hd_t a) { GcryDigestEntry *r; - if (a->ctx->finalized) + if (a->ctx->flags.finalized) return; if (a->bufpos) @@ -651,7 +658,7 @@ md_final (gcry_md_hd_t a) for (r = a->ctx->list; r; r = r->next) (*r->spec->final) (&r->context.c); - a->ctx->finalized = 1; + a->ctx->flags.finalized = 1; if (a->ctx->macpads) { @@ -660,8 +667,11 @@ md_final (gcry_md_hd_t a) byte *p = md_read (a, algo); size_t dlen = md_digest_length (algo); gcry_md_hd_t om; - gcry_err_code_t err = md_open (&om, algo, a->ctx->secure, 0); + gcry_err_code_t err; + err = md_open (&om, algo, + ((a->ctx->flags.secure? GCRY_MD_FLAG_SECURE:0) + | (a->ctx->flags.bugemu1? GCRY_MD_FLAG_BUGEMU1:0))); if (err) _gcry_fatal_error (err, NULL); md_write (om, @@ -864,7 +874,7 @@ _gcry_md_hash_buffer (int algo, void *digest, } } - err = md_open (&h, algo, 0, 0); + err = md_open (&h, algo, 0); if (err) log_bug ("gcry_md_open failed for algo %d: %s", algo, gpg_strerror (gcry_error(err))); @@ -925,7 +935,7 @@ _gcry_md_hash_buffers (int algo, unsigned int flags, void *digest, } } - rc = md_open (&h, algo, 0, hmac); + rc = md_open (&h, algo, (hmac? GCRY_MD_FLAG_HMAC:0)); if (rc) return rc; @@ -1158,7 +1168,7 @@ _gcry_md_info (gcry_md_hd_t h, int cmd, void *buffer, size_t *nbytes) switch (cmd) { case GCRYCTL_IS_SECURE: - *nbytes = h->ctx->secure; + *nbytes = h->ctx->flags.secure; break; case GCRYCTL_IS_ALGO_ENABLED: diff --git a/cipher/md4.c b/cipher/md4.c index 40dc058..7291254 100644 --- a/cipher/md4.c +++ b/cipher/md4.c @@ -69,10 +69,12 @@ static unsigned int transform ( void *c, const unsigned char *data, size_t nblks ); static void -md4_init( void *context ) +md4_init (void *context, unsigned int flags) { MD4_CONTEXT *ctx = context; + (void)flags; + ctx->A = 0x67452301; ctx->B = 0xefcdab89; ctx->C = 0x98badcfe; diff --git a/cipher/md5.c b/cipher/md5.c index d06d3f7..73ad968 100644 --- a/cipher/md5.c +++ b/cipher/md5.c @@ -53,10 +53,12 @@ static unsigned int transform ( void *ctx, const unsigned char *data, size_t datalen ); static void -md5_init( void *context ) +md5_init( void *context, unsigned int flags) { MD5_CONTEXT *ctx = context; + (void)flags; + ctx->A = 0x67452301; ctx->B = 0xefcdab89; ctx->C = 0x98badcfe; diff --git a/cipher/rmd160.c b/cipher/rmd160.c index 224694f..1a58ba6 100644 --- a/cipher/rmd160.c +++ b/cipher/rmd160.c @@ -143,11 +143,13 @@ static unsigned int transform ( void *ctx, const unsigned char *data, size_t nblks ); -void -_gcry_rmd160_init (void *context) +static void +rmd160_init (void *context, unsigned int flags) { RMD160_CONTEXT *hd = context; + (void)flags; + hd->h0 = 0x67452301; hd->h1 = 0xEFCDAB89; hd->h2 = 0x98BADCFE; @@ -162,6 +164,12 @@ _gcry_rmd160_init (void *context) } +void +_gcry_rmd160_init (void *context) +{ + rmd160_init (context, 0); +} + /**************** * Transform the message X which consists of 16 32-bit-words @@ -528,6 +536,6 @@ gcry_md_spec_t _gcry_digest_spec_rmd160 = { GCRY_MD_RMD160, {0, 0}, "RIPEMD160", asn, DIM (asn), oid_spec_rmd160, 20, - _gcry_rmd160_init, _gcry_md_block_write, rmd160_final, rmd160_read, + rmd160_init, _gcry_md_block_write, rmd160_final, rmd160_read, sizeof (RMD160_CONTEXT) }; diff --git a/cipher/sha1.c b/cipher/sha1.c index 889a7ea..65bd686 100644 --- a/cipher/sha1.c +++ b/cipher/sha1.c @@ -106,11 +106,13 @@ transform (void *c, const unsigned char *data, size_t nblks); static void -sha1_init (void *context) +sha1_init (void *context, unsigned int flags) { SHA1_CONTEXT *hd = context; unsigned int features = _gcry_get_hw_features (); + (void)flags; + hd->h0 = 0x67452301; hd->h1 = 0xefcdab89; hd->h2 = 0x98badcfe; @@ -425,7 +427,7 @@ _gcry_sha1_hash_buffer (void *outbuf, const void *buffer, size_t length) { SHA1_CONTEXT hd; - sha1_init (&hd); + sha1_init (&hd, 0); _gcry_md_block_write (&hd, buffer, length); sha1_final (&hd); memcpy (outbuf, hd.bctx.buf, 20); @@ -438,7 +440,7 @@ _gcry_sha1_hash_buffers (void *outbuf, const gcry_buffer_t *iov, int iovcnt) { SHA1_CONTEXT hd; - sha1_init (&hd); + sha1_init (&hd, 0); for (;iovcnt > 0; iov++, iovcnt--) _gcry_md_block_write (&hd, (const char*)iov[0].data + iov[0].off, iov[0].len); diff --git a/cipher/sha256.c b/cipher/sha256.c index 601e9c0..4efaec6 100644 --- a/cipher/sha256.c +++ b/cipher/sha256.c @@ -92,11 +92,13 @@ transform (void *c, const unsigned char *data, size_t nblks); static void -sha256_init (void *context) +sha256_init (void *context, unsigned int flags) { SHA256_CONTEXT *hd = context; unsigned int features = _gcry_get_hw_features (); + (void)flags; + hd->h0 = 0x6a09e667; hd->h1 = 0xbb67ae85; hd->h2 = 0x3c6ef372; @@ -128,11 +130,13 @@ sha256_init (void *context) static void -sha224_init (void *context) +sha224_init (void *context, unsigned int flags) { SHA256_CONTEXT *hd = context; unsigned int features = _gcry_get_hw_features (); + (void)flags; + hd->h0 = 0xc1059ed8; hd->h1 = 0x367cd507; hd->h2 = 0x3070dd17; diff --git a/cipher/sha512.c b/cipher/sha512.c index 3474694..92b4913 100644 --- a/cipher/sha512.c +++ b/cipher/sha512.c @@ -119,12 +119,14 @@ static unsigned int transform (void *context, const unsigned char *data, size_t nblks); static void -sha512_init (void *context) +sha512_init (void *context, unsigned int flags) { SHA512_CONTEXT *ctx = context; SHA512_STATE *hd = &ctx->state; unsigned int features = _gcry_get_hw_features (); + (void)flags; + hd->h0 = U64_C(0x6a09e667f3bcc908); hd->h1 = U64_C(0xbb67ae8584caa73b); hd->h2 = U64_C(0x3c6ef372fe94f82b); @@ -157,12 +159,14 @@ sha512_init (void *context) } static void -sha384_init (void *context) +sha384_init (void *context, unsigned int flags) { SHA512_CONTEXT *ctx = context; SHA512_STATE *hd = &ctx->state; unsigned int features = _gcry_get_hw_features (); + (void)flags; + hd->h0 = U64_C(0xcbbb9d5dc1059ed8); hd->h1 = U64_C(0x629a292a367cd507); hd->h2 = U64_C(0x9159015a3070dd17); diff --git a/cipher/stribog.c b/cipher/stribog.c index 6d1d342..942bbf4 100644 --- a/cipher/stribog.c +++ b/cipher/stribog.c @@ -1198,10 +1198,12 @@ transform (void *context, const unsigned char *inbuf_arg, size_t datalen); static void -stribog_init_512 (void *context) +stribog_init_512 (void *context, unsigned int flags) { STRIBOG_CONTEXT *hd = context; + (void)flags; + memset (hd, 0, sizeof (*hd)); hd->bctx.blocksize = 64; @@ -1209,10 +1211,11 @@ stribog_init_512 (void *context) } static void -stribog_init_256 (void *context) +stribog_init_256 (void *context, unsigned int flags) { STRIBOG_CONTEXT *hd = context; - stribog_init_512 (context); + + stribog_init_512 (context, flags); memset (hd->h, 1, 64); } diff --git a/cipher/whirlpool.c b/cipher/whirlpool.c index 57ca882..ffc6662 100644 --- a/cipher/whirlpool.c +++ b/cipher/whirlpool.c @@ -54,6 +54,11 @@ typedef u64 whirlpool_block_t[BLOCK_SIZE / 8]; typedef struct { gcry_md_block_ctx_t bctx; whirlpool_block_t hash_state; + int use_bugemu; + struct { + size_t count; + unsigned char length[32]; + } bugemu; } whirlpool_context_t; @@ -1166,7 +1171,7 @@ whirlpool_transform (void *ctx, const unsigned char *data, size_t nblks); static void -whirlpool_init (void *ctx) +whirlpool_init (void *ctx, unsigned int flags) { whirlpool_context_t *context = ctx; @@ -1174,9 +1179,17 @@ whirlpool_init (void *ctx) context->bctx.blocksize = BLOCK_SIZE; context->bctx.bwrite = whirlpool_transform; + if ((flags & GCRY_MD_FLAG_BUGEMU1)) + { + memset (&context->bugemu, 0, sizeof context->bugemu); + context->use_bugemu = 1; + } + else + context->use_bugemu = 0; } + /* * Transform block. */ @@ -1295,15 +1308,120 @@ whirlpool_transform ( void *c, const unsigned char *data, size_t nblks ) return burn; } + +/* Bug compatibility Whirlpool version. */ +static void +whirlpool_add_bugemu (whirlpool_context_t *context, + const void *buffer_arg, size_t buffer_n) +{ + const unsigned char *buffer = buffer_arg; + u64 buffer_size; + unsigned int carry; + unsigned int i; + + buffer_size = buffer_n; + + if (context->bugemu.count == BLOCK_SIZE) + { + /* Flush the buffer. */ + whirlpool_transform (context, context->bctx.buf, 1); + context->bugemu.count = 0; + } + if (! buffer) + return; /* Nothing to add. */ + + if (context->bugemu.count) + { + while (buffer_n && (context->bugemu.count < BLOCK_SIZE)) + { + context->bctx.buf[context->bugemu.count++] = *buffer++; + buffer_n--; + } + whirlpool_add_bugemu (context, NULL, 0); + if (!buffer_n) + return; /* Done. This is the bug we emulate. */ + } + + while (buffer_n >= BLOCK_SIZE) + { + whirlpool_transform (context, buffer, 1); + context->bugemu.count = 0; + buffer_n -= BLOCK_SIZE; + buffer += BLOCK_SIZE; + } + while (buffer_n && (context->bugemu.count < BLOCK_SIZE)) + { + context->bctx.buf[context->bugemu.count++] = *buffer++; + buffer_n--; + } + + /* Update bit counter. */ + carry = 0; + buffer_size <<= 3; + for (i = 1; i <= 32; i++) + { + if (! (buffer_size || carry)) + break; + + carry += context->bugemu.length[32 - i] + (buffer_size & 0xFF); + context->bugemu.length[32 - i] = carry; + buffer_size >>= 8; + carry >>= 8; + } + gcry_assert (! (buffer_size || carry)); +} + + +/* Bug compatibility Whirlpool version. */ +static void +whirlpool_final_bugemu (void *ctx) +{ + whirlpool_context_t *context = ctx; + unsigned int i; + + /* Flush. */ + whirlpool_add_bugemu (context, NULL, 0); + + /* Pad. */ + context->bctx.buf[context->bugemu.count++] = 0x80; + + if (context->bugemu.count > 32) + { + /* An extra block is necessary. */ + while (context->bugemu.count < 64) + context->bctx.buf[context->bugemu.count++] = 0; + whirlpool_add_bugemu (context, NULL, 0); + } + while (context->bugemu.count < 32) + context->bctx.buf[context->bugemu.count++] = 0; + + /* Add length of message. */ + memcpy (context->bctx.buf + context->bugemu.count, + context->bugemu.length, 32); + context->bugemu.count += 32; + whirlpool_add_bugemu (context, NULL, 0); + + block_to_buffer (context->bctx.buf, context->hash_state, i); +} + + static void whirlpool_write (void *ctx, const void *buffer, size_t buffer_n) { whirlpool_context_t *context = ctx; - u64 old_nblocks = context->bctx.nblocks; - _gcry_md_block_write (context, buffer, buffer_n); + if (context->use_bugemu) + { + whirlpool_add_bugemu (context, buffer, buffer_n); + } + else + { + u64 old_nblocks = context->bctx.nblocks; + + _gcry_md_block_write (context, buffer, buffer_n); - gcry_assert (old_nblocks <= context->bctx.nblocks); + gcry_assert (old_nblocks <= context->bctx.nblocks); + } } static void @@ -1314,6 +1432,12 @@ whirlpool_final (void *ctx) u64 t, th, lsb, msb; unsigned char *length; + if (context->use_bugemu) + { + whirlpool_final_bugemu (ctx); + return; + } + t = context->bctx.nblocks; /* if (sizeof t == sizeof context->bctx.nblocks) */ th = context->bctx.nblocks_high; diff --git a/doc/gcrypt.texi b/doc/gcrypt.texi index 7712b80..4a91790 100644 --- a/doc/gcrypt.texi +++ b/doc/gcrypt.texi @@ -3111,6 +3111,22 @@ The size of the MAC is equal to the message digest of the underlying hash algorithm. If you want CBC message authentication codes based on a cipher, see @xref{Working with cipher handles}. + at item GCRY_MD_FLAG_BUGEMU1 + at cindex bug emulation +Versions of Libgcrypt before 1.6.0 had a bug in the Whirlpool code +which led to a wrong result for certain input sizes and write +patterns. Using this flag emulates that bug. This may for example be +useful for applications which use Whirlpool as part of their key +generation. It is strongly suggested to use this flag only if really +needed and if possible to the data should be re-processed using the +regular Whirlpool algorithm. + +Note that this flag works for the entire hash context. If needed +arises it may be used to enable bug emulation for other hash +algorithms. Thus you should not use this flag for a multi-algorithm +hash context. + + @end table @c begin table of hash flags diff --git a/src/cipher-proto.h b/src/cipher-proto.h index 0955ef5..8267791 100644 --- a/src/cipher-proto.h +++ b/src/cipher-proto.h @@ -204,7 +204,7 @@ typedef struct gcry_cipher_spec */ /* Type for the md_init function. */ -typedef void (*gcry_md_init_t) (void *c); +typedef void (*gcry_md_init_t) (void *c, unsigned int flags); /* Type for the md_write function. */ typedef void (*gcry_md_write_t) (void *c, const void *buf, size_t nbytes); diff --git a/src/gcrypt.h.in b/src/gcrypt.h.in index f8318c0..b06f259 100644 --- a/src/gcrypt.h.in +++ b/src/gcrypt.h.in @@ -1151,7 +1151,8 @@ enum gcry_md_algos enum gcry_md_flags { GCRY_MD_FLAG_SECURE = 1, /* Allocate all buffers in "secure" memory. */ - GCRY_MD_FLAG_HMAC = 2 /* Make an HMAC out of this algorithm. */ + GCRY_MD_FLAG_HMAC = 2, /* Make an HMAC out of this algorithm. */ + GCRY_MD_FLAG_BUGEMU1 = 0x0100 }; /* (Forward declaration.) */ diff --git a/tests/basic.c b/tests/basic.c index 697485e..5fd7131 100644 --- a/tests/basic.c +++ b/tests/basic.c @@ -4046,6 +4046,7 @@ check_digests (void) #endif { 0 } }; + gcry_error_t err; int i; if (verbose) @@ -4074,6 +4075,58 @@ check_digests (void) algos[i].expect); } + /* Check the Whirlpool bug emulation. */ + if (!gcry_md_test_algo (GCRY_MD_WHIRLPOOL) && !in_fips_mode) + { + static const char expect[] = + "\x35\x28\xd6\x4c\x56\x2c\x55\x2e\x3b\x91\x93\x95\x7b\xdd\xcc\x6e" + "\x6f\xb7\xbf\x76\x22\x9c\xc6\x23\xda\x3e\x09\x9b\x36\xe8\x6d\x76" + "\x2f\x94\x3b\x0c\x63\xa0\xba\xa3\x4d\x66\x71\xe6\x5d\x26\x67\x28" + "\x36\x1f\x0e\x1a\x40\xf0\xce\x83\x50\x90\x1f\xfa\x3f\xed\x6f\xfd"; + gcry_md_hd_t hd; + int algo = GCRY_MD_WHIRLPOOL; + unsigned char *p; + int mdlen; + + err = gcry_md_open (&hd, GCRY_MD_WHIRLPOOL, GCRY_MD_FLAG_BUGEMU1); + if (err) + { + fail ("algo %d, gcry_md_open failed: %s\n", algo, gpg_strerror (err)); + goto leave; + } + + mdlen = gcry_md_get_algo_dlen (algo); + if (mdlen < 1 || mdlen > 500) + { + fail ("algo %d, gcry_md_get_algo_dlen failed: %d\n", algo, mdlen); + gcry_md_close (hd); + goto leave; + } + + /* Hash 62 byes in chunks. */ + gcry_md_write (hd, "1234567890", 10); + gcry_md_write (hd, "1234567890123456789012345678901234567890123456789012", + 52); + + p = gcry_md_read (hd, algo); + + if (memcmp (p, expect, mdlen)) + { + printf ("computed: "); + for (i = 0; i < mdlen; i++) + printf ("%02x ", p[i] & 0xFF); + printf ("\nexpected: "); + for (i = 0; i < mdlen; i++) + printf ("%02x ", expect[i] & 0xFF); + printf ("\n"); + + fail ("algo %d, digest mismatch\n", algo); + } + + gcry_md_close (hd); + } + + leave: if (verbose) fprintf (stderr, "Completed hash checks.\n"); } commit c3b30bae7d1e157f8b65e32ba1b3a516f2bbf58b Author: Werner Koch Date: Thu Jan 9 19:14:09 2014 +0100 Actually check for uint64_t. * configure.ac: Check size of uint64_t and the UINT64_C macro. -- configure.ac used $ac_cv_sizeof_uint64_t but never set this variable. Due to the availability of long long on all platforms supporting uint64_t this was not a real problem. Found while remove the corresponding test from gnupg. Signed-off-by: Werner Koch diff --git a/configure.ac b/configure.ac index 6272871..c3ab96f 100644 --- a/configure.ac +++ b/configure.ac @@ -350,6 +350,15 @@ if test "$ac_cv_sizeof_unsigned_short" = "0" \ AC_MSG_WARN([Hmmm, something is wrong with the sizes - using defaults]); fi +# Ensure that we have UINT64_C before we bother to check for uint64_t +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 + # Do we have any 64-bit data types? if test "$ac_cv_sizeof_unsigned_int" != "8" \ && test "$ac_cv_sizeof_unsigned_long" != "8" \ ----------------------------------------------------------------------- Summary of changes: NEWS | 3 ++ cipher/crc.c | 15 ++++-- cipher/gostr3411-94.c | 4 +- cipher/md.c | 56 ++++++++++++--------- cipher/md4.c | 4 +- cipher/md5.c | 4 +- cipher/rmd160.c | 14 ++++-- cipher/sha1.c | 8 +-- cipher/sha256.c | 8 ++- cipher/sha512.c | 8 ++- cipher/stribog.c | 9 ++-- cipher/whirlpool.c | 132 +++++++++++++++++++++++++++++++++++++++++++++++-- configure.ac | 9 ++++ doc/gcrypt.texi | 16 ++++++ src/cipher-proto.h | 2 +- src/gcrypt.h.in | 3 +- tests/basic.c | 53 ++++++++++++++++++++ 17 files changed, 300 insertions(+), 48 deletions(-) hooks/post-receive -- The GNU crypto library http://git.gnupg.org From cvs at cvs.gnupg.org Mon Jan 20 10:08:23 2014 From: cvs at cvs.gnupg.org (by Werner Koch) Date: Mon, 20 Jan 2014 10:08:23 +0100 Subject: [git] GCRYPT - branch, LIBGCRYPT-1-6-BRANCH, updated. libgcrypt-1.6.0-11-g77f2879 Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The GNU crypto library". The branch, LIBGCRYPT-1-6-BRANCH has been updated via 77f28793481d1f41755242377164e4caaa1d106d (commit) from ead3a097a9ee5908e562e6ec683707c38191acf3 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 77f28793481d1f41755242377164e4caaa1d106d Author: Werner Koch Date: Thu Jan 9 19:14:09 2014 +0100 md: Add Whirlpool bug emulation feature. * src/gcrypt.h.in (GCRY_MD_FLAG_BUGEMU1): New. * src/cipher-proto.h (gcry_md_init_t): Add arg FLAGS. Change all code to implement that flag. * cipher/md.c (gcry_md_context): Replace SECURE and FINALIZED by bit field FLAGS. Add flag BUGEMU1. Change all users. (md_open): Replace args SECURE and HMAC by FLAGS. Init flags.bugemu1. (_gcry_md_open): Add for GCRY_MD_FLAG_BUGEMU1. (md_enable): Pass bugemu1 flag to the hash init function. (_gcry_md_reset): Ditto. -- This problem is for example exhibited in the Linux cryptsetup tool. See https://bbs.archlinux.org/viewtopic.php?id=175737 . It has been tracked down by Milan Broz. The suggested way of using the flag is: if (whirlpool_bug_assumed) { #if GCRYPT_VERSION_NUMBER >= 0x010601 err = gcry_md_open (&hd, GCRY_MD_WHIRLPOOL, GCRY_MD_FLAG_BUGEMU1) if (gpg_err_code (err) == GPG_ERR_INV_ARG) error ("Need at least Libggcrypt 1.6.1 for the fix"); else { do_hash (hd); gcry_md_close (hd); } #endif } Signed-off-by: Werner Koch (cherry picked from commit 94030e44aaff805d754e368507f16dd51a531b72) Reolved conflicts: NEWS cipher/whirlpool.c: Remove NBLOCKS arg from whirlpool_transform. diff --git a/NEWS b/NEWS index 97fb089..9c3df10 100644 --- a/NEWS +++ b/NEWS @@ -6,6 +6,12 @@ Noteworthy changes in version 1.6.1 (unreleased) * Fix build problem on NetBSD. + * Add emulation for broken Whirlpool code prior to 1.6.0. + + * Interface changes relative to the 1.6.0 release: + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + GCRY_MD_FLAG_BUGEMU1 NEW. + Noteworthy changes in version 1.6.0 (2013-12-16) ------------------------------------------------ diff --git a/cipher/crc.c b/cipher/crc.c index 4f72ffb..1322f0d 100644 --- a/cipher/crc.c +++ b/cipher/crc.c @@ -149,9 +149,12 @@ CRC_CONTEXT; /* CRC32 */ static void -crc32_init (void *context) +crc32_init (void *context, unsigned int flags) { CRC_CONTEXT *ctx = (CRC_CONTEXT *) context; + + (void)flags; + ctx->CRC = 0 ^ 0xffffffffL; } @@ -184,9 +187,12 @@ crc32_final (void *context) /* CRC32 a'la RFC 1510 */ static void -crc32rfc1510_init (void *context) +crc32rfc1510_init (void *context, unsigned int flags) { CRC_CONTEXT *ctx = (CRC_CONTEXT *) context; + + (void)flags; + ctx->CRC = 0; } @@ -237,9 +243,12 @@ crc32rfc1510_final (void *context) #define CRC24_POLY 0x1864cfbL static void -crc24rfc2440_init (void *context) +crc24rfc2440_init (void *context, unsigned int flags) { CRC_CONTEXT *ctx = (CRC_CONTEXT *) context; + + (void)flags; + ctx->CRC = CRC24_INIT; } diff --git a/cipher/gostr3411-94.c b/cipher/gostr3411-94.c index 1267216..5486964 100644 --- a/cipher/gostr3411-94.c +++ b/cipher/gostr3411-94.c @@ -44,10 +44,12 @@ static unsigned int transform (void *c, const unsigned char *data); static void -gost3411_init (void *context) +gost3411_init (void *context, unsigned int flags) { GOSTR3411_CONTEXT *hd = context; + (void)flags; + memset (&hd->hd, 0, sizeof(hd->hd)); memset (hd->h, 0, 32); memset (hd->sigma, 0, 32); diff --git a/cipher/md.c b/cipher/md.c index 1b59765..22da30a 100644 --- a/cipher/md.c +++ b/cipher/md.c @@ -1,7 +1,7 @@ /* md.c - message digest dispatcher * Copyright (C) 1998, 1999, 2002, 2003, 2006, * 2008 Free Software Foundation, Inc. - * Copyright (C) 2013 g10 Code GmbH + * Copyright (C) 2013, 2014 g10 Code GmbH * * This file is part of Libgcrypt. * @@ -94,9 +94,12 @@ struct gcry_md_context { int magic; size_t actual_handle_size; /* Allocated size of this handle. */ - int secure; FILE *debug; - int finalized; + struct { + unsigned int secure: 1; + unsigned int finalized:1; + unsigned int bugemu1:1; + } flags; GcryDigestEntry *list; byte *macpads; int macpads_Bsize; /* Blocksize as used for the HMAC pads. */ @@ -270,9 +273,11 @@ check_digest_algo (int algorithm) * may be 0. */ static gcry_err_code_t -md_open (gcry_md_hd_t *h, int algo, int secure, int hmac) +md_open (gcry_md_hd_t *h, int algo, unsigned int flags) { - gcry_err_code_t err = GPG_ERR_NO_ERROR; + gcry_err_code_t err = 0; + int secure = !!(flags & GCRY_MD_FLAG_SECURE); + int hmac = !!(flags & GCRY_MD_FLAG_HMAC); int bufsize = secure ? 512 : 1024; struct gcry_md_context *ctx; gcry_md_hd_t hd; @@ -316,7 +321,8 @@ md_open (gcry_md_hd_t *h, int algo, int secure, int hmac) memset (hd->ctx, 0, sizeof *hd->ctx); ctx->magic = secure ? CTX_MAGIC_SECURE : CTX_MAGIC_NORMAL; ctx->actual_handle_size = n + sizeof (struct gcry_md_context); - ctx->secure = secure; + ctx->flags.secure = secure; + ctx->flags.bugemu1 = !!(flags & GCRY_MD_FLAG_BUGEMU1); if (hmac) { @@ -372,13 +378,12 @@ _gcry_md_open (gcry_md_hd_t *h, int algo, unsigned int flags) gcry_err_code_t rc; gcry_md_hd_t hd; - if ((flags & ~(GCRY_MD_FLAG_SECURE | GCRY_MD_FLAG_HMAC))) + if ((flags & ~(GCRY_MD_FLAG_SECURE + | GCRY_MD_FLAG_HMAC + | GCRY_MD_FLAG_BUGEMU1))) rc = GPG_ERR_INV_ARG; else - { - rc = md_open (&hd, algo, (flags & GCRY_MD_FLAG_SECURE), - (flags & GCRY_MD_FLAG_HMAC)); - } + rc = md_open (&hd, algo, flags); *h = rc? NULL : hd; return rc; @@ -424,7 +429,7 @@ md_enable (gcry_md_hd_t hd, int algorithm) - sizeof (entry->context)); /* And allocate a new list entry. */ - if (h->secure) + if (h->flags.secure) entry = xtrymalloc_secure (size); else entry = xtrymalloc (size); @@ -439,7 +444,8 @@ md_enable (gcry_md_hd_t hd, int algorithm) h->list = entry; /* And init this instance. */ - entry->spec->init (&entry->context.c); + entry->spec->init (&entry->context.c, + h->flags.bugemu1? GCRY_MD_FLAG_BUGEMU1:0); } } @@ -468,7 +474,7 @@ md_copy (gcry_md_hd_t ahd, gcry_md_hd_t *b_hd) md_write (ahd, NULL, 0); n = (char *) ahd->ctx - (char *) ahd; - if (a->secure) + if (a->flags.secure) bhd = xtrymalloc_secure (n + sizeof (struct gcry_md_context)); else bhd = xtrymalloc (n + sizeof (struct gcry_md_context)); @@ -506,7 +512,7 @@ md_copy (gcry_md_hd_t ahd, gcry_md_hd_t *b_hd) { for (ar = a->list; ar; ar = ar->next) { - if (a->secure) + if (a->flags.secure) br = xtrymalloc_secure (sizeof *br + ar->spec->contextsize - sizeof(ar->context)); @@ -561,12 +567,13 @@ _gcry_md_reset (gcry_md_hd_t a) /* Note: We allow this even in fips non operational mode. */ - a->bufpos = a->ctx->finalized = 0; + a->bufpos = a->ctx->flags.finalized = 0; for (r = a->ctx->list; r; r = r->next) { memset (r->context.c, 0, r->spec->contextsize); - (*r->spec->init) (&r->context.c); + (*r->spec->init) (&r->context.c, + a->ctx->flags.bugemu1? GCRY_MD_FLAG_BUGEMU1:0); } if (a->ctx->macpads) md_write (a, a->ctx->macpads, a->ctx->macpads_Bsize); /* inner pad */ @@ -643,7 +650,7 @@ md_final (gcry_md_hd_t a) { GcryDigestEntry *r; - if (a->ctx->finalized) + if (a->ctx->flags.finalized) return; if (a->bufpos) @@ -652,7 +659,7 @@ md_final (gcry_md_hd_t a) for (r = a->ctx->list; r; r = r->next) (*r->spec->final) (&r->context.c); - a->ctx->finalized = 1; + a->ctx->flags.finalized = 1; if (a->ctx->macpads) { @@ -661,8 +668,11 @@ md_final (gcry_md_hd_t a) byte *p = md_read (a, algo); size_t dlen = md_digest_length (algo); gcry_md_hd_t om; - gcry_err_code_t err = md_open (&om, algo, a->ctx->secure, 0); + gcry_err_code_t err; + err = md_open (&om, algo, + ((a->ctx->flags.secure? GCRY_MD_FLAG_SECURE:0) + | (a->ctx->flags.bugemu1? GCRY_MD_FLAG_BUGEMU1:0))); if (err) _gcry_fatal_error (err, NULL); md_write (om, @@ -865,7 +875,7 @@ _gcry_md_hash_buffer (int algo, void *digest, } } - err = md_open (&h, algo, 0, 0); + err = md_open (&h, algo, 0); if (err) log_bug ("gcry_md_open failed for algo %d: %s", algo, gpg_strerror (gcry_error(err))); @@ -926,7 +936,7 @@ _gcry_md_hash_buffers (int algo, unsigned int flags, void *digest, } } - rc = md_open (&h, algo, 0, hmac); + rc = md_open (&h, algo, (hmac? GCRY_MD_FLAG_HMAC:0)); if (rc) return rc; @@ -1159,7 +1169,7 @@ _gcry_md_info (gcry_md_hd_t h, int cmd, void *buffer, size_t *nbytes) switch (cmd) { case GCRYCTL_IS_SECURE: - *nbytes = h->ctx->secure; + *nbytes = h->ctx->flags.secure; break; case GCRYCTL_IS_ALGO_ENABLED: diff --git a/cipher/md4.c b/cipher/md4.c index b9a1a95..624ae99 100644 --- a/cipher/md4.c +++ b/cipher/md4.c @@ -69,10 +69,12 @@ static unsigned int transform ( void *c, const unsigned char *data ); static void -md4_init( void *context ) +md4_init (void *context, unsigned int flags) { MD4_CONTEXT *ctx = context; + (void)flags; + ctx->A = 0x67452301; ctx->B = 0xefcdab89; ctx->C = 0x98badcfe; diff --git a/cipher/md5.c b/cipher/md5.c index 79b6e87..b0187c9 100644 --- a/cipher/md5.c +++ b/cipher/md5.c @@ -53,10 +53,12 @@ static unsigned int transform ( void *ctx, const unsigned char *data ); static void -md5_init( void *context ) +md5_init( void *context, unsigned int flags) { MD5_CONTEXT *ctx = context; + (void)flags; + ctx->A = 0x67452301; ctx->B = 0xefcdab89; ctx->C = 0x98badcfe; diff --git a/cipher/rmd160.c b/cipher/rmd160.c index a6d9a80..08e8cb0 100644 --- a/cipher/rmd160.c +++ b/cipher/rmd160.c @@ -143,11 +143,13 @@ static unsigned int transform ( void *ctx, const unsigned char *data ); -void -_gcry_rmd160_init (void *context) +static void +rmd160_init (void *context, unsigned int flags) { RMD160_CONTEXT *hd = context; + (void)flags; + hd->h0 = 0x67452301; hd->h1 = 0xEFCDAB89; hd->h2 = 0x98BADCFE; @@ -162,6 +164,12 @@ _gcry_rmd160_init (void *context) } +void +_gcry_rmd160_init (void *context) +{ + rmd160_init (context, 0); +} + /**************** * Transform the message X which consists of 16 32-bit-words @@ -512,6 +520,6 @@ gcry_md_spec_t _gcry_digest_spec_rmd160 = { GCRY_MD_RMD160, {0, 0}, "RIPEMD160", asn, DIM (asn), oid_spec_rmd160, 20, - _gcry_rmd160_init, _gcry_md_block_write, rmd160_final, rmd160_read, + rmd160_init, _gcry_md_block_write, rmd160_final, rmd160_read, sizeof (RMD160_CONTEXT) }; diff --git a/cipher/sha1.c b/cipher/sha1.c index 18b6daa..2e0b030 100644 --- a/cipher/sha1.c +++ b/cipher/sha1.c @@ -74,10 +74,12 @@ transform (void *c, const unsigned char *data); static void -sha1_init (void *context) +sha1_init (void *context, unsigned int flags) { SHA1_CONTEXT *hd = context; + (void)flags; + hd->h0 = 0x67452301; hd->h1 = 0xefcdab89; hd->h2 = 0x98badcfe; @@ -337,7 +339,7 @@ _gcry_sha1_hash_buffer (void *outbuf, const void *buffer, size_t length) { SHA1_CONTEXT hd; - sha1_init (&hd); + sha1_init (&hd, 0); _gcry_md_block_write (&hd, buffer, length); sha1_final (&hd); memcpy (outbuf, hd.bctx.buf, 20); @@ -350,7 +352,7 @@ _gcry_sha1_hash_buffers (void *outbuf, const gcry_buffer_t *iov, int iovcnt) { SHA1_CONTEXT hd; - sha1_init (&hd); + sha1_init (&hd, 0); for (;iovcnt > 0; iov++, iovcnt--) _gcry_md_block_write (&hd, (const char*)iov[0].data + iov[0].off, iov[0].len); diff --git a/cipher/sha256.c b/cipher/sha256.c index f3c1d62..d92303c 100644 --- a/cipher/sha256.c +++ b/cipher/sha256.c @@ -70,10 +70,12 @@ transform (void *c, const unsigned char *data); static void -sha256_init (void *context) +sha256_init (void *context, unsigned int flags) { SHA256_CONTEXT *hd = context; + (void)flags; + hd->h0 = 0x6a09e667; hd->h1 = 0xbb67ae85; hd->h2 = 0x3c6ef372; @@ -96,10 +98,12 @@ sha256_init (void *context) static void -sha224_init (void *context) +sha224_init (void *context, unsigned int flags) { SHA256_CONTEXT *hd = context; + (void)flags; + hd->h0 = 0xc1059ed8; hd->h1 = 0x367cd507; hd->h2 = 0x3070dd17; diff --git a/cipher/sha512.c b/cipher/sha512.c index 586c809..26ed031 100644 --- a/cipher/sha512.c +++ b/cipher/sha512.c @@ -119,12 +119,14 @@ static unsigned int transform (void *context, const unsigned char *data); static void -sha512_init (void *context) +sha512_init (void *context, unsigned int flags) { SHA512_CONTEXT *ctx = context; SHA512_STATE *hd = &ctx->state; unsigned int features = _gcry_get_hw_features (); + (void)flags; + hd->h0 = U64_C(0x6a09e667f3bcc908); hd->h1 = U64_C(0xbb67ae8584caa73b); hd->h2 = U64_C(0x3c6ef372fe94f82b); @@ -157,12 +159,14 @@ sha512_init (void *context) } static void -sha384_init (void *context) +sha384_init (void *context, unsigned int flags) { SHA512_CONTEXT *ctx = context; SHA512_STATE *hd = &ctx->state; unsigned int features = _gcry_get_hw_features (); + (void)flags; + hd->h0 = U64_C(0xcbbb9d5dc1059ed8); hd->h1 = U64_C(0x629a292a367cd507); hd->h2 = U64_C(0x9159015a3070dd17); diff --git a/cipher/stribog.c b/cipher/stribog.c index a3cab36..297b64a 100644 --- a/cipher/stribog.c +++ b/cipher/stribog.c @@ -1198,10 +1198,12 @@ transform64 (void *context, const unsigned char *inbuf_arg); static void -stribog_init_512 (void *context) +stribog_init_512 (void *context, unsigned int flags) { STRIBOG_CONTEXT *hd = context; + (void)flags; + memset (hd, 0, sizeof (*hd)); hd->bctx.blocksize = 64; @@ -1209,10 +1211,11 @@ stribog_init_512 (void *context) } static void -stribog_init_256 (void *context) +stribog_init_256 (void *context, unsigned int flags) { STRIBOG_CONTEXT *hd = context; - stribog_init_512 (context); + + stribog_init_512 (context, flags); memset (hd->h, 1, 64); } diff --git a/cipher/whirlpool.c b/cipher/whirlpool.c index e562781..338d44e 100644 --- a/cipher/whirlpool.c +++ b/cipher/whirlpool.c @@ -46,7 +46,7 @@ /* Number of rounds. */ #define R 10 - + /* Types. */ typedef u64 whirlpool_block_t[BLOCK_SIZE / 8]; @@ -54,6 +54,11 @@ typedef u64 whirlpool_block_t[BLOCK_SIZE / 8]; typedef struct { gcry_md_block_ctx_t bctx; whirlpool_block_t hash_state; + int use_bugemu; + struct { + size_t count; + unsigned char length[32]; + } bugemu; } whirlpool_context_t; @@ -1158,25 +1163,8 @@ static const u64 C7[256] = U64_C (0xf8c7f8933fed6bf8), U64_C (0x86228644a411c286), }; - - -static unsigned int -whirlpool_transform (void *ctx, const unsigned char *data); - -static void -whirlpool_init (void *ctx) -{ - whirlpool_context_t *context = ctx; - - memset (context, 0, sizeof (*context)); - - context->bctx.blocksize = BLOCK_SIZE; - context->bctx.bwrite = whirlpool_transform; -} - - /* * Transform block. */ @@ -1280,15 +1268,139 @@ whirlpool_transform (void *ctx, const unsigned char *data) 4 * sizeof(void*); } + +static void +whirlpool_init (void *ctx, unsigned int flags) +{ + whirlpool_context_t *context = ctx; + + memset (context, 0, sizeof (*context)); + + context->bctx.blocksize = BLOCK_SIZE; + context->bctx.bwrite = whirlpool_transform; + if ((flags & GCRY_MD_FLAG_BUGEMU1)) + { + memset (&context->bugemu, 0, sizeof context->bugemu); + context->use_bugemu = 1; + } + else + context->use_bugemu = 0; +} + + +/* Bug compatibility Whirlpool version. */ +static void +whirlpool_add_bugemu (whirlpool_context_t *context, + const void *buffer_arg, size_t buffer_n) +{ + const unsigned char *buffer = buffer_arg; + u64 buffer_size; + unsigned int carry; + unsigned int i; + + buffer_size = buffer_n; + + if (context->bugemu.count == BLOCK_SIZE) + { + /* Flush the buffer. */ + whirlpool_transform (context, context->bctx.buf); + context->bugemu.count = 0; + } + if (! buffer) + return; /* Nothing to add. */ + + if (context->bugemu.count) + { + while (buffer_n && (context->bugemu.count < BLOCK_SIZE)) + { + context->bctx.buf[context->bugemu.count++] = *buffer++; + buffer_n--; + } + whirlpool_add_bugemu (context, NULL, 0); + if (!buffer_n) + return; /* Done. This is the bug we emulate. */ + } + + while (buffer_n >= BLOCK_SIZE) + { + whirlpool_transform (context, buffer); + context->bugemu.count = 0; + buffer_n -= BLOCK_SIZE; + buffer += BLOCK_SIZE; + } + while (buffer_n && (context->bugemu.count < BLOCK_SIZE)) + { + context->bctx.buf[context->bugemu.count++] = *buffer++; + buffer_n--; + } + + /* Update bit counter. */ + carry = 0; + buffer_size <<= 3; + for (i = 1; i <= 32; i++) + { + if (! (buffer_size || carry)) + break; + + carry += context->bugemu.length[32 - i] + (buffer_size & 0xFF); + context->bugemu.length[32 - i] = carry; + buffer_size >>= 8; + carry >>= 8; + } + gcry_assert (! (buffer_size || carry)); +} + + +/* Bug compatibility Whirlpool version. */ +static void +whirlpool_final_bugemu (void *ctx) +{ + whirlpool_context_t *context = ctx; + unsigned int i; + + /* Flush. */ + whirlpool_add_bugemu (context, NULL, 0); + + /* Pad. */ + context->bctx.buf[context->bugemu.count++] = 0x80; + + if (context->bugemu.count > 32) + { + /* An extra block is necessary. */ + while (context->bugemu.count < 64) + context->bctx.buf[context->bugemu.count++] = 0; + whirlpool_add_bugemu (context, NULL, 0); + } + while (context->bugemu.count < 32) + context->bctx.buf[context->bugemu.count++] = 0; + + /* Add length of message. */ + memcpy (context->bctx.buf + context->bugemu.count, + context->bugemu.length, 32); + context->bugemu.count += 32; + whirlpool_add_bugemu (context, NULL, 0); + + block_to_buffer (context->bctx.buf, context->hash_state, i); +} + + static void whirlpool_write (void *ctx, const void *buffer, size_t buffer_n) { whirlpool_context_t *context = ctx; - u64 old_nblocks = context->bctx.nblocks; - _gcry_md_block_write (context, buffer, buffer_n); + if (context->use_bugemu) + { + whirlpool_add_bugemu (context, buffer, buffer_n); + } + else + { + u64 old_nblocks = context->bctx.nblocks; + + _gcry_md_block_write (context, buffer, buffer_n); - gcry_assert (old_nblocks <= context->bctx.nblocks); + gcry_assert (old_nblocks <= context->bctx.nblocks); + } } static void @@ -1299,6 +1411,12 @@ whirlpool_final (void *ctx) u64 t, th, lsb, msb; unsigned char *length; + if (context->use_bugemu) + { + whirlpool_final_bugemu (ctx); + return; + } + t = context->bctx.nblocks; /* if (sizeof t == sizeof context->bctx.nblocks) */ th = context->bctx.nblocks_high; diff --git a/doc/gcrypt.texi b/doc/gcrypt.texi index 7af1706..c2534a2 100644 --- a/doc/gcrypt.texi +++ b/doc/gcrypt.texi @@ -3194,6 +3194,22 @@ The size of the MAC is equal to the message digest of the underlying hash algorithm. If you want CBC message authentication codes based on a cipher, see @xref{Working with cipher handles}. + at item GCRY_MD_FLAG_BUGEMU1 + at cindex bug emulation +Versions of Libgcrypt before 1.6.0 had a bug in the Whirlpool code +which led to a wrong result for certain input sizes and write +patterns. Using this flag emulates that bug. This may for example be +useful for applications which use Whirlpool as part of their key +generation. It is strongly suggested to use this flag only if really +needed and if possible to the data should be re-processed using the +regular Whirlpool algorithm. + +Note that this flag works for the entire hash context. If needed +arises it may be used to enable bug emulation for other hash +algorithms. Thus you should not use this flag for a multi-algorithm +hash context. + + @end table @c begin table of hash flags diff --git a/src/cipher-proto.h b/src/cipher-proto.h index 0955ef5..8267791 100644 --- a/src/cipher-proto.h +++ b/src/cipher-proto.h @@ -204,7 +204,7 @@ typedef struct gcry_cipher_spec */ /* Type for the md_init function. */ -typedef void (*gcry_md_init_t) (void *c); +typedef void (*gcry_md_init_t) (void *c, unsigned int flags); /* Type for the md_write function. */ typedef void (*gcry_md_write_t) (void *c, const void *buf, size_t nbytes); diff --git a/src/gcrypt.h.in b/src/gcrypt.h.in index 5c771e5..9e94e87 100644 --- a/src/gcrypt.h.in +++ b/src/gcrypt.h.in @@ -1151,7 +1151,8 @@ enum gcry_md_algos enum gcry_md_flags { GCRY_MD_FLAG_SECURE = 1, /* Allocate all buffers in "secure" memory. */ - GCRY_MD_FLAG_HMAC = 2 /* Make an HMAC out of this algorithm. */ + GCRY_MD_FLAG_HMAC = 2, /* Make an HMAC out of this algorithm. */ + GCRY_MD_FLAG_BUGEMU1 = 0x0100 }; /* (Forward declaration.) */ diff --git a/tests/basic.c b/tests/basic.c index 0eb8215..97276d0 100644 --- a/tests/basic.c +++ b/tests/basic.c @@ -4046,6 +4046,7 @@ check_digests (void) #endif { 0 } }; + gcry_error_t err; int i; if (verbose) @@ -4074,6 +4075,58 @@ check_digests (void) algos[i].expect); } + /* Check the Whirlpool bug emulation. */ + if (!gcry_md_test_algo (GCRY_MD_WHIRLPOOL) && !in_fips_mode) + { + static const char expect[] = + "\x35\x28\xd6\x4c\x56\x2c\x55\x2e\x3b\x91\x93\x95\x7b\xdd\xcc\x6e" + "\x6f\xb7\xbf\x76\x22\x9c\xc6\x23\xda\x3e\x09\x9b\x36\xe8\x6d\x76" + "\x2f\x94\x3b\x0c\x63\xa0\xba\xa3\x4d\x66\x71\xe6\x5d\x26\x67\x28" + "\x36\x1f\x0e\x1a\x40\xf0\xce\x83\x50\x90\x1f\xfa\x3f\xed\x6f\xfd"; + gcry_md_hd_t hd; + int algo = GCRY_MD_WHIRLPOOL; + unsigned char *p; + int mdlen; + + err = gcry_md_open (&hd, GCRY_MD_WHIRLPOOL, GCRY_MD_FLAG_BUGEMU1); + if (err) + { + fail ("algo %d, gcry_md_open failed: %s\n", algo, gpg_strerror (err)); + goto leave; + } + + mdlen = gcry_md_get_algo_dlen (algo); + if (mdlen < 1 || mdlen > 500) + { + fail ("algo %d, gcry_md_get_algo_dlen failed: %d\n", algo, mdlen); + gcry_md_close (hd); + goto leave; + } + + /* Hash 62 byes in chunks. */ + gcry_md_write (hd, "1234567890", 10); + gcry_md_write (hd, "1234567890123456789012345678901234567890123456789012", + 52); + + p = gcry_md_read (hd, algo); + + if (memcmp (p, expect, mdlen)) + { + printf ("computed: "); + for (i = 0; i < mdlen; i++) + printf ("%02x ", p[i] & 0xFF); + printf ("\nexpected: "); + for (i = 0; i < mdlen; i++) + printf ("%02x ", expect[i] & 0xFF); + printf ("\n"); + + fail ("algo %d, digest mismatch\n", algo); + } + + gcry_md_close (hd); + } + + leave: if (verbose) fprintf (stderr, "Completed hash checks.\n"); } ----------------------------------------------------------------------- Summary of changes: NEWS | 6 ++ cipher/crc.c | 15 ++++- cipher/gostr3411-94.c | 4 +- cipher/md.c | 56 ++++++++++------- cipher/md4.c | 4 +- cipher/md5.c | 4 +- cipher/rmd160.c | 14 ++++- cipher/sha1.c | 8 ++- cipher/sha256.c | 8 ++- cipher/sha512.c | 8 ++- cipher/stribog.c | 9 ++- cipher/whirlpool.c | 160 ++++++++++++++++++++++++++++++++++++++++++------- doc/gcrypt.texi | 16 +++++ src/cipher-proto.h | 2 +- src/gcrypt.h.in | 3 +- tests/basic.c | 53 ++++++++++++++++ 16 files changed, 305 insertions(+), 65 deletions(-) hooks/post-receive -- The GNU crypto library http://git.gnupg.org From cvs at cvs.gnupg.org Mon Jan 20 11:13:56 2014 From: cvs at cvs.gnupg.org (by Werner Koch) Date: Mon, 20 Jan 2014 11:13:56 +0100 Subject: [git] GCRYPT - branch, master, updated. libgcrypt-1.6.0-39-gdad06e4 Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The GNU crypto library". The branch, master has been updated via dad06e4d1b835bac778b87090b1d3894b7535b14 (commit) via 192e77d123fdb04c459c998b9eb1731618a833fa (commit) from 94030e44aaff805d754e368507f16dd51a531b72 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit dad06e4d1b835bac778b87090b1d3894b7535b14 Author: Werner Koch Date: Thu Jan 9 19:14:09 2014 +0100 cipher: Fix commit 94030e44 * cipher/tiger.c (tiger_init): Add arg FLAGS. (tiger1_init, tiger2_init): Ditto. diff --git a/cipher/tiger.c b/cipher/tiger.c index 17c4119..91db4e6 100644 --- a/cipher/tiger.c +++ b/cipher/tiger.c @@ -610,20 +610,26 @@ do_init (void *context, int variant) } static void -tiger_init (void *context) +tiger_init (void *context, unsigned int flags) { + (void)flags; + do_init (context, 0); } static void -tiger1_init (void *context) +tiger1_init (void *context, unsigned int flags) { + (void)flags; + do_init (context, 1); } static void -tiger2_init (void *context) +tiger2_init (void *context, unsigned int flags) { + (void)flags; + do_init (context, 2); } commit 192e77d123fdb04c459c998b9eb1731618a833fa Author: Werner Koch Date: Thu Jan 9 19:14:09 2014 +0100 tests: Rename tsexp.c * tests/tsexp.c: Rename to t-sexp.c Signed-off-by: Werner Koch diff --git a/tests/Makefile.am b/tests/Makefile.am index f5b5b9f..884fb3d 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -19,7 +19,7 @@ ## Process this file with automake to produce Makefile.in tests_bin = \ - version mpitests tsexp t-convert \ + version mpitests t-sexp t-convert \ t-mpi-bit t-mpi-point curves \ prime basic keygen pubkey hmac hashtest t-kdf keygrip \ fips186-dsa aeswrap pkcs1v2 random dsa-rfc6979 t-ed25519 diff --git a/tests/tsexp.c b/tests/t-sexp.c similarity index 99% rename from tests/tsexp.c rename to tests/t-sexp.c index 1ab9802..ec8b280 100644 --- a/tests/tsexp.c +++ b/tests/t-sexp.c @@ -1,4 +1,4 @@ -/* tsexp.c - S-expression regression tests +/* t-sexp.c - S-expression regression tests * Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc. * * This file is part of Libgcrypt. @@ -28,7 +28,7 @@ #include #include "../src/gcrypt-int.h" -#define PGMNAME "tsexp" +#define PGMNAME "t-sexp" #ifndef DIM # define DIM(v) (sizeof(v)/sizeof((v)[0])) ----------------------------------------------------------------------- Summary of changes: cipher/tiger.c | 12 +++++++++--- tests/Makefile.am | 2 +- tests/{tsexp.c => t-sexp.c} | 4 ++-- 3 files changed, 12 insertions(+), 6 deletions(-) rename tests/{tsexp.c => t-sexp.c} (99%) hooks/post-receive -- The GNU crypto library http://git.gnupg.org From cvs at cvs.gnupg.org Mon Jan 20 11:17:26 2014 From: cvs at cvs.gnupg.org (by Werner Koch) Date: Mon, 20 Jan 2014 11:17:26 +0100 Subject: [git] GCRYPT - branch, LIBGCRYPT-1-6-BRANCH, updated. libgcrypt-1.6.0-12-gd76fffa Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The GNU crypto library". The branch, LIBGCRYPT-1-6-BRANCH has been updated via d76fffaedce6e93304b69ea690213836ed3b9a38 (commit) from 77f28793481d1f41755242377164e4caaa1d106d (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit d76fffaedce6e93304b69ea690213836ed3b9a38 Author: Werner Koch Date: Thu Jan 9 19:14:09 2014 +0100 cipher: Fix commit 77f28793 * cipher/tiger.c (tiger_init): Add arg FLAGS. (tiger1_init, tiger2_init): Ditto. (cherry picked from commit dad06e4d1b835bac778b87090b1d3894b7535b14) diff --git a/cipher/tiger.c b/cipher/tiger.c index 9b8d0ef..414dcc4 100644 --- a/cipher/tiger.c +++ b/cipher/tiger.c @@ -610,20 +610,26 @@ do_init (void *context, int variant) } static void -tiger_init (void *context) +tiger_init (void *context, unsigned int flags) { + (void)flags; + do_init (context, 0); } static void -tiger1_init (void *context) +tiger1_init (void *context, unsigned int flags) { + (void)flags; + do_init (context, 1); } static void -tiger2_init (void *context) +tiger2_init (void *context, unsigned int flags) { + (void)flags; + do_init (context, 2); } ----------------------------------------------------------------------- Summary of changes: cipher/tiger.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) hooks/post-receive -- The GNU crypto library http://git.gnupg.org From cvs at cvs.gnupg.org Thu Jan 23 15:28:56 2014 From: cvs at cvs.gnupg.org (by Werner Koch) Date: Thu, 23 Jan 2014 15:28:56 +0100 Subject: [git] GnuPG - branch, STABLE-BRANCH-1-4, updated. gnupg-1.4.15-14-g24ba0ce Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The GNU Privacy Guard". The branch, STABLE-BRANCH-1-4 has been updated via 24ba0ce93263c42afb9f087ffcf2edda0b433022 (commit) from 9df639b684f8420452d7b39e1dd1c3b974623921 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 24ba0ce93263c42afb9f087ffcf2edda0b433022 Author: Werner Koch Date: Thu Jan 23 15:19:35 2014 +0100 Support building using the latest mingw-w64 toolchain. * acinclude.m4 (GNUPG_SYS_SYMBOL_UNDERSCORE): Change mingw detection. -- From: Stephen Kitt All MinGW targets require underscores when linking. This patch fixes acinclude.m4 and the resulting configure so they don't limit the use of underscores to the old mingw32msvc targets. Debian-bug-id: 730271 Signed-off-by: Werner Koch diff --git a/acinclude.m4 b/acinclude.m4 index 9e4a166..44dfd85 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -692,7 +692,7 @@ AC_CHECK_TOOL(AS, as, false) AC_DEFUN([GNUPG_SYS_SYMBOL_UNDERSCORE], [tmp_do_check="no" case "${host}" in - *-mingw32msvc*) + *-mingw32*) ac_cv_sys_symbol_underscore=yes ;; i386-emx-os2 | i[3456]86-pc-os2*emx | i386-pc-msdosdjgpp) ----------------------------------------------------------------------- Summary of changes: acinclude.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- The GNU Privacy Guard http://git.gnupg.org From cvs at cvs.gnupg.org Thu Jan 23 15:31:45 2014 From: cvs at cvs.gnupg.org (by Werner Koch) Date: Thu, 23 Jan 2014 15:31:45 +0100 Subject: [git] GCRYPT - branch, master, updated. libgcrypt-1.6.0-40-g4ad3417 Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The GNU crypto library". The branch, master has been updated via 4ad3417acab5021db1f722c314314ce4b781833a (commit) from dad06e4d1b835bac778b87090b1d3894b7535b14 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 4ad3417acab5021db1f722c314314ce4b781833a Author: Werner Koch Date: Thu Jan 9 19:14:09 2014 +0100 Support building using the latest mingw-w64 toolchain. * acinclude.m4 (GNUPG_SYS_SYMBOL_UNDERSCORE): Change mingw detection. -- This patch is related to Debian-bug-id 730271 for GnuPG 1.4: From: Stephen Kitt All MinGW targets require underscores when linking. This patch fixes acinclude.m4 and the resulting configure so they don't limit the use of underscores to the old mingw32msvc targets. Signed-off-by: Werner Koch diff --git a/acinclude.m4 b/acinclude.m4 index fdb2d17..0791b84 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -101,7 +101,7 @@ AC_DEFUN([GNUPG_CHECK_GNUMAKE], AC_DEFUN([GNUPG_SYS_SYMBOL_UNDERSCORE], [tmp_do_check="no" case "${host}" in - *-mingw32msvc*) + *-mingw32*) ac_cv_sys_symbol_underscore=yes ;; i386-emx-os2 | i[3456]86-pc-os2*emx | i386-pc-msdosdjgpp) ----------------------------------------------------------------------- Summary of changes: acinclude.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- The GNU crypto library http://git.gnupg.org From cvs at cvs.gnupg.org Fri Jan 24 10:25:02 2014 From: cvs at cvs.gnupg.org (by Werner Koch) Date: Fri, 24 Jan 2014 10:25:02 +0100 Subject: [git] GCRYPT - branch, LIBGCRYPT-1-6-BRANCH, updated. libgcrypt-1.6.0-13-gfa42c61 Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The GNU crypto library". The branch, LIBGCRYPT-1-6-BRANCH has been updated via fa42c61a84996b6a7574c32233dfd8d9f254d93a (commit) from d76fffaedce6e93304b69ea690213836ed3b9a38 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit fa42c61a84996b6a7574c32233dfd8d9f254d93a Author: Werner Koch Date: Thu Jan 9 19:14:09 2014 +0100 Support locking under Windows. * src/ath.c: Add support for Windows. * src/global.c (external_lock_test): New. (_gcry_vcontrol): Call new function with formerly reserved code 61. * tests/t-common.h: New. Taken from current libgpg-error. * tests/t-lock.c: New. Based on t-lock.c from libgpg-error. * configure.ac (HAVE_PTHREAD): Set macro to 1 if defined. (AC_CHECK_FUNCS): Check for flockfile. * tests/Makefile.am (tests_bin): Add t-lock. (noinst_HEADERS): Add t-common.h (LDADD): Move value to ... (default_ldadd): new. (t_lock_LDADD): New. -- 1.6.0 misses locking for Windows and non ELF systems. This patch fixes the Windows case. For 1.7 we will use the forthcoming gpgrt locking functions of libgpg-error. However, we don't want to to that for 1.6. and thus implement W32 locking directly. We further add a test feature for the locking functions. Signed-off-by: Werner Koch diff --git a/configure.ac b/configure.ac index 3387b9a..f0ca372 100644 --- a/configure.ac +++ b/configure.ac @@ -730,7 +730,7 @@ AC_SUBST(PTH_LIBS) # AC_CHECK_LIB(pthread,pthread_create,have_pthread=yes) if test "$have_pthread" = yes; then - AC_DEFINE(HAVE_PTHREAD, ,[Define if we have pthread.]) + AC_DEFINE(HAVE_PTHREAD, 1 ,[Define if we have pthread.]) fi # @@ -1225,7 +1225,7 @@ AC_CHECK_FUNCS(strtoul memmove stricmp atexit raise) # Other checks AC_CHECK_FUNCS(strerror rand mmap getpagesize sysconf waitpid wait4) AC_CHECK_FUNCS(gettimeofday getrusage gethrtime clock_gettime syslog) -AC_CHECK_FUNCS(fcntl ftruncate) +AC_CHECK_FUNCS(fcntl ftruncate flockfile) GNUPG_CHECK_MLOCK diff --git a/src/ath.c b/src/ath.c index 7a7035d..ca40de5 100644 --- a/src/ath.c +++ b/src/ath.c @@ -1,5 +1,6 @@ /* ath.c - A Thread-safeness library. * Copyright (C) 2002, 2003, 2004, 2011 Free Software Foundation, Inc. + * Copyright (C) 2014 g10 Code GmbH * * This file is part of Libgcrypt. * @@ -98,8 +99,12 @@ ath_init (void) #endif else { +#if HAVE_W32_SYSTEM + thread_model = ath_model_w32; +#else /*!HAVE_W32_SYSTEM*/ /* Assume a single threaded application. */ thread_model = ath_model_none; +#endif /*!HAVE_W32_SYSTEM*/ } return err; @@ -166,6 +171,10 @@ ath_install (struct ath_ops *ath_ops) } else if (thread_option == ATH_THREAD_OPTION_DEFAULT) return 0; /* No thread support requested. */ +#if HAVE_W32_SYSTEM + else + return 0; /* It is always enabled. */ +#endif /*HAVE_W32_SYSTEM*/ return GPG_ERR_NOT_SUPPORTED; } @@ -206,6 +215,24 @@ ath_mutex_init (ath_mutex_t *lock) break; #endif /*USE_POSIX_THREADS_WEAK*/ +#if HAVE_W32_SYSTEM + case ath_model_w32: + { + CRITICAL_SECTION *csec; + + csec = malloc (sizeof *csec); + if (!csec) + err = errno? errno : ENOMEM; + else + { + InitializeCriticalSection (csec); + *lock = (void*)csec; + err = 0; + } + } + break; +#endif /*HAVE_W32_SYSTEM*/ + default: err = EINVAL; break; @@ -253,6 +280,18 @@ ath_mutex_destroy (ath_mutex_t *lock) break; #endif /*USE_POSIX_THREADS_WEAK*/ +#if HAVE_W32_SYSTEM + case ath_model_w32: + { + CRITICAL_SECTION *csec = (CRITICAL_SECTION *)(*lock); + + DeleteCriticalSection (csec); + free (csec); + err = 0; + } + break; +#endif /*HAVE_W32_SYSTEM*/ + default: err = EINVAL; break; @@ -289,6 +328,17 @@ ath_mutex_lock (ath_mutex_t *lock) break; #endif /*USE_POSIX_THREADS_WEAK*/ +#if HAVE_W32_SYSTEM + case ath_model_w32: + { + CRITICAL_SECTION *csec = (CRITICAL_SECTION *)(*lock); + + EnterCriticalSection (csec); + err = 0; + } + break; +#endif /*HAVE_W32_SYSTEM*/ + default: err = EINVAL; break; @@ -324,6 +374,17 @@ ath_mutex_unlock (ath_mutex_t *lock) break; #endif /*USE_POSIX_THREADS_WEAK*/ +#if HAVE_W32_SYSTEM + case ath_model_w32: + { + CRITICAL_SECTION *csec = (CRITICAL_SECTION *)(*lock); + + LeaveCriticalSection (csec); + err = 0; + } + break; +#endif /*HAVE_W32_SYSTEM*/ + default: err = EINVAL; break; diff --git a/src/global.c b/src/global.c index 9af499e..5677bde 100644 --- a/src/global.c +++ b/src/global.c @@ -66,6 +66,8 @@ static gcry_handler_no_mem_t outofcore_handler; static void *outofcore_handler_value; static int no_secure_memory; +/* Prototypes. */ +static gpg_err_code_t external_lock_test (int cmd); @@ -616,7 +618,8 @@ _gcry_vcontrol (enum gcry_ctl_cmds cmd, va_list arg_ptr) _gcry_random_deinit_external_test (ctx); } break; - case 61: /* RFU */ + case 61: /* Run external lock test */ + rc = external_lock_test (va_arg (arg_ptr, int)); break; case 62: /* RFU */ break; @@ -1117,3 +1120,48 @@ _gcry_set_progress_handler (void (*cb)(void *,const char*,int, int, int), _gcry_register_primegen_progress (cb, cb_data); _gcry_register_random_progress (cb, cb_data); } + + + +/* This is a helper for the regression test suite to test Libgcrypt's locks. + It works using a one test lock with CMD controlling what to do: + + 30111 - Allocate and init lock + 30112 - Take lock + 30113 - Release lock + 30114 - Destroy lock. + + This function is used by tests/t-lock.c - it is not part of the + public API! + */ +static gpg_err_code_t +external_lock_test (int cmd) +{ + static ath_mutex_t testlock; + gpg_err_code_t rc = 0; + + switch (cmd) + { + case 30111: /* Init Lock. */ + rc = ath_mutex_init (&testlock); + break; + + case 30112: /* Take Lock. */ + rc = ath_mutex_lock (&testlock); + break; + + case 30113: /* Release Lock. */ + rc = ath_mutex_unlock (&testlock); + break; + + case 30114: /* Destroy Lock. */ + rc = ath_mutex_destroy (&testlock); + break; + + default: + rc = GPG_ERR_INV_OP; + break; + } + + return rc; +} diff --git a/tests/Makefile.am b/tests/Makefile.am index f5b5b9f..99d3ecd 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -20,7 +20,7 @@ tests_bin = \ version mpitests tsexp t-convert \ - t-mpi-bit t-mpi-point curves \ + t-mpi-bit t-mpi-point curves t-lock \ prime basic keygen pubkey hmac hashtest t-kdf keygrip \ fips186-dsa aeswrap pkcs1v2 random dsa-rfc6979 t-ed25519 @@ -45,11 +45,17 @@ TESTS_ENVIRONMENT = GCRYPT_IN_REGRESSION_TEST=1 AM_CPPFLAGS = -I../src -I$(top_srcdir)/src AM_CFLAGS = $(GPG_ERROR_CFLAGS) -LDADD = ../src/libgcrypt.la $(DL_LIBS) ../compat/libcompat.la $(GPG_ERROR_LIBS) +default_ldadd = \ + ../src/libgcrypt.la $(DL_LIBS) \ + ../compat/libcompat.la $(GPG_ERROR_LIBS) EXTRA_PROGRAMS = testapi pkbench noinst_PROGRAMS = $(tests_bin) $(tests_bin_last) fipsdrv rsacvt genhashdata +noinst_HEADERS = t-common.h EXTRA_DIST = README rsa-16k.key cavs_tests.sh cavs_driver.pl \ pkcs1v2-oaep.h pkcs1v2-pss.h pkcs1v2-v15c.h pkcs1v2-v15s.h \ t-ed25519.inp stopwatch.h hashtest-256g.in + +LDADD = $(default_ldadd) +t_lock_LDADD = $(default_ldadd) $(LIBMULTITHREAD) diff --git a/tests/t-common.h b/tests/t-common.h new file mode 100644 index 0000000..288963d --- /dev/null +++ b/tests/t-common.h @@ -0,0 +1,99 @@ +/* t-common.h - Common code for the tests. + * Copyright (C) 2013 g10 Code GmbH + * + * This file is part of libgpg-error. + * + * libgpg-error is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * libgpg-error is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program; if not, see . + */ + +#include + +#include "../src/gcrypt.h" + +#ifndef PGM +# error Macro PGM not defined. +#endif + + +static int verbose; +static int debug; +static int errorcount; + + +static void +die (const char *format, ...) +{ + va_list arg_ptr ; + + fflush (stdout); +#ifdef HAVE_FLOCKFILE + flockfile (stderr); +#endif + fprintf (stderr, "%s: ", PGM); + va_start (arg_ptr, format) ; + vfprintf (stderr, format, arg_ptr); + va_end (arg_ptr); + if (*format && format[strlen(format)-1] != '\n') + putc ('\n', stderr); +#ifdef HAVE_FLOCKFILE + funlockfile (stderr); +#endif + exit (1); +} + + +static void +fail (const char *format, ...) +{ + va_list arg_ptr; + + fflush (stdout); +#ifdef HAVE_FLOCKFILE + flockfile (stderr); +#endif + fprintf (stderr, "%s: ", PGM); + va_start (arg_ptr, format); + vfprintf (stderr, format, arg_ptr); + va_end (arg_ptr); + if (*format && format[strlen(format)-1] != '\n') + putc ('\n', stderr); +#ifdef HAVE_FLOCKFILE + funlockfile (stderr); +#endif + errorcount++; + if (errorcount >= 50) + die ("stopped after 50 errors."); +} + + +static void +show (const char *format, ...) +{ + va_list arg_ptr; + + if (!verbose) + return; +#ifdef HAVE_FLOCKFILE + flockfile (stderr); +#endif + fprintf (stderr, "%s: ", PGM); + va_start (arg_ptr, format); + vfprintf (stderr, format, arg_ptr); + if (*format && format[strlen(format)-1] != '\n') + putc ('\n', stderr); + va_end (arg_ptr); +#ifdef HAVE_FLOCKFILE + funlockfile (stderr); +#endif +} diff --git a/tests/t-lock.c b/tests/t-lock.c new file mode 100644 index 0000000..cae5748 --- /dev/null +++ b/tests/t-lock.c @@ -0,0 +1,463 @@ +/* t-lock.c - Check the lock functions + * Copyright (C) 2014 g10 Code GmbH + * + * This file is part of Libgcrypt. + * + * Libgcrypt is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * Libgcrypt 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 . + */ + +#if HAVE_CONFIG_H +# include +#endif + +#include +#include +#include +#include +#include +#include +#if HAVE_PTHREAD +# include +#endif + +#define PGM "t-lock" + +#include "t-common.h" + +/* Mingw requires us to include windows.h after winsock2.h which is + included by gcrypt.h. */ +#ifdef _WIN32 +# include +#endif + +#ifdef _WIN32 +# define THREAD_RET_TYPE DWORD WINAPI +# define THREAD_RET_VALUE 0 +#else +# define THREAD_RET_TYPE void * +# define THREAD_RET_VALUE NULL +#endif + +#define PRIV_CTL_EXTERNAL_LOCK_TEST 61 +#define EXTERNAL_LOCK_TEST_INIT 30111 +#define EXTERNAL_LOCK_TEST_LOCK 30112 +#define EXTERNAL_LOCK_TEST_UNLOCK 30113 +#define EXTERNAL_LOCK_TEST_DESTROY 30114 + + +/* Number of threads to run. */ +#define N_NONCE_THREADS 8 +/* Number of interations. */ +#define N_NONCE_ITERATIONS 1000 +/* Requested nonce size. */ +#define NONCE_SIZE 11 + + +/* This tests works by having a a couple of accountant threads which do + random transactions between accounts and a revision threads which + checks that the balance of all accounts is invariant. The idea for + this check is due to Bruno Haible. */ +#define N_ACCOUNT 8 +#define ACCOUNT_VALUE 42 +static int account[N_ACCOUNT]; + +/* Number of transactions done by each accountant. */ +#define N_TRANSACTIONS 1000 + +/* Number of accountants to run. */ +#define N_ACCOUNTANTS 5 + +/* Maximum transaction value. A quite low value is used so that we + would get an integer overflow. */ +#define MAX_TRANSACTION_VALUE 50 + +/* Flag to tell the revision thread to finish. */ +static volatile int stop_revision_thread; + + +struct thread_arg_s +{ + int no; +}; + + + + +/* Wrapper functions to access Libgcrypt's internal test lock. */ +static void +external_lock_test_init (int line) +{ + gpg_error_t err; + + err = gcry_control (PRIV_CTL_EXTERNAL_LOCK_TEST, EXTERNAL_LOCK_TEST_INIT); + if (err) + fail ("init lock failed at %d: %s", line, gpg_strerror (err)); +} + +static void +external_lock_test_lock (int line) +{ + gpg_error_t err; + + err = gcry_control (PRIV_CTL_EXTERNAL_LOCK_TEST, EXTERNAL_LOCK_TEST_LOCK); + if (err) + fail ("taking lock failed at %d: %s", line, gpg_strerror (err)); +} + +static void +external_lock_test_unlock (int line) +{ + gpg_error_t err; + + err = gcry_control (PRIV_CTL_EXTERNAL_LOCK_TEST, EXTERNAL_LOCK_TEST_UNLOCK); + if (err) + fail ("releasing lock failed at %d: %s", line, gpg_strerror (err)); + +} + +static void +external_lock_test_destroy (int line) +{ + gpg_error_t err; + + err = gcry_control (PRIV_CTL_EXTERNAL_LOCK_TEST, EXTERNAL_LOCK_TEST_DESTROY); + if (err) + fail ("destroying lock failed at %d: %s", line, gpg_strerror (err)); +} + + + + +/* The nonce thread. We simply request a couple of nonces and + return. */ +static THREAD_RET_TYPE +nonce_thread (void *argarg) +{ + struct thread_arg_s *arg = argarg; + int i; + char nonce[NONCE_SIZE]; + + for (i = 0; i < N_NONCE_ITERATIONS; i++) + { + gcry_create_nonce (nonce, sizeof nonce); + if (i && !(i%100)) + show ("thread %d created %d nonces so far", arg->no, i); + } + + gcry_free (arg); + return THREAD_RET_VALUE; +} + + +/* To check our locking function we run several threads all accessing + the nonce functions. If this function returns we know that there + are no obvious deadlocks or failed lock initialization. */ +static void +check_nonce_lock (void) +{ + struct thread_arg_s *arg; +#ifdef _WIN32 + HANDLE threads[N_NONCE_THREADS]; + int i; + int rc; + + for (i=0; i < N_NONCE_THREADS; i++) + { + arg = gcry_xmalloc (sizeof *arg); + arg->no = i; + threads[i] = CreateThread (NULL, 0, nonce_thread, arg, 0, NULL); + if (!threads[i]) + die ("error creating nonce thread %d: rc=%d", + i, (int)GetLastError ()); + } + + for (i=0; i < N_NONCE_THREADS; i++) + { + rc = WaitForSingleObject (threads[i], INFINITE); + if (rc == WAIT_OBJECT_0) + show ("nonce thread %d has terminated", i); + else + fail ("waiting for nonce thread %d failed: %d", + i, (int)GetLastError ()); + CloseHandle (threads[i]); + } + +#elif HAVE_PTHREAD + pthread_t threads[N_NONCE_THREADS]; + int rc, i; + + for (i=0; i < N_NONCE_THREADS; i++) + { + arg = gcry_xmalloc (sizeof *arg); + arg->no = i; + pthread_create (&threads[i], NULL, nonce_thread, arg); + } + + for (i=0; i < N_NONCE_THREADS; i++) + { + rc = pthread_join (threads[i], NULL); + if (rc) + fail ("pthread_join failed for nonce thread %d: %s", + i, strerror (errno)); + else + show ("nonce thread %d has terminated", i); + } + +#endif /*!_WIN32*/ +} + + +/* Initialze all accounts. */ +static void +init_accounts (void) +{ + int i; + + for (i=0; i < N_ACCOUNT; i++) + account[i] = ACCOUNT_VALUE; +} + + +/* Check that the sum of all accounts matches the intial sum. */ +static void +check_accounts (void) +{ + int i, sum; + + sum = 0; + for (i = 0; i < N_ACCOUNT; i++) + sum += account[i]; + if (sum != N_ACCOUNT * ACCOUNT_VALUE) + die ("accounts out of balance"); +} + + +static void +print_accounts (void) +{ + int i; + + for (i=0; i < N_ACCOUNT; i++) + printf ("account %d: %6d\n", i, account[i]); +} + + +/* Get a a random integer value in the range 0 to HIGH. */ +static unsigned int +get_rand (int high) +{ + return (unsigned int)(1+(int)((double)(high+1)*rand ()/(RAND_MAX+1.0))) - 1; +} + + +/* Pick a random account. Note that this fucntion is not + thread-safe. */ +static int +pick_account (void) +{ + return get_rand (N_ACCOUNT - 1); +} + + +/* Pick a random value for a transaction. This is not thread-safe. */ +static int +pick_value (void) +{ + return get_rand (MAX_TRANSACTION_VALUE); +} + + +/* This is the revision department. */ +static THREAD_RET_TYPE +revision_thread (void *arg) +{ + (void)arg; + + while (!stop_revision_thread) + { + external_lock_test_lock (__LINE__); + check_accounts (); + external_lock_test_unlock (__LINE__); + } + return THREAD_RET_VALUE; +} + + +/* This is one of our accountants. */ +static THREAD_RET_TYPE +accountant_thread (void *arg) +{ + int i; + int acc1, acc2; + int value; + + (void)arg; + + for (i = 0; i < N_TRANSACTIONS; i++) + { + external_lock_test_lock (__LINE__); + acc1 = pick_account (); + acc2 = pick_account (); + value = pick_value (); + account[acc1] += value; + account[acc2] -= value; + external_lock_test_unlock (__LINE__); + } + return THREAD_RET_VALUE; +} + + +static void +run_test (void) +{ +#ifdef _WIN32 + HANDLE rthread; + HANDLE athreads[N_ACCOUNTANTS]; + int i; + int rc; + + external_lock_test_init (__LINE__); + stop_revision_thread = 0; + rthread = CreateThread (NULL, 0, revision_thread, NULL, 0, NULL); + if (!rthread) + die ("error creating revision thread: rc=%d", (int)GetLastError ()); + + for (i=0; i < N_ACCOUNTANTS; i++) + { + athreads[i] = CreateThread (NULL, 0, accountant_thread, NULL, 0, NULL); + if (!athreads[i]) + die ("error creating accountant thread %d: rc=%d", + i, (int)GetLastError ()); + } + + for (i=0; i < N_ACCOUNTANTS; i++) + { + rc = WaitForSingleObject (athreads[i], INFINITE); + if (rc == WAIT_OBJECT_0) + show ("accountant thread %d has terminated", i); + else + fail ("waiting for accountant thread %d failed: %d", + i, (int)GetLastError ()); + CloseHandle (athreads[i]); + } + stop_revision_thread = 1; + + rc = WaitForSingleObject (rthread, INFINITE); + if (rc == WAIT_OBJECT_0) + show ("revision thread has terminated"); + else + fail ("waiting for revision thread failed: %d", (int)GetLastError ()); + CloseHandle (rthread); + +#else /*!_WIN32*/ + pthread_t rthread; + pthread_t athreads[N_ACCOUNTANTS]; + int rc, i; + + external_lock_test_init (__LINE__); + stop_revision_thread = 0; + pthread_create (&rthread, NULL, revision_thread, NULL); + + for (i=0; i < N_ACCOUNTANTS; i++) + pthread_create (&athreads[i], NULL, accountant_thread, NULL); + + for (i=0; i < N_ACCOUNTANTS; i++) + { + rc = pthread_join (athreads[i], NULL); + if (rc) + fail ("pthread_join failed for accountant thread %d: %s", + i, strerror (errno)); + else + show ("accountant thread %d has terminated", i); + } + + stop_revision_thread = 1; + rc = pthread_join (rthread, NULL); + if (rc) + fail ("pthread_join failed for the revision thread: %s", strerror (errno)); + else + show ("revision thread has terminated"); + +#endif /*!_WIN32*/ + + external_lock_test_destroy (__LINE__); +} + + + +int +main (int argc, char **argv) +{ + int last_argc = -1; + + if (argc) + { + argc--; argv++; + } + while (argc && last_argc != argc ) + { + last_argc = argc; + if (!strcmp (*argv, "--help")) + { + puts ( +"usage: ./t-lock [options]\n" +"\n" +"Options:\n" +" --verbose Show what is going on\n" +" --debug Flyswatter\n" +); + exit (0); + } + if (!strcmp (*argv, "--verbose")) + { + verbose = 1; + argc--; argv++; + } + else if (!strcmp (*argv, "--debug")) + { + verbose = debug = 1; + argc--; argv++; + } + } + + srand (time(NULL)*getpid()); + + if (debug) + gcry_control (GCRYCTL_SET_DEBUG_FLAGS, 1u, 0); + gcry_control (GCRYCTL_DISABLE_SECMEM, 0); + if (!gcry_check_version (GCRYPT_VERSION)) + die ("version mismatch"); + gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0); + gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); + + if (debug) + gcry_control (GCRYCTL_PRINT_CONFIG, NULL); + + check_nonce_lock (); + + init_accounts (); + check_accounts (); + + run_test (); + check_accounts (); + + /* Run a second time to check deinit code. */ + run_test (); + check_accounts (); + + if (verbose) + print_accounts (); + + return errorcount ? 1 : 0; +} ----------------------------------------------------------------------- Summary of changes: configure.ac | 4 +- src/ath.c | 61 +++++++ src/global.c | 50 +++++- tests/Makefile.am | 10 +- tests/t-common.h | 99 ++++++++++++ tests/t-lock.c | 463 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 682 insertions(+), 5 deletions(-) create mode 100644 tests/t-common.h create mode 100644 tests/t-lock.c hooks/post-receive -- The GNU crypto library http://git.gnupg.org From cvs at cvs.gnupg.org Fri Jan 24 10:50:21 2014 From: cvs at cvs.gnupg.org (by Dmitry Eremin-Solenikov) Date: Fri, 24 Jan 2014 10:50:21 +0100 Subject: [git] GCRYPT - branch, LIBGCRYPT-1-6-BRANCH, updated. libgcrypt-1.6.0-14-gf6bd8ed Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The GNU crypto library". The branch, LIBGCRYPT-1-6-BRANCH has been updated via f6bd8edf764e04f10bb04ba8ba4c9e56ecee3b47 (commit) from fa42c61a84996b6a7574c32233dfd8d9f254d93a (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit f6bd8edf764e04f10bb04ba8ba4c9e56ecee3b47 Author: Dmitry Eremin-Solenikov Date: Tue Dec 31 00:38:37 2013 +0400 Truncate hash values for ECDSA signature scheme * cipher/dsa-common (_gcry_dsa_normalize_hash): New. Truncate opaque mpis as required for DSA and ECDSA signature schemas. * cipher/dsa.c (verify): Return gpg_err_code_t value from verify() to behave like the rest of internal sign/verify functions. * cipher/dsa.c (sign, verify, dsa_verify): Factor out hash truncation. * cipher/ecc-ecdsa.c (_gcry_ecc_ecdsa_sign): Factor out hash truncation. * cipher/ecc-ecdsa.c (_gcry_ecc_ecdsa_verify): as required by ECDSA scheme, truncate hash values to bitlength of used curve. * tests/pubkey.c (check_ecc_sample_key): add a testcase for hash truncation. Signed-off-by: Dmitry Eremin-Solenikov (cherry picked from commit 9edcf1090e0485f9f383b6c54b18ea8ca3d4a225) diff --git a/cipher/dsa-common.c b/cipher/dsa-common.c index d251eae..a5e42a2 100644 --- a/cipher/dsa-common.c +++ b/cipher/dsa-common.c @@ -359,3 +359,36 @@ _gcry_dsa_gen_rfc6979_k (gcry_mpi_t *r_k, *r_k = k; return rc; } + +/* + * Truncate opaque hash value to qbits for DSA. + * Non-opaque input is not truncated, in hope that user + * knows what is passed. It is not possible to correctly + * trucate non-opaque inputs. + */ +gpg_err_code_t +_gcry_dsa_normalize_hash (gcry_mpi_t input, + gcry_mpi_t *out, + unsigned int qbits) +{ + gpg_err_code_t rc = 0; + const void *abuf; + unsigned int abits; + gcry_mpi_t hash; + + if (mpi_is_opaque (input)) + { + abuf = mpi_get_opaque (input, &abits); + rc = _gcry_mpi_scan (&hash, GCRYMPI_FMT_USG, abuf, (abits+7)/8, NULL); + if (rc) + return rc; + if (abits > qbits) + mpi_rshift (hash, hash, abits - qbits); + } + else + hash = input; + + *out = hash; + + return rc; +} diff --git a/cipher/dsa.c b/cipher/dsa.c index 50bdab1..1707d8c 100644 --- a/cipher/dsa.c +++ b/cipher/dsa.c @@ -115,7 +115,7 @@ static gpg_err_code_t generate (DSA_secret_key *sk, gcry_mpi_t **ret_factors); static gpg_err_code_t sign (gcry_mpi_t r, gcry_mpi_t s, gcry_mpi_t input, DSA_secret_key *skey, int flags, int hashalgo); -static int verify (gcry_mpi_t r, gcry_mpi_t s, gcry_mpi_t input, +static gpg_err_code_t verify (gcry_mpi_t r, gcry_mpi_t s, gcry_mpi_t input, DSA_public_key *pkey); static unsigned int dsa_get_nbits (gcry_sexp_t parms); @@ -165,12 +165,12 @@ test_keys (DSA_secret_key *sk, unsigned int qbits) sign (sig_a, sig_b, data, sk, 0, 0); /* Verify the signature using the public key. */ - if ( !verify (sig_a, sig_b, data, &pk) ) + if ( verify (sig_a, sig_b, data, &pk) ) goto leave; /* Signature does not match. */ /* Modify the data and check that the signing fails. */ mpi_add_ui (data, data, 1); - if ( verify (sig_a, sig_b, data, &pk) ) + if ( !verify (sig_a, sig_b, data, &pk) ) goto leave; /* Signature matches but should not. */ result = 0; /* The test succeeded. */ @@ -573,20 +573,9 @@ sign (gcry_mpi_t r, gcry_mpi_t s, gcry_mpi_t input, DSA_secret_key *skey, qbits = mpi_get_nbits (skey->q); /* Convert the INPUT into an MPI. */ - if (mpi_is_opaque (input)) - { - abuf = mpi_get_opaque (input, &abits); - rc = _gcry_mpi_scan (&hash, GCRYMPI_FMT_USG, abuf, (abits+7)/8, NULL); - if (rc) - return rc; - if (abits > qbits) - mpi_rshift (hash, hash, abits - qbits); - } - else - { - mpi_normalize (input); - hash = input; - } + rc = _gcry_dsa_normalize_hash (input, &hash, qbits); + if (rc) + return rc; again: /* Create the K value. */ @@ -651,18 +640,25 @@ sign (gcry_mpi_t r, gcry_mpi_t s, gcry_mpi_t input, DSA_secret_key *skey, /* Returns true if the signature composed from R and S is valid. */ -static int -verify (gcry_mpi_t r, gcry_mpi_t s, gcry_mpi_t hash, DSA_public_key *pkey ) +static gpg_err_code_t +verify (gcry_mpi_t r, gcry_mpi_t s, gcry_mpi_t input, DSA_public_key *pkey ) { - int rc; + gpg_err_code_t rc = 0; gcry_mpi_t w, u1, u2, v; gcry_mpi_t base[3]; gcry_mpi_t ex[3]; + gcry_mpi_t hash; + unsigned int nbits; if( !(mpi_cmp_ui( r, 0 ) > 0 && mpi_cmp( r, pkey->q ) < 0) ) - return 0; /* assertion 0 < r < q failed */ + return GPG_ERR_BAD_SIGNATURE; /* Assertion 0 < r < n failed. */ if( !(mpi_cmp_ui( s, 0 ) > 0 && mpi_cmp( s, pkey->q ) < 0) ) - return 0; /* assertion 0 < s < q failed */ + return GPG_ERR_BAD_SIGNATURE; /* Assertion 0 < s < n failed. */ + + nbits = mpi_get_nbits (pkey->q); + rc = _gcry_dsa_normalize_hash (input, &hash, nbits); + if (rc) + return rc; w = mpi_alloc( mpi_get_nlimbs(pkey->q) ); u1 = mpi_alloc( mpi_get_nlimbs(pkey->q) ); @@ -685,12 +681,25 @@ verify (gcry_mpi_t r, gcry_mpi_t s, gcry_mpi_t hash, DSA_public_key *pkey ) mpi_mulpowm( v, base, ex, pkey->p ); mpi_fdiv_r( v, v, pkey->q ); - rc = !mpi_cmp( v, r ); + if (mpi_cmp( v, r )) + { + if (DBG_CIPHER) + { + log_mpidump (" i", input); + log_mpidump (" h", hash); + log_mpidump (" v", v); + log_mpidump (" r", r); + log_mpidump (" s", s); + } + rc = GPG_ERR_BAD_SIGNATURE; + } mpi_free(w); mpi_free(u1); mpi_free(u2); mpi_free(v); + if (hash != input) + mpi_free (hash); return rc; } @@ -1090,31 +1099,7 @@ dsa_verify (gcry_sexp_t s_sig, gcry_sexp_t s_data, gcry_sexp_t s_keyparms) } /* Verify the signature. */ - if (mpi_is_opaque (data)) - { - const void *abuf; - unsigned int abits, qbits; - gcry_mpi_t a; - - qbits = mpi_get_nbits (pk.q); - - abuf = mpi_get_opaque (data, &abits); - rc = _gcry_mpi_scan (&a, GCRYMPI_FMT_USG, abuf, (abits+7)/8, NULL); - if (!rc) - { - if (abits > qbits) - mpi_rshift (a, a, abits - qbits); - - if (!verify (sig_r, sig_s, a, &pk)) - rc = GPG_ERR_BAD_SIGNATURE; - _gcry_mpi_release (a); - } - } - else - { - if (!verify (sig_r, sig_s, data, &pk)) - rc = GPG_ERR_BAD_SIGNATURE; - } + rc = verify (sig_r, sig_s, data, &pk); leave: _gcry_mpi_release (pk.p); diff --git a/cipher/ecc-ecdsa.c b/cipher/ecc-ecdsa.c index b4bbe2c..1484830 100644 --- a/cipher/ecc-ecdsa.c +++ b/cipher/ecc-ecdsa.c @@ -57,18 +57,9 @@ _gcry_ecc_ecdsa_sign (gcry_mpi_t input, ECC_secret_key *skey, qbits = mpi_get_nbits (skey->E.n); /* Convert the INPUT into an MPI if needed. */ - if (mpi_is_opaque (input)) - { - abuf = mpi_get_opaque (input, &abits); - rc = _gcry_mpi_scan (&hash, GCRYMPI_FMT_USG, abuf, (abits+7)/8, NULL); - if (rc) - return rc; - if (abits > qbits) - mpi_rshift (hash, hash, abits - qbits); - } - else - hash = input; - + rc = _gcry_dsa_normalize_hash (input, &hash, qbits); + if (rc) + return rc; k = NULL; dr = mpi_alloc (0); @@ -161,15 +152,21 @@ _gcry_ecc_ecdsa_verify (gcry_mpi_t input, ECC_public_key *pkey, gcry_mpi_t r, gcry_mpi_t s) { gpg_err_code_t err = 0; - gcry_mpi_t h, h1, h2, x; + gcry_mpi_t hash, h, h1, h2, x; mpi_point_struct Q, Q1, Q2; mpi_ec_t ctx; + unsigned int nbits; if( !(mpi_cmp_ui (r, 0) > 0 && mpi_cmp (r, pkey->E.n) < 0) ) return GPG_ERR_BAD_SIGNATURE; /* Assertion 0 < r < n failed. */ if( !(mpi_cmp_ui (s, 0) > 0 && mpi_cmp (s, pkey->E.n) < 0) ) return GPG_ERR_BAD_SIGNATURE; /* Assertion 0 < s < n failed. */ + nbits = mpi_get_nbits (pkey->E.n); + err = _gcry_dsa_normalize_hash (input, &hash, nbits); + if (err) + return err; + h = mpi_alloc (0); h1 = mpi_alloc (0); h2 = mpi_alloc (0); @@ -184,7 +181,7 @@ _gcry_ecc_ecdsa_verify (gcry_mpi_t input, ECC_public_key *pkey, /* h = s^(-1) (mod n) */ mpi_invm (h, s, pkey->E.n); /* h1 = hash * s^(-1) (mod n) */ - mpi_mulm (h1, input, h, pkey->E.n); + mpi_mulm (h1, hash, h, pkey->E.n); /* Q1 = [ hash * s^(-1) ]G */ _gcry_mpi_ec_mul_point (&Q1, h1, &pkey->E.G, ctx); /* h2 = r * s^(-1) (mod n) */ @@ -230,5 +227,8 @@ _gcry_ecc_ecdsa_verify (gcry_mpi_t input, ECC_public_key *pkey, mpi_free (h2); mpi_free (h1); mpi_free (h); + if (hash != input) + mpi_free (hash); + return err; } diff --git a/cipher/pubkey-internal.h b/cipher/pubkey-internal.h index db1399d..193248c 100644 --- a/cipher/pubkey-internal.h +++ b/cipher/pubkey-internal.h @@ -88,6 +88,9 @@ gpg_err_code_t _gcry_dsa_gen_rfc6979_k (gcry_mpi_t *r_k, int halgo, unsigned int extraloops); +gpg_err_code_t _gcry_dsa_normalize_hash (gcry_mpi_t input, + gcry_mpi_t *out, + unsigned int qbits); /*-- ecc.c --*/ gpg_err_code_t _gcry_pk_ecc_get_sexp (gcry_sexp_t *r_sexp, int mode, diff --git a/tests/pubkey.c b/tests/pubkey.c index 4e12dfd..ae5eea2 100644 --- a/tests/pubkey.c +++ b/tests/pubkey.c @@ -980,9 +980,23 @@ check_ecc_sample_key (void) "(data (flags raw)\n" " (value #00112233445566778899AABBCCDDEEFF" /* */ "000102030405060708090A0B0C0D0E0F#))"; + static const char hash2_string[] = + "(data (flags raw)\n" + " (hash sha1 #00112233445566778899AABBCCDDEEFF" + /* */ "000102030405060708090A0B0C0D0E0F" + /* */ "000102030405060708090A0B0C0D0E0F" + /* */ "00112233445566778899AABBCCDDEEFF#))"; + /* hash2, but longer than curve length, so it will be truncated */ + static const char hash3_string[] = + "(data (flags raw)\n" + " (hash sha1 #00112233445566778899AABBCCDDEEFF" + /* */ "000102030405060708090A0B0C0D0E0F" + /* */ "000102030405060708090A0B0C0D0E0F" + /* */ "00112233445566778899AABBCCDDEEFF" + /* */ "000102030405060708090A0B0C0D0E0F#))"; gpg_error_t err; - gcry_sexp_t key, hash, sig; + gcry_sexp_t key, hash, hash2, hash3, sig, sig2; if (verbose) fprintf (stderr, "Checking sample ECC key.\n"); @@ -990,6 +1004,12 @@ check_ecc_sample_key (void) if ((err = gcry_sexp_new (&hash, hash_string, 0, 1))) die ("line %d: %s", __LINE__, gpg_strerror (err)); + if ((err = gcry_sexp_new (&hash2, hash2_string, 0, 1))) + die ("line %d: %s", __LINE__, gpg_strerror (err)); + + if ((err = gcry_sexp_new (&hash3, hash3_string, 0, 1))) + die ("line %d: %s", __LINE__, gpg_strerror (err)); + if ((err = gcry_sexp_new (&key, ecc_private_key, 0, 1))) die ("line %d: %s", __LINE__, gpg_strerror (err)); @@ -1003,6 +1023,28 @@ check_ecc_sample_key (void) if ((err = gcry_pk_verify (sig, hash, key))) die ("gcry_pk_verify failed: %s", gpg_strerror (err)); + /* Verify hash truncation */ + gcry_sexp_release (key); + if ((err = gcry_sexp_new (&key, ecc_private_key, 0, 1))) + die ("line %d: %s", __LINE__, gpg_strerror (err)); + + if ((err = gcry_pk_sign (&sig2, hash2, key))) + die ("gcry_pk_sign failed: %s", gpg_strerror (err)); + + gcry_sexp_release (sig); + if ((err = gcry_pk_sign (&sig, hash3, key))) + die ("gcry_pk_sign failed: %s", gpg_strerror (err)); + + gcry_sexp_release (key); + if ((err = gcry_sexp_new (&key, ecc_public_key, 0, 1))) + die ("line %d: %s", __LINE__, gpg_strerror (err)); + + if ((err = gcry_pk_verify (sig, hash2, key))) + die ("gcry_pk_verify failed: %s", gpg_strerror (err)); + + if ((err = gcry_pk_verify (sig2, hash3, key))) + die ("gcry_pk_verify failed: %s", gpg_strerror (err)); + /* Now try signing without the Q parameter. */ gcry_sexp_release (key); @@ -1021,8 +1063,11 @@ check_ecc_sample_key (void) die ("gcry_pk_verify signed without Q failed: %s", gpg_strerror (err)); gcry_sexp_release (sig); + gcry_sexp_release (sig2); gcry_sexp_release (key); gcry_sexp_release (hash); + gcry_sexp_release (hash2); + gcry_sexp_release (hash3); } ----------------------------------------------------------------------- Summary of changes: cipher/dsa-common.c | 33 +++++++++++++++++++ cipher/dsa.c | 81 +++++++++++++++++++--------------------------- cipher/ecc-ecdsa.c | 28 ++++++++-------- cipher/pubkey-internal.h | 3 ++ tests/pubkey.c | 47 ++++++++++++++++++++++++++- 5 files changed, 129 insertions(+), 63 deletions(-) hooks/post-receive -- The GNU crypto library http://git.gnupg.org From cvs at cvs.gnupg.org Fri Jan 24 15:25:02 2014 From: cvs at cvs.gnupg.org (by Werner Koch) Date: Fri, 24 Jan 2014 15:25:02 +0100 Subject: [git] GCRYPT - branch, LIBGCRYPT-1-6-BRANCH, updated. libgcrypt-1.6.0-15-g04d478d Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The GNU crypto library". The branch, LIBGCRYPT-1-6-BRANCH has been updated via 04d478d9b0f92d80105ddaf2c011f40ae8260cfb (commit) from f6bd8edf764e04f10bb04ba8ba4c9e56ecee3b47 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 04d478d9b0f92d80105ddaf2c011f40ae8260cfb Author: Werner Koch Date: Thu Jan 9 19:14:09 2014 +0100 Check compiler features only for the relevant platform. * mpi/config.links (mpi_cpu_arch): Always set for ARM. Set for HPPA. Set to "undefined" for unknown platforms. (try_asm_modules): Act upon only after having detected the CPU. * configure.ac: Move the call to config.links before the platform specific compiler checks. Check platform specific features only if the platform is targeted. -- There is no need to check x86 options if we are targeting ARM and vice versa. This may only introduce build problems. With this patch the summary output at the end of the compiler also shows more reasonable messages. Signed-off-by: Werner Koch diff --git a/configure.ac b/configure.ac index f0ca372..e6686a7 100644 --- a/configure.ac +++ b/configure.ac @@ -566,10 +566,6 @@ AC_ARG_ENABLE(padlock-support, [Disable support for the PadLock Engine of VIA processors]), padlocksupport=$enableval,padlocksupport=yes) AC_MSG_RESULT($padlocksupport) -if test x"$padlocksupport" = xyes ; then - AC_DEFINE(ENABLE_PADLOCK_SUPPORT, 1, - [Enable support for the PadLock engine.]) -fi # Implementation of the --disable-aesni-support switch. AC_MSG_CHECKING([whether AESNI support is requested]) @@ -594,10 +590,6 @@ AC_ARG_ENABLE(drng-support, [Disable support for the Intel DRNG (RDRAND instruction)]), drngsupport=$enableval,drngsupport=yes) AC_MSG_RESULT($drngsupport) -if test x"$drngsupport" = xyes ; then - AC_DEFINE(ENABLE_DRNG_SUPPORT, 1, - [Enable support for Intel DRNG (RDRAND instruction).]) -fi # Implementation of the --disable-avx-support switch. AC_MSG_CHECKING([whether AVX support is requested]) @@ -991,19 +983,121 @@ fi # +# Check whether GCC assembler supports features needed for our ARM +# implementations. This needs to be done before setting up the +# assembler stuff. +# +AC_CACHE_CHECK([whether GCC assembler is compatible for ARM assembly implementations], + [gcry_cv_gcc_arm_platform_as_ok], + [gcry_cv_gcc_arm_platform_as_ok=no + AC_COMPILE_IFELSE([AC_LANG_SOURCE( + [[__asm__( + /* Test if assembler supports UAL syntax. */ + ".syntax unified\n\t" + ".arm\n\t" /* our assembly code is in ARM mode */ + /* Following causes error if assembler ignored '.syntax unified'. */ + "asmfunc:\n\t" + "add %r0, %r0, %r4, ror #12;\n\t" + + /* Test if '.type' and '.size' are supported. */ + ".size asmfunc,.-asmfunc;\n\t" + ".type asmfunc,%function;\n\t" + );]])], + [gcry_cv_gcc_arm_platform_as_ok=yes])]) +if test "$gcry_cv_gcc_arm_platform_as_ok" = "yes" ; then + AC_DEFINE(HAVE_COMPATIBLE_GCC_ARM_PLATFORM_AS,1, + [Defined if underlying assembler is compatible with ARM assembly implementations]) +fi + + +# +# Check whether underscores in symbols are required. This needs to be +# done before setting up the assembler stuff. +# +GNUPG_SYS_SYMBOL_UNDERSCORE() + + +################################# +#### #### +#### Setup assembler stuff. #### +#### Define mpi_cpu_arch. #### +#### #### +################################# +AC_ARG_ENABLE(mpi-path, + AC_HELP_STRING([--enable-mpi-path=EXTRA_PATH], + [prepend EXTRA_PATH to list of CPU specific optimizations]), + mpi_extra_path="$enableval",mpi_extra_path="") +AC_MSG_CHECKING(architecture and mpi assembler functions) +if test -f $srcdir/mpi/config.links ; then + . $srcdir/mpi/config.links + AC_CONFIG_LINKS("$mpi_ln_list") + ac_cv_mpi_sflags="$mpi_sflags" + AC_MSG_RESULT($mpi_cpu_arch) +else + AC_MSG_RESULT(failed) + AC_MSG_ERROR([mpi/config.links missing!]) +fi +MPI_SFLAGS="$ac_cv_mpi_sflags" +AC_SUBST(MPI_SFLAGS) + +AM_CONDITIONAL(MPI_MOD_ASM_MPIH_ADD1, test "$mpi_mod_asm_mpih_add1" = yes) +AM_CONDITIONAL(MPI_MOD_ASM_MPIH_SUB1, test "$mpi_mod_asm_mpih_sub1" = yes) +AM_CONDITIONAL(MPI_MOD_ASM_MPIH_MUL1, test "$mpi_mod_asm_mpih_mul1" = yes) +AM_CONDITIONAL(MPI_MOD_ASM_MPIH_MUL2, test "$mpi_mod_asm_mpih_mul2" = yes) +AM_CONDITIONAL(MPI_MOD_ASM_MPIH_MUL3, test "$mpi_mod_asm_mpih_mul3" = yes) +AM_CONDITIONAL(MPI_MOD_ASM_MPIH_LSHIFT, test "$mpi_mod_asm_mpih_lshift" = yes) +AM_CONDITIONAL(MPI_MOD_ASM_MPIH_RSHIFT, test "$mpi_mod_asm_mpih_rshift" = yes) +AM_CONDITIONAL(MPI_MOD_ASM_UDIV, test "$mpi_mod_asm_udiv" = yes) +AM_CONDITIONAL(MPI_MOD_ASM_UDIV_QRNND, test "$mpi_mod_asm_udiv_qrnnd" = yes) +AM_CONDITIONAL(MPI_MOD_C_MPIH_ADD1, test "$mpi_mod_c_mpih_add1" = yes) +AM_CONDITIONAL(MPI_MOD_C_MPIH_SUB1, test "$mpi_mod_c_mpih_sub1" = yes) +AM_CONDITIONAL(MPI_MOD_C_MPIH_MUL1, test "$mpi_mod_c_mpih_mul1" = yes) +AM_CONDITIONAL(MPI_MOD_C_MPIH_MUL2, test "$mpi_mod_c_mpih_mul2" = yes) +AM_CONDITIONAL(MPI_MOD_C_MPIH_MUL3, test "$mpi_mod_c_mpih_mul3" = yes) +AM_CONDITIONAL(MPI_MOD_C_MPIH_LSHIFT, test "$mpi_mod_c_mpih_lshift" = yes) +AM_CONDITIONAL(MPI_MOD_C_MPIH_RSHIFT, test "$mpi_mod_c_mpih_rshift" = yes) +AM_CONDITIONAL(MPI_MOD_C_UDIV, test "$mpi_mod_c_udiv" = yes) +AM_CONDITIONAL(MPI_MOD_C_UDIV_QRNND, test "$mpi_mod_c_udiv_qrnnd" = yes) + +# Reset non applicable feature flags. +if test "$mpi_cpu_arch" != "x86" ; then + aesnisupport="n/a" + pclmulsupport="n/a" + avxsupport="n/a" + avx2support="n/a" + padlocksupport="n/a" + drngsupport="n/a" +fi + +if test "$mpi_cpu_arch" != "arm" ; then + neonsupport="n/a" +fi + + +############################################# +#### #### +#### Platform specific compiler checks. #### +#### #### +############################################# + +# # Check whether GCC inline assembler supports SSSE3 instructions # This is required for the AES-NI instructions. # AC_CACHE_CHECK([whether GCC inline assembler supports SSSE3 instructions], [gcry_cv_gcc_inline_asm_ssse3], - [gcry_cv_gcc_inline_asm_ssse3=no - AC_COMPILE_IFELSE([AC_LANG_SOURCE( + [if test "$mpi_cpu_arch" != "x86" ; then + gcry_cv_gcc_inline_asm_ssse3="n/a" + else + gcry_cv_gcc_inline_asm_ssse3=no + AC_COMPILE_IFELSE([AC_LANG_SOURCE( [[static unsigned char be_mask[16] __attribute__ ((aligned (16))) = { 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 }; void a(void) { __asm__("pshufb %[mask], %%xmm2\n\t"::[mask]"m"(*be_mask):); }]])], - [gcry_cv_gcc_inline_asm_ssse3=yes])]) + [gcry_cv_gcc_inline_asm_ssse3=yes]) + fi]) if test "$gcry_cv_gcc_inline_asm_ssse3" = "yes" ; then AC_DEFINE(HAVE_GCC_INLINE_ASM_SSSE3,1, [Defined if inline assembler supports SSSE3 instructions]) @@ -1015,12 +1109,16 @@ fi # AC_CACHE_CHECK([whether GCC inline assembler supports PCLMUL instructions], [gcry_cv_gcc_inline_asm_pclmul], - [gcry_cv_gcc_inline_asm_pclmul=no - AC_COMPILE_IFELSE([AC_LANG_SOURCE( + [if test "$mpi_cpu_arch" != "x86" ; then + gcry_cv_gcc_inline_asm_pclmul="n/a" + else + gcry_cv_gcc_inline_asm_pclmul=no + AC_COMPILE_IFELSE([AC_LANG_SOURCE( [[void a(void) { __asm__("pclmulqdq \$0, %%xmm1, %%xmm3\n\t":::"cc"); }]])], - [gcry_cv_gcc_inline_asm_pclmul=yes])]) + [gcry_cv_gcc_inline_asm_pclmul=yes]) + fi]) if test "$gcry_cv_gcc_inline_asm_pclmul" = "yes" ; then AC_DEFINE(HAVE_GCC_INLINE_ASM_PCLMUL,1, [Defined if inline assembler supports PCLMUL instructions]) @@ -1032,12 +1130,16 @@ fi # AC_CACHE_CHECK([whether GCC inline assembler supports AVX instructions], [gcry_cv_gcc_inline_asm_avx], - [gcry_cv_gcc_inline_asm_avx=no - AC_COMPILE_IFELSE([AC_LANG_SOURCE( + [if test "$mpi_cpu_arch" != "x86" ; then + gcry_cv_gcc_inline_asm_avx="n/a" + else + gcry_cv_gcc_inline_asm_avx=no + AC_COMPILE_IFELSE([AC_LANG_SOURCE( [[void a(void) { __asm__("xgetbv; vaesdeclast (%[mem]),%%xmm0,%%xmm7\n\t"::[mem]"r"(0):); }]])], - [gcry_cv_gcc_inline_asm_avx=yes])]) + [gcry_cv_gcc_inline_asm_avx=yes]) + fi]) if test "$gcry_cv_gcc_inline_asm_avx" = "yes" ; then AC_DEFINE(HAVE_GCC_INLINE_ASM_AVX,1, [Defined if inline assembler supports AVX instructions]) @@ -1049,12 +1151,16 @@ fi # AC_CACHE_CHECK([whether GCC inline assembler supports AVX2 instructions], [gcry_cv_gcc_inline_asm_avx2], - [gcry_cv_gcc_inline_asm_avx2=no - AC_COMPILE_IFELSE([AC_LANG_SOURCE( + [if test "$mpi_cpu_arch" != "x86" ; then + gcry_cv_gcc_inline_asm_avx2="n/a" + else + gcry_cv_gcc_inline_asm_avx2=no + AC_COMPILE_IFELSE([AC_LANG_SOURCE( [[void a(void) { __asm__("xgetbv; vpbroadcastb %%xmm7,%%ymm1\n\t":::"cc"); }]])], - [gcry_cv_gcc_inline_asm_avx2=yes])]) + [gcry_cv_gcc_inline_asm_avx2=yes]) + fi]) if test "$gcry_cv_gcc_inline_asm_avx2" = "yes" ; then AC_DEFINE(HAVE_GCC_INLINE_ASM_AVX2,1, [Defined if inline assembler supports AVX2 instructions]) @@ -1066,12 +1172,16 @@ fi # AC_CACHE_CHECK([whether GCC inline assembler supports BMI2 instructions], [gcry_cv_gcc_inline_asm_bmi2], - [gcry_cv_gcc_inline_asm_bmi2=no - AC_COMPILE_IFELSE([AC_LANG_SOURCE( + [if test "$mpi_cpu_arch" != "x86" ; then + gcry_cv_gcc_inline_asm_bmi2="n/a" + else + gcry_cv_gcc_inline_asm_bmi2=no + AC_COMPILE_IFELSE([AC_LANG_SOURCE( [[void a(void) { __asm__("rorxl \$23, %%eax, %%edx\\n\\t":::"memory"); }]])], - [gcry_cv_gcc_inline_asm_bmi2=yes])]) + [gcry_cv_gcc_inline_asm_bmi2=yes]) + fi]) if test "$gcry_cv_gcc_inline_asm_bmi2" = "yes" ; then AC_DEFINE(HAVE_GCC_INLINE_ASM_BMI2,1, [Defined if inline assembler supports BMI2 instructions]) @@ -1085,8 +1195,11 @@ fi if test $amd64_as_feature_detection = yes; then AC_CACHE_CHECK([whether GCC assembler is compatible for amd64 assembly implementations], [gcry_cv_gcc_amd64_platform_as_ok], - [gcry_cv_gcc_amd64_platform_as_ok=no - AC_COMPILE_IFELSE([AC_LANG_SOURCE( + [if test "$mpi_cpu_arch" != "x86" ; then + gcry_cv_gcc_amd64_platform_as_ok="n/a" + else + gcry_cv_gcc_amd64_platform_as_ok=no + AC_COMPILE_IFELSE([AC_LANG_SOURCE( [[__asm__( /* Test if '.type' and '.size' are supported. */ /* These work only on ELF targets. */ @@ -1097,7 +1210,8 @@ if test $amd64_as_feature_detection = yes; then ".size asmfunc,.-asmfunc;\n\t" ".type asmfunc, at function;\n\t" );]])], - [gcry_cv_gcc_amd64_platform_as_ok=yes])]) + [gcry_cv_gcc_amd64_platform_as_ok=yes]) + fi]) if test "$gcry_cv_gcc_amd64_platform_as_ok" = "yes" ; then AC_DEFINE(HAVE_COMPATIBLE_GCC_AMD64_PLATFORM_AS,1, [Defined if underlying assembler is compatible with amd64 assembly implementations]) @@ -1111,8 +1225,11 @@ fi # AC_CACHE_CHECK([whether GCC assembler is compatible for Intel syntax assembly implementations], [gcry_cv_gcc_platform_as_ok_for_intel_syntax], - [gcry_cv_gcc_platform_as_ok_for_intel_syntax=no - AC_COMPILE_IFELSE([AC_LANG_SOURCE( + [if test "$mpi_cpu_arch" != "x86" ; then + gcry_cv_gcc_platform_as_ok_for_intel_syntax="n/a" + else + gcry_cv_gcc_platform_as_ok_for_intel_syntax=no + AC_COMPILE_IFELSE([AC_LANG_SOURCE( [[__asm__( ".intel_syntax noprefix\n\t" "pxor xmm1, xmm7;\n\t" @@ -1132,7 +1249,8 @@ AC_CACHE_CHECK([whether GCC assembler is compatible for Intel syntax assembly im "add VAL_A, VAL_B;\n\t" "add VAL_B, 0b10101;\n\t" );]])], - [gcry_cv_gcc_platform_as_ok_for_intel_syntax=yes])]) + [gcry_cv_gcc_platform_as_ok_for_intel_syntax=yes]) + fi]) if test "$gcry_cv_gcc_platform_as_ok_for_intel_syntax" = "yes" ; then AC_DEFINE(HAVE_INTEL_SYNTAX_PLATFORM_AS,1, [Defined if underlying assembler is compatible with Intel syntax assembly implementations]) @@ -1144,7 +1262,10 @@ fi # AC_CACHE_CHECK([whether compiler is configured for ARMv6 or newer architecture], [gcry_cv_cc_arm_arch_is_v6], - [AC_EGREP_CPP(yes, + [if test "$mpi_cpu_arch" != "arm" ; then + gcry_cv_cc_arm_arch_is_v6="n/a" + else + AC_EGREP_CPP(yes, [#if defined(__arm__) && \ ((defined(__ARM_ARCH) && __ARM_ARCH >= 6) \ || defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) \ @@ -1155,7 +1276,8 @@ AC_CACHE_CHECK([whether compiler is configured for ARMv6 or newer architecture], || defined(__ARM_ARCH_7EM__)) yes #endif - ], gcry_cv_cc_arm_arch_is_v6=yes, gcry_cv_cc_arm_arch_is_v6=no)]) + ], gcry_cv_cc_arm_arch_is_v6=yes, gcry_cv_cc_arm_arch_is_v6=no) + fi]) if test "$gcry_cv_cc_arm_arch_is_v6" = "yes" ; then AC_DEFINE(HAVE_ARM_ARCH_V6,1, [Defined if ARM architecture is v6 or newer]) @@ -1167,8 +1289,11 @@ fi # AC_CACHE_CHECK([whether GCC inline assembler supports NEON instructions], [gcry_cv_gcc_inline_asm_neon], - [gcry_cv_gcc_inline_asm_neon=no - AC_COMPILE_IFELSE([AC_LANG_SOURCE( + [if test "$mpi_cpu_arch" != "arm" ; then + gcry_cv_gcc_inline_asm_neon="n/a" + else + gcry_cv_gcc_inline_asm_neon=no + AC_COMPILE_IFELSE([AC_LANG_SOURCE( [[__asm__( ".syntax unified\n\t" ".thumb\n\t" @@ -1179,40 +1304,14 @@ AC_CACHE_CHECK([whether GCC inline assembler supports NEON instructions], "vadd.s64 %d3, %d2, %d3;\n\t" ); ]])], - [gcry_cv_gcc_inline_asm_neon=yes])]) + [gcry_cv_gcc_inline_asm_neon=yes]) + fi]) if test "$gcry_cv_gcc_inline_asm_neon" = "yes" ; then AC_DEFINE(HAVE_GCC_INLINE_ASM_NEON,1, [Defined if inline assembler supports NEON instructions]) fi -# -# Check whether GCC assembler supports features needed for our ARM -# implementations -# -AC_CACHE_CHECK([whether GCC assembler is compatible for ARM assembly implementations], - [gcry_cv_gcc_arm_platform_as_ok], - [gcry_cv_gcc_arm_platform_as_ok=no - AC_COMPILE_IFELSE([AC_LANG_SOURCE( - [[__asm__( - /* Test if assembler supports UAL syntax. */ - ".syntax unified\n\t" - ".arm\n\t" /* our assembly code is in ARM mode */ - /* Following causes error if assembler ignored '.syntax unified'. */ - "asmfunc:\n\t" - "add %r0, %r0, %r4, ror #12;\n\t" - - /* Test if '.type' and '.size' are supported. */ - ".size asmfunc,.-asmfunc;\n\t" - ".type asmfunc,%function;\n\t" - );]])], - [gcry_cv_gcc_arm_platform_as_ok=yes])]) -if test "$gcry_cv_gcc_arm_platform_as_ok" = "yes" ; then - AC_DEFINE(HAVE_COMPATIBLE_GCC_ARM_PLATFORM_AS,1, - [Defined if underlying assembler is compatible with ARM assembly implementations]) -fi - - ####################################### #### Checks for library functions. #### ####################################### @@ -1328,48 +1427,8 @@ fi # -# Setup assembler stuff. +# Other defines # -# Note that config.links also defines mpi_cpu_arch, which is required -# later on. -# -GNUPG_SYS_SYMBOL_UNDERSCORE() -AC_ARG_ENABLE(mpi-path, - AC_HELP_STRING([--enable-mpi-path=EXTRA_PATH], - [prepend EXTRA_PATH to list of CPU specific optimizations]), - mpi_extra_path="$enableval",mpi_extra_path="") -AC_MSG_CHECKING(for mpi assembler functions) -if test -f $srcdir/mpi/config.links ; then - . $srcdir/mpi/config.links - AC_CONFIG_LINKS("$mpi_ln_list") - ac_cv_mpi_sflags="$mpi_sflags" - AC_MSG_RESULT(done) -else - AC_MSG_RESULT(failed) - AC_MSG_ERROR([mpi/config.links missing!]) -fi -MPI_SFLAGS="$ac_cv_mpi_sflags" -AC_SUBST(MPI_SFLAGS) - -AM_CONDITIONAL(MPI_MOD_ASM_MPIH_ADD1, test "$mpi_mod_asm_mpih_add1" = yes) -AM_CONDITIONAL(MPI_MOD_ASM_MPIH_SUB1, test "$mpi_mod_asm_mpih_sub1" = yes) -AM_CONDITIONAL(MPI_MOD_ASM_MPIH_MUL1, test "$mpi_mod_asm_mpih_mul1" = yes) -AM_CONDITIONAL(MPI_MOD_ASM_MPIH_MUL2, test "$mpi_mod_asm_mpih_mul2" = yes) -AM_CONDITIONAL(MPI_MOD_ASM_MPIH_MUL3, test "$mpi_mod_asm_mpih_mul3" = yes) -AM_CONDITIONAL(MPI_MOD_ASM_MPIH_LSHIFT, test "$mpi_mod_asm_mpih_lshift" = yes) -AM_CONDITIONAL(MPI_MOD_ASM_MPIH_RSHIFT, test "$mpi_mod_asm_mpih_rshift" = yes) -AM_CONDITIONAL(MPI_MOD_ASM_UDIV, test "$mpi_mod_asm_udiv" = yes) -AM_CONDITIONAL(MPI_MOD_ASM_UDIV_QRNND, test "$mpi_mod_asm_udiv_qrnnd" = yes) -AM_CONDITIONAL(MPI_MOD_C_MPIH_ADD1, test "$mpi_mod_c_mpih_add1" = yes) -AM_CONDITIONAL(MPI_MOD_C_MPIH_SUB1, test "$mpi_mod_c_mpih_sub1" = yes) -AM_CONDITIONAL(MPI_MOD_C_MPIH_MUL1, test "$mpi_mod_c_mpih_mul1" = yes) -AM_CONDITIONAL(MPI_MOD_C_MPIH_MUL2, test "$mpi_mod_c_mpih_mul2" = yes) -AM_CONDITIONAL(MPI_MOD_C_MPIH_MUL3, test "$mpi_mod_c_mpih_mul3" = yes) -AM_CONDITIONAL(MPI_MOD_C_MPIH_LSHIFT, test "$mpi_mod_c_mpih_lshift" = yes) -AM_CONDITIONAL(MPI_MOD_C_MPIH_RSHIFT, test "$mpi_mod_c_mpih_rshift" = yes) -AM_CONDITIONAL(MPI_MOD_C_UDIV, test "$mpi_mod_c_udiv" = yes) -AM_CONDITIONAL(MPI_MOD_C_UDIV_QRNND, test "$mpi_mod_c_udiv_qrnnd" = yes) - if test mym4_isgit = "yes"; then AC_DEFINE(IS_DEVELOPMENT_VERSION,1, [Defined if this is not a regular release]) @@ -1498,6 +1557,14 @@ if test x"$neonsupport" = xyes ; then AC_DEFINE(ENABLE_NEON_SUPPORT,1, [Enable support for ARM NEON instructions.]) fi +if test x"$padlocksupport" = xyes ; then + AC_DEFINE(ENABLE_PADLOCK_SUPPORT, 1, + [Enable support for the PadLock engine.]) +fi +if test x"$drngsupport" = xyes ; then + AC_DEFINE(ENABLE_DRNG_SUPPORT, 1, + [Enable support for Intel DRNG (RDRAND instruction).]) +fi # Define conditional sources and config.h symbols depending on the diff --git a/mpi/config.links b/mpi/config.links index a79b03b..57e6c2a 100644 --- a/mpi/config.links +++ b/mpi/config.links @@ -21,6 +21,10 @@ # sourced by ../configure to get the list of files to link # this should set $mpi_ln_list. # Note: this is called from the above directory. +# +# Reguired variables: +# $ac_cv_sys_symbol_underscore +# $gcry_cv_gcc_arm_platform_as_ok mpi_sflags= mpi_extra_modules= @@ -39,7 +43,6 @@ mpi_optional_modules=`$AWK '/^#BEGIN_ASM_LIST/,/^#END_ASM_LIST/ { echo '/* created by config.links - do not edit */' >./mpi/asm-syntax.h echo "/* Host: ${host} */" >>./mpi/asm-syntax.h -if test "$try_asm_modules" = "yes" ; then case "${host}" in powerpc-apple-darwin* | \ i[34567]86*-*-openbsd[12]* | \ @@ -142,10 +145,10 @@ case "${host}" in mpi_cpu_arch="aarch64" ;; arm*-*-*) + mpi_cpu_arch="arm" if test "$gcry_cv_gcc_arm_platform_as_ok" = "yes" ; then echo '/* configured for arm */' >>./mpi/asm-syntax.h path="arm" - mpi_cpu_arch="arm" else echo '/* No assembler modules configured */' >>./mpi/asm-syntax.h path="" @@ -155,16 +158,19 @@ case "${host}" in echo '/* configured for HPPA (pa7000) */' >>./mpi/asm-syntax.h path="hppa1.1 hppa" mpi_extra_modules="udiv-qrnnd" + mpi_cpu_arch="hppa" ;; hppa1.0*-*-*) echo '/* configured for HPPA 1.0 */' >>./mpi/asm-syntax.h path="hppa" mpi_extra_modules="udiv-qrnnd" + mpi_cpu_arch="hppa" ;; hppa*-*-*) # assume pa7100 echo '/* configured for HPPA (pa7100) */' >>./mpi/asm-syntax.h path="pa7100 hppa1.1 hppa" mpi_extra_modules="udiv-qrnnd" + mpi_cpu_arch="hppa" ;; sparc64-*-linux-gnu) echo '/* No working assembler modules available */' >>./mpi/asm-syntax.h @@ -300,6 +306,7 @@ case "${host}" in mpi_sflags="-Wa,-mpwr" path="power" mpi_extra_modules="udiv-w-sdiv" + mpi_cpu_arch="ppc" ;; rs6000-*-* | \ power-*-* | \ @@ -333,13 +340,23 @@ case "${host}" in mpi_cpu_arch="ppc" ;; *) - echo '/* No assembler modules configured */' >>./mpi/asm-syntax.h + echo '/* Platform not known */' >>./mpi/asm-syntax.h path="" ;; esac -else - echo '/* Assembler modules disabled on request */' >>./mpi/asm-syntax.h + +# If asm modules are disabled reset the found variables but keep +# mpi_cpu_arch. +if test "$try_asm_modules" != "yes" ; then + echo '/* Assembler modules disabled on request */' >./mpi/asm-syntax.h path="" + mpi_sflags="" + mpi_extra_modules="" +fi + +# Make sure that mpi_cpu_arch is not the empty string. +if test x"$mpi_cpu_arch" = x ; then + mpi_cpu_arch="unknown" fi ----------------------------------------------------------------------- Summary of changes: configure.ac | 271 ++++++++++++++++++++++++++++++++++-------------------- mpi/config.links | 27 +++++- 2 files changed, 191 insertions(+), 107 deletions(-) hooks/post-receive -- The GNU crypto library http://git.gnupg.org From cvs at cvs.gnupg.org Fri Jan 24 17:44:07 2014 From: cvs at cvs.gnupg.org (by Werner Koch) Date: Fri, 24 Jan 2014 17:44:07 +0100 Subject: [git] GPG-ERROR - branch, master, updated. libgpg-error-1.12-16-gf209d16 Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Error codes used by GnuPG et al.". The branch, master has been updated via f209d163a8167caa6910cd367aba923f703ac69e (commit) via 4e8a88e7632b1f1d2b31ae738a159802549882c3 (commit) from e07538c0ed3c5cb3d870a490a4c12bef4375278a (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit f209d163a8167caa6910cd367aba923f703ac69e Author: Werner Koch Date: Thu Jan 9 19:14:09 2014 +0100 Make multi-threading flags available via gpg-error-config. * m4/threadlib.m4: Set THREADLIB_CPPFLAGS. * src/gpg-error-config.in: Add option --mt. * configure.ac: Add support for the --mt option. * src/gpg-error.m4: Add ac_subst GPG_ERROR_MT_CFLAGS and GPG_ERROR_MT_LIBS. -- Although, libgpg-error does not yet provide an API for multi-thread support, it is useful to add the already available detection to the config script. This allows the latest Libgcrypt to take advantage of this in its regression tests. In particular for the regression tests a gpgrt_thread functions would be useful and eventually added to libgpg-error. The new gpg-error.m4 script should already be used by other packages to be prepared for future updates. diff --git a/NEWS b/NEWS index c7f666b..87d7a86 100644 --- a/NEWS +++ b/NEWS @@ -1,7 +1,12 @@ Noteworthy changes in version 1.13 (unreleased) ----------------------------------------------- - Add a portable mutex API. + * Added a portable mutex API. + + * The AM_PATH_GPG_ERROR macro now defines GPG_ERROR_MT_CFLAGS and + GPG_ERROR_MT_LIBS autoconf output variables for use by programs + which need gpgrt based thread support. gpg-error-config has a new + option --mt. * Interface changes relative to the 1.12 release: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/configure.ac b/configure.ac index 21a36e9..e3fa795 100644 --- a/configure.ac +++ b/configure.ac @@ -179,11 +179,23 @@ GPG_ERROR_CONFIG_LIBS="-lgpg-error" if test "x$LIBTHREAD" != x; then GPG_ERROR_CONFIG_LIBS="${GPG_ERROR_CONFIG_LIBS} ${LIBTHREAD}" fi +if test "x$LIBMULTITHREAD" != x; then + GPG_ERROR_CONFIG_MT_LIBS="${LIBMULTITHREAD}" +else + GPG_ERROR_CONFIG_MT_LIBS="" +fi GPG_ERROR_CONFIG_CFLAGS="" +if test "x$THREADLIB_CPPFLAGS" != x; then + GPG_ERROR_CONFIG_MT_CFLAGS="${THREADLIB_CPPFLAGS}" +else + GPG_ERROR_CONFIG_MT_CFLAGS="" +fi GPG_ERROR_CONFIG_ISUBDIRAFTER="" GPG_ERROR_CONFIG_HOST="$host" AC_SUBST(GPG_ERROR_CONFIG_LIBS) AC_SUBST(GPG_ERROR_CONFIG_CFLAGS) +AC_SUBST(GPG_ERROR_CONFIG_MT_LIBS) +AC_SUBST(GPG_ERROR_CONFIG_MT_CFLAGS) AC_SUBST(GPG_ERROR_CONFIG_ISUBDIRAFTER) AC_SUBST(GPG_ERROR_CONFIG_HOST) diff --git a/m4/threadlib.m4 b/m4/threadlib.m4 index a91e819..b015365 100644 --- a/m4/threadlib.m4 +++ b/m4/threadlib.m4 @@ -1,4 +1,4 @@ -# threadlib.m4 serial 10 (gettext-0.18.2) modified by wk 2014-01-15. +# threadlib.m4 serial 10 (gettext-0.18.2) modified by wk 2014-01-24. dnl Copyright (C) 2005-2014 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -23,8 +23,8 @@ dnl Sets the variables LIBMULTITHREAD and LTLIBMULTITHREAD similarly, for dnl programs that really need multithread functionality. The difference dnl between LIBTHREAD and LIBMULTITHREAD is that on platforms supporting weak dnl symbols, typically LIBTHREAD="" whereas LIBMULTITHREAD="-lpthread". -dnl Adds to CPPFLAGS the flag -D_REENTRANT or -D_THREAD_SAFE if needed for -dnl multithread-safe programs. +dnl Sets THREADLIB_CPPFLAGS to -D_REENTRANT or -D_THREAD_SAFE if needed for +dnl multithread-safe programs and adds THREADLIB_CPPFLAGS to CPPFLAGS. AC_DEFUN([gl_THREADLIB_EARLY], [ @@ -49,6 +49,7 @@ AC_DEFUN([gl_THREADLIB_EARLY_BODY], [AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])], [AC_REQUIRE([AC_GNU_SOURCE])]) dnl Check for multithreading. + THREADLIB_CPPFLAGS="" m4_ifdef([gl_THREADLIB_DEFAULT_NO], [m4_divert_text([DEFAULTS], [gl_use_threads_default=no])], [m4_divert_text([DEFAULTS], [gl_use_threads_default=])]) @@ -89,17 +90,24 @@ changequote([,])dnl # 2. putting a flag into CPPFLAGS that has an effect on the linker # causes the AC_LINK_IFELSE test below to succeed unexpectedly, # leading to wrong values of LIBTHREAD and LTLIBTHREAD. - CPPFLAGS="$CPPFLAGS -D_REENTRANT" + THREADLIB_CPPFLAGS="$THREADLIB_CPPFLAGS -D_REENTRANT" ;; esac # Some systems optimize for single-threaded programs by default, and # need special flags to disable these optimizations. For example, the # definition of 'errno' in . case "$host_os" in - aix* | freebsd*) CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE" ;; - solaris*) CPPFLAGS="$CPPFLAGS -D_REENTRANT" ;; + aix* | freebsd*) + THREADLIB_CPPFLAGS="$THREADLIB_CPPFLAGS -D_THREAD_SAFE" + ;; + solaris*) + THREADLIB_CPPFLAGS="$THREADLIB_CPPFLAGS -D_REENTRANT" + ;; esac fi + if test x"$THREADLIB_CPPFLAGS" != x ; then + CPPFLAGS="$CPPFLAGS $THREADLIB_CPPFLAGS" + fi ]) dnl The guts of gl_THREADLIB. Needs to be expanded only once. diff --git a/src/gpg-error-config.in b/src/gpg-error-config.in index b132314..bc1c583 100644 --- a/src/gpg-error-config.in +++ b/src/gpg-error-config.in @@ -17,12 +17,14 @@ libdir=@libdir@ isubdirafter="@GPG_ERROR_CONFIG_ISUBDIRAFTER@" output="" +mt=no usage() { cat </dev/null` + GPG_ERROR_MT_LIBS=`$GPG_ERROR_CONFIG $gpg_error_config_args --mt --libs 2>/dev/null` AC_MSG_RESULT([yes ($gpg_error_config_version)]) ifelse([$2], , :, [$2]) gpg_error_config_host=`$GPG_ERROR_CONFIG $gpg_error_config_args --host 2>/dev/null || echo none` @@ -82,9 +90,13 @@ AC_DEFUN([AM_PATH_GPG_ERROR], else GPG_ERROR_CFLAGS="" GPG_ERROR_LIBS="" + GPG_ERROR_MT_CFLAGS="" + GPG_ERROR_MT_LIBS="" AC_MSG_RESULT(no) ifelse([$3], , :, [$3]) fi AC_SUBST(GPG_ERROR_CFLAGS) AC_SUBST(GPG_ERROR_LIBS) + AC_SUBST(GPG_ERROR_MT_CFLAGS) + AC_SUBST(GPG_ERROR_MT_LIBS) ]) commit 4e8a88e7632b1f1d2b31ae738a159802549882c3 Author: Werner Koch Date: Thu Jan 9 19:14:09 2014 +0100 Allow using gpgrt_lock_init on an unitialized variable. * src/posix-lock.c (gpgrt_lock_init): Detect unitialized lock var. * src/w32-lock.c (gpgrt_lock_init): Ditto. -- gpgrt_lock_init may be used for dynamically allocated locks. For example gpgrt_lock_t *lock = xcalloc (1, sizeof *lock); gpgrt_lock_init (lock); gpgrt_lock_lock (lock); foo (); gpgrt_lock_unlock (lock); gpgrt_lock_destroy (lock); free (lock); This patch actually allows for this. Signed-off-by: Werner Koch diff --git a/src/gpg-error.h.in b/src/gpg-error.h.in index adb796b..4bd28bf 100644 --- a/src/gpg-error.h.in +++ b/src/gpg-error.h.in @@ -291,7 +291,8 @@ gpg_error_from_syserror (void) #define GPGRT_LOCK_DEFINE(name) \ static gpgrt_lock_t name = GPGRT_LOCK_INITIALIZER - +/* NB: If GPGRT_LOCK_DEFINE is not used, zero out the lock variable + before passing it to gpgrt_lock_init. */ gpg_err_code_t gpgrt_lock_init (gpgrt_lock_t *lockhd); gpg_err_code_t gpgrt_lock_lock (gpgrt_lock_t *lockhd); gpg_err_code_t gpgrt_lock_unlock (gpgrt_lock_t *lockhd); diff --git a/src/posix-lock.c b/src/posix-lock.c index 363cc09..5b0cab5 100644 --- a/src/posix-lock.c +++ b/src/posix-lock.c @@ -116,9 +116,21 @@ get_lock_object (gpgrt_lock_t *lockhd) gpg_err_code_t gpgrt_lock_init (gpgrt_lock_t *lockhd) { - _gpgrt_lock_t *lock = get_lock_object (lockhd); + _gpgrt_lock_t *lock = (_gpgrt_lock_t*)lockhd; int rc; + /* If VERS is zero we assume that no static initialization has been + done, so we setup our ABI version right here. The caller might + have called us to test whether lock support is at all available. */ + if (!lock->vers) + { + if (sizeof (gpgrt_lock_t) < sizeof (_gpgrt_lock_t)) + abort (); + lock->vers = LOCK_ABI_VERSION; + } + else /* Run the usual check. */ + lock = get_lock_object (lockhd); + #if USE_POSIX_THREADS if (use_pthread_p()) { @@ -198,7 +210,7 @@ gpgrt_lock_destroy (gpgrt_lock_t *lockhd) rc = gpg_err_code_from_errno (rc); else { - /* Re-init the the mutex so that it can be re-used. */ + /* Re-init the mutex so that it can be re-used. */ gpgrt_lock_t tmp = GPGRT_LOCK_INITIALIZER; memcpy (lockhd, &tmp, sizeof tmp); } diff --git a/src/w32-lock.c b/src/w32-lock.c index 0ad9409..56a0ed5 100644 --- a/src/w32-lock.c +++ b/src/w32-lock.c @@ -52,10 +52,24 @@ get_lock_object (gpgrt_lock_t *lockhd) gpg_err_code_t gpgrt_lock_init (gpgrt_lock_t *lockhd) { - _gpgrt_lock_t *lock = get_lock_object (lockhd); + _gpgrt_lock_t *lock = (_gpgrt_lock_t*)lockhd; + + /* If VERS is zero we assume that no static initialization has been + done, so we setup our ABI version right here. The caller might + have called us to test whether lock support is at all available. */ + if (!lock->vers) + { + if (sizeof (gpgrt_lock_t) < sizeof (_gpgrt_lock_t)) + abort (); + lock->vers = LOCK_ABI_VERSION; + } + else /* Run the usual check. */ + { + lock = get_lock_object (lockhd); + if (sizeof (gpgrt_lock_t) < sizeof (_gpgrt_lock_t)) + abort (); + } - if (sizeof (gpgrt_lock_t) < sizeof (_gpgrt_lock_t)) - abort (); InitializeCriticalSection (&lock->csec); lock->initdone = 1; } ----------------------------------------------------------------------- Summary of changes: NEWS | 7 ++++++- configure.ac | 12 ++++++++++++ m4/threadlib.m4 | 20 ++++++++++++++------ src/gpg-error-config.in | 11 +++++++++++ src/gpg-error.h.in | 3 ++- src/gpg-error.m4 | 16 ++++++++++++++-- src/posix-lock.c | 16 ++++++++++++++-- src/w32-lock.c | 20 +++++++++++++++++--- 8 files changed, 90 insertions(+), 15 deletions(-) hooks/post-receive -- Error codes used by GnuPG et al. http://git.gnupg.org From cvs at cvs.gnupg.org Sat Jan 25 12:50:42 2014 From: cvs at cvs.gnupg.org (by Werner Koch) Date: Sat, 25 Jan 2014 12:50:42 +0100 Subject: [git] GPG-ERROR - branch, master, updated. libgpg-error-1.12-19-ge1aa030 Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Error codes used by GnuPG et al.". The branch, master has been updated via e1aa030d7655743f0c3cdd5f7b26ae1b4665fbc6 (commit) via 8e352780fd0e2fbc8f4c4971aae188d62df24d0a (commit) via 2e4c5963119dc02cac7b8f0dfb46572c43d1ebe7 (commit) from f209d163a8167caa6910cd367aba923f703ac69e (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit e1aa030d7655743f0c3cdd5f7b26ae1b4665fbc6 Author: Werner Koch Date: Thu Jan 9 19:14:09 2014 +0100 Add lock info for arm-unknown-linux-androideabi. * src/syscfg/lock-obj.arm-unknown-linux-androideabi.h: New. Provided by Hans-Christoph Steiner. * src/Makefile.am (lock_obj_pub): Add file. diff --git a/src/Makefile.am b/src/Makefile.am index 77ece16..0a8a59a 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -41,8 +41,8 @@ endif # Distributed lock object definitions for cross compilation. lock_obj_pub = \ - syscfg/lock-obj-pub.mingw32.h - + syscfg/lock-obj-pub.mingw32.h \ + syscfg/lock-obj.arm-unknown-linux-androideabi.h lib_LTLIBRARIES = libgpg-error.la include_HEADERS = gpg-error.h diff --git a/src/syscfg/lock-obj.arm-unknown-linux-androideabi.h b/src/syscfg/lock-obj.arm-unknown-linux-androideabi.h new file mode 100644 index 0000000..adcf46f --- /dev/null +++ b/src/syscfg/lock-obj.arm-unknown-linux-androideabi.h @@ -0,0 +1,21 @@ +## lock-obj.arm-unknown-linux-androideabi.h +## File created by gen-posix-lock-obj - DO NOT EDIT +## To be included by mkheader into gpg-error.h + +typedef struct +{ + long _vers; + union { + volatile char _priv[4]; + long _x_align; + long *_xp_align; + } u; +} gpgrt_lock_t; + +#define GPGRT_LOCK_INITIALIZER {1,{{0,0,0,0}}} +## +## Local Variables: +## mode: c +## buffer-read-only: t +## End: +## commit 8e352780fd0e2fbc8f4c4971aae188d62df24d0a Author: Werner Koch Date: Thu Jan 9 19:14:09 2014 +0100 tests: Call srand for each thread under Windows. * tests/t-lock.c (accountant_thread) [W32]: Call srand. diff --git a/tests/t-lock.c b/tests/t-lock.c index 91923fb..190d63e 100644 --- a/tests/t-lock.c +++ b/tests/t-lock.c @@ -164,6 +164,9 @@ accountant_thread (void *arg) (void)arg; +#ifdef _WIN32 + srand (time(NULL)*getpid()); /* Windows needs it per thread. */ +#endif for (i = 0; i < N_TRANSACTIONS; i++) { rc = gpgrt_lock_lock (&accounts_lock); commit 2e4c5963119dc02cac7b8f0dfb46572c43d1ebe7 Author: Werner Koch Date: Thu Jan 9 19:14:09 2014 +0100 Do not use the threadlib macros for Windows. * configure.ac: Move platform detection before gl_THREADLIB_EARLY. Do not use gl_THREADLIB for Windows. Signed-off-by: Werner Koch diff --git a/configure.ac b/configure.ac index e3fa795..77f235f 100644 --- a/configure.ac +++ b/configure.ac @@ -85,28 +85,6 @@ AC_PROG_AWK AC_CHECK_TOOL(AR, ar, :) AC_GNU_SOURCE -gl_THREADLIB_EARLY - - -LT_PREREQ([2.2.6]) -LT_INIT([win32-dll disable-static]) -LT_LANG([Windows Resource]) - - -# We need to compile and run a program on the build machine. -dnl The AC_PROG_CC_FOR_BUILD macro in the AC archive is broken for -dnl autoconf 2.57. -dnl AC_PROG_CC_FOR_BUILD -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]) - - # Set some internal variables depending on the platform for later use. have_w32_system=no have_w64_system=no @@ -128,6 +106,30 @@ case "${host}" in esac +if test "$have_w32_system" != yes; then + gl_THREADLIB_EARLY +fi + + +LT_PREREQ([2.2.6]) +LT_INIT([win32-dll disable-static]) +LT_LANG([Windows Resource]) + + +# We need to compile and run a program on the build machine. +dnl The AC_PROG_CC_FOR_BUILD macro in the AC archive is broken for +dnl autoconf 2.57. +dnl AC_PROG_CC_FOR_BUILD +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]) + + AH_BOTTOM([ /* Force using of NLS for W32 even if no libintl has been found. This is okay because we have our own gettext implementation for W32. */ @@ -166,11 +168,27 @@ AC_CHECK_FUNCS([flockfile]) AC_C_CONST -# Check for thread library -gl_LOCK -if test "$gl_threads_api" = posix; then - AC_CHECK_SIZEOF(pthread_mutex_t,,[AC_INCLUDES_DEFAULT - #include ]) +# Check for thread library. +# +# Windows has always thread support; thus we don't bother to test for +# it as it may lead to false results when cross building. +if test "$have_w32_system" = yes; then + AC_DEFINE([USE_WINDOWS_THREADS], [1]) + LIBTHREAD= + LTLIBTHREAD= + LIBMULTITHREAD= + LTLIBMULTITHREAD= + THREADLIB_CPPFLAGS="" + AC_SUBST([LIBTHREAD]) + AC_SUBST([LTLIBTHREAD]) + AC_SUBST([LIBMULTITHREAD]) + AC_SUBST([LTLIBMULTITHREAD]) +else + gl_LOCK + if test "$gl_threads_api" = posix; then + AC_CHECK_SIZEOF(pthread_mutex_t,,[AC_INCLUDES_DEFAULT + #include ]) + fi fi ----------------------------------------------------------------------- Summary of changes: configure.ac | 72 ++++++++++++-------- src/Makefile.am | 4 +- .../lock-obj.arm-unknown-linux-androideabi.h | 21 ++++++ tests/t-lock.c | 3 + 4 files changed, 71 insertions(+), 29 deletions(-) create mode 100644 src/syscfg/lock-obj.arm-unknown-linux-androideabi.h hooks/post-receive -- Error codes used by GnuPG et al. http://git.gnupg.org From cvs at cvs.gnupg.org Mon Jan 27 14:28:26 2014 From: cvs at cvs.gnupg.org (by Dmitry Eremin-Solenikov) Date: Mon, 27 Jan 2014 14:28:26 +0100 Subject: [git] GCRYPT - branch, master, updated. libgcrypt-1.6.0-46-g5d23e7b Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The GNU crypto library". The branch, master has been updated via 5d23e7b9a77421f3ebfda4a84c459a8729f3bb41 (commit) via f7df906171854b6b6506b82d4fee2c2ebb0327ea (commit) via 79da0358fd555361e1ce4202f55494a8918eb8ae (commit) via bf34bfa5c458ee5ece91f25e3b4194d768498ab6 (commit) via ff91ec934ed52294cddcd7dcfacc04721a0487bf (commit) via 24e65d715812cea28732397870cb1585b8435521 (commit) from 4ad3417acab5021db1f722c314314ce4b781833a (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 5d23e7b9a77421f3ebfda4a84c459a8729f3bb41 Author: Dmitry Eremin-Solenikov Date: Fri Jan 24 15:02:14 2014 +0400 Fix number of blocks passed used in _gcry_rmd160_mixblock * cipher/rmd160.c (_gcry_rmd160_mixblock): pass 1 to transform -- Currently _gcry_rmd160_mixblock() passes 64 as nblocks to transform() function, while passing only one block of data. This causes acess after the allocated data and tons of errors on each valgrind invokation. Signed-off-by: Dmitry Eremin-Solenikov This fixes commit 50b8c834. diff --git a/cipher/rmd160.c b/cipher/rmd160.c index 1a58ba6..2aba0fe 100644 --- a/cipher/rmd160.c +++ b/cipher/rmd160.c @@ -421,7 +421,7 @@ _gcry_rmd160_mixblock ( RMD160_CONTEXT *hd, void *blockof64byte ) { char *p = blockof64byte; - transform ( hd, blockof64byte, 64 ); + transform ( hd, blockof64byte, 1 ); #define X(a) do { *(u32*)p = hd->h##a ; p += 4; } while(0) X(0); X(1); commit f7df906171854b6b6506b82d4fee2c2ebb0327ea Author: Werner Koch Date: Thu Jan 9 19:14:09 2014 +0100 Small Windows build tweaks. * configure.ac (HAVE_PTHREAD): Do test when building for Windows. * tests/basic.c: Replace "%zi" by "%z" and a cast to make it work under Windows. Signed-off-by: Werner Koch diff --git a/configure.ac b/configure.ac index 4d16fc6..6254453 100644 --- a/configure.ac +++ b/configure.ac @@ -729,9 +729,11 @@ AC_SUBST(PTH_LIBS) # # Check whether pthreads is available # -AC_CHECK_LIB(pthread,pthread_create,have_pthread=yes) -if test "$have_pthread" = yes; then - AC_DEFINE(HAVE_PTHREAD, 1 ,[Define if we have pthread.]) +if test "$have_w32_system" != yes; then + AC_CHECK_LIB(pthread,pthread_create,have_pthread=yes) + if test "$have_pthread" = yes; then + AC_DEFINE(HAVE_PTHREAD, 1 ,[Define if we have pthread.]) + fi fi diff --git a/tests/basic.c b/tests/basic.c index 5fd7131..e85e4e1 100644 --- a/tests/basic.c +++ b/tests/basic.c @@ -4063,11 +4063,11 @@ check_digests (void) continue; } if (verbose) - fprintf (stderr, " checking %s [%i] for length %zi\n", + fprintf (stderr, " checking %s [%i] for length %d\n", gcry_md_algo_name (algos[i].md), algos[i].md, !strcmp (algos[i].data, "!")? - 1000000 : strlen(algos[i].data)); + 1000000 : (int)strlen(algos[i].data)); check_one_md (algos[i].md, algos[i].data, strlen (algos[i].data), algos[i].expect); @@ -4488,10 +4488,10 @@ check_hmac (void) } if (verbose) fprintf (stderr, - " checking %s [%i] for %zi byte key and %zi byte data\n", + " checking %s [%i] for %d byte key and %d byte data\n", gcry_md_algo_name (algos[i].md), algos[i].md, - strlen(algos[i].key), strlen(algos[i].data)); + (int)strlen(algos[i].key), (int)strlen(algos[i].data)); check_one_hmac (algos[i].md, algos[i].data, strlen (algos[i].data), algos[i].key, strlen(algos[i].key), @@ -5091,10 +5091,10 @@ check_mac (void) } if (verbose) fprintf (stderr, - " checking %s [%i] for %zi byte key and %zi byte data\n", + " checking %s [%i] for %d byte key and %d byte data\n", gcry_mac_algo_name (algos[i].algo), algos[i].algo, - strlen(algos[i].key), strlen(algos[i].data)); + (int)strlen(algos[i].key), (int)strlen(algos[i].data)); check_one_mac (algos[i].algo, algos[i].data, strlen (algos[i].data), algos[i].key, strlen(algos[i].key), algos[i].iv, commit 79da0358fd555361e1ce4202f55494a8918eb8ae Author: Werner Koch Date: Thu Jan 9 19:14:09 2014 +0100 Update gpg-error autoconf macros to fix threading problems. * m4/gpg-error.m4: Update to version 2014-01-24. * tests/Makefile.am (t_lock_LDADD): Use MT Libs. diff --git a/m4/gpg-error.m4 b/m4/gpg-error.m4 index eb5d7c4..053eceb 100644 --- a/m4/gpg-error.m4 +++ b/m4/gpg-error.m4 @@ -1,5 +1,5 @@ # gpg-error.m4 - autoconf macro to detect libgpg-error. -# Copyright (C) 2002, 2003, 2004 g10 Code GmbH +# Copyright (C) 2002, 2003, 2004, 2011, 2014 g10 Code GmbH # # This file is free software; as a special exception the author gives # unlimited permission to copy and/or distribute it, with or without @@ -8,26 +8,33 @@ # 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. +# +# Last-changed: 2014-01-24 + dnl AM_PATH_GPG_ERROR([MINIMUM-VERSION, dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]]) -dnl Test for libgpg-error and define GPG_ERROR_CFLAGS and GPG_ERROR_LIBS +dnl +dnl Test for libgpg-error and define GPG_ERROR_CFLAGS, GPG_ERROR_LIBS, +dnl GPG_ERROR_MT_CFLAGS, and GPG_ERROR_MT_LIBS. The _MT_ variants are +dnl used for programs requireding real multi thread support. dnl AC_DEFUN([AM_PATH_GPG_ERROR], -[ +[ AC_REQUIRE([AC_CANONICAL_HOST]) + gpg_error_config_prefix="" dnl --with-libgpg-error-prefix=PFX is the preferred name for this option, dnl since that is consistent with how our three siblings use the directory/ dnl package name in --with-$dir_name-prefix=PFX. AC_ARG_WITH(libgpg-error-prefix, - AC_HELP_STRING([--with-libgpg-error-prefix=PFX], - [prefix where GPG Error is installed (optional)]), - gpg_error_config_prefix="$withval", gpg_error_config_prefix="") + AC_HELP_STRING([--with-libgpg-error-prefix=PFX], + [prefix where GPG Error is installed (optional)]), + [gpg_error_config_prefix="$withval"]) dnl Accept --with-gpg-error-prefix and make it work the same as dnl --with-libgpg-error-prefix above, for backwards compatibility, dnl but do not document this old, inconsistently-named option. AC_ARG_WITH(gpg-error-prefix,, - gpg_error_config_prefix="$withval", gpg_error_config_prefix="") + [gpg_error_config_prefix="$withval"]) if test x$gpg_error_config_prefix != x ; then if test x${GPG_ERROR_CONFIG+set} != xset ; then @@ -39,7 +46,8 @@ AC_DEFUN([AM_PATH_GPG_ERROR], min_gpg_error_version=ifelse([$1], ,0.0,$1) AC_MSG_CHECKING(for GPG Error - version >= $min_gpg_error_version) ok=no - if test "$GPG_ERROR_CONFIG" != "no" ; then + if test "$GPG_ERROR_CONFIG" != "no" \ + && test -f "$GPG_ERROR_CONFIG" ; then req_major=`echo $min_gpg_error_version | \ sed 's/\([[0-9]]*\)\.\([[0-9]]*\)/\1/'` req_minor=`echo $min_gpg_error_version | \ @@ -62,12 +70,13 @@ AC_DEFUN([AM_PATH_GPG_ERROR], if test $ok = yes; then GPG_ERROR_CFLAGS=`$GPG_ERROR_CONFIG $gpg_error_config_args --cflags` GPG_ERROR_LIBS=`$GPG_ERROR_CONFIG $gpg_error_config_args --libs` + GPG_ERROR_MT_CFLAGS=`$GPG_ERROR_CONFIG $gpg_error_config_args --mt --cflags 2>/dev/null` + GPG_ERROR_MT_LIBS=`$GPG_ERROR_CONFIG $gpg_error_config_args --mt --libs 2>/dev/null` AC_MSG_RESULT([yes ($gpg_error_config_version)]) ifelse([$2], , :, [$2]) - if test x"$host" != x ; then - gpg_error_config_host=`$GPG_ERROR_CONFIG $gpg_error_config_args --host 2>/dev/null || echo none` - if test x"$gpg_error_config_host" != xnone ; then - if test x"$gpg_error_config_host" != x"$host" ; then + gpg_error_config_host=`$GPG_ERROR_CONFIG $gpg_error_config_args --host 2>/dev/null || echo none` + if test x"$gpg_error_config_host" != xnone ; then + if test x"$gpg_error_config_host" != x"$host" ; then AC_MSG_WARN([[ *** *** The config script $GPG_ERROR_CONFIG was @@ -76,15 +85,18 @@ AC_DEFUN([AM_PATH_GPG_ERROR], *** You may want to use the configure option --with-gpg-error-prefix *** to specify a matching config script. ***]]) - fi fi fi else GPG_ERROR_CFLAGS="" GPG_ERROR_LIBS="" + GPG_ERROR_MT_CFLAGS="" + GPG_ERROR_MT_LIBS="" AC_MSG_RESULT(no) ifelse([$3], , :, [$3]) fi AC_SUBST(GPG_ERROR_CFLAGS) AC_SUBST(GPG_ERROR_LIBS) + AC_SUBST(GPG_ERROR_MT_CFLAGS) + AC_SUBST(GPG_ERROR_MT_LIBS) ]) diff --git a/tests/Makefile.am b/tests/Makefile.am index ac5ab70..4cf7a44 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -46,9 +46,9 @@ AM_CPPFLAGS = -I../src -I$(top_srcdir)/src AM_CFLAGS = $(GPG_ERROR_CFLAGS) AM_LDFLAGS = -no-install -default_ldadd = \ +standard_ldadd = \ ../src/libgcrypt.la $(DL_LIBS) \ - ../compat/libcompat.la $(GPG_ERROR_LIBS) + ../compat/libcompat.la EXTRA_PROGRAMS = testapi pkbench noinst_PROGRAMS = $(tests_bin) $(tests_bin_last) fipsdrv rsacvt genhashdata @@ -58,5 +58,6 @@ EXTRA_DIST = README rsa-16k.key cavs_tests.sh cavs_driver.pl \ pkcs1v2-oaep.h pkcs1v2-pss.h pkcs1v2-v15c.h pkcs1v2-v15s.h \ t-ed25519.inp stopwatch.h hashtest-256g.in -LDADD = $(default_ldadd) -t_lock_LDADD = $(default_ldadd) $(LIBMULTITHREAD) +LDADD = $(standard_ldadd) $(GPG_ERROR_LIBS) +t_lock_LDADD = $(standard_ldadd) $(GPG_ERROR_MT_LIBS) +t_lock_CFLAGS = $(GPG_ERROR_MT_CFLAGS) commit bf34bfa5c458ee5ece91f25e3b4194d768498ab6 Author: Dmitry Eremin-Solenikov Date: Fri Jan 24 15:02:15 2014 +0400 tests: Pass -no-install to libtool * tests/Makefile.am: add AM_LDFLAGS = -no-install -- There is little point building tests with support for installation. Passing -no-install stops libtool from building wrapper scripts, thus allowing direct gdb/valgrind invocation on programs in tests/ subdirectory. Signed-off-by: Dmitry Eremin-Solenikov diff --git a/tests/Makefile.am b/tests/Makefile.am index f0a4633..ac5ab70 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -44,6 +44,7 @@ TESTS_ENVIRONMENT = GCRYPT_IN_REGRESSION_TEST=1 # a built header. AM_CPPFLAGS = -I../src -I$(top_srcdir)/src AM_CFLAGS = $(GPG_ERROR_CFLAGS) +AM_LDFLAGS = -no-install default_ldadd = \ ../src/libgcrypt.la $(DL_LIBS) \ commit ff91ec934ed52294cddcd7dcfacc04721a0487bf Author: Werner Koch Date: Thu Jan 9 19:14:09 2014 +0100 tests: Add a test for the internal locking * src/global.c (external_lock_test): New. (_gcry_vcontrol): Call new function with formerly reserved code 61. * tests/t-common.h: New. Taken from current libgpg-error. * tests/t-lock.c: New. Based on t-lock.c from libgpg-error. * configure.ac (HAVE_PTHREAD): Set macro to 1 if defined. (AC_CHECK_FUNCS): Check for flockfile. * tests/Makefile.am (tests_bin): Add t-lock. (noinst_HEADERS): Add t-common.h (LDADD): Move value to ... (default_ldadd): new. (t_lock_LDADD): New. -- Signed-off-by: Werner Koch (cherry picked from commit fa42c61a84996b6a7574c32233dfd8d9f254d93a) Resolved conflicts: * src/ath.c: Remove as not anymore used in 1.7. * tests/Makefile.am: Merge. Changes: * src/global.c (external_lock_test): Use the gpgrt function for locking. Changed subject because here we are only adding the test case. diff --git a/configure.ac b/configure.ac index 1d5027a..4d16fc6 100644 --- a/configure.ac +++ b/configure.ac @@ -731,7 +731,7 @@ AC_SUBST(PTH_LIBS) # AC_CHECK_LIB(pthread,pthread_create,have_pthread=yes) if test "$have_pthread" = yes; then - AC_DEFINE(HAVE_PTHREAD, ,[Define if we have pthread.]) + AC_DEFINE(HAVE_PTHREAD, 1 ,[Define if we have pthread.]) fi @@ -1364,7 +1364,7 @@ AC_CHECK_FUNCS(strtoul memmove stricmp atexit raise) # Other checks AC_CHECK_FUNCS(strerror rand mmap getpagesize sysconf waitpid wait4) AC_CHECK_FUNCS(gettimeofday getrusage gethrtime clock_gettime syslog) -AC_CHECK_FUNCS(fcntl ftruncate) +AC_CHECK_FUNCS(fcntl ftruncate flockfile) GNUPG_CHECK_MLOCK diff --git a/src/global.c b/src/global.c index b2b1de6..ec0cc3f 100644 --- a/src/global.c +++ b/src/global.c @@ -66,6 +66,8 @@ static gcry_handler_no_mem_t outofcore_handler; static void *outofcore_handler_value; static int no_secure_memory; +/* Prototypes. */ +static gpg_err_code_t external_lock_test (int cmd); @@ -607,7 +609,8 @@ _gcry_vcontrol (enum gcry_ctl_cmds cmd, va_list arg_ptr) _gcry_random_deinit_external_test (ctx); } break; - case 61: /* RFU */ + case 61: /* Run external lock test */ + rc = external_lock_test (va_arg (arg_ptr, int)); break; case 62: /* RFU */ break; @@ -1108,3 +1111,48 @@ _gcry_set_progress_handler (void (*cb)(void *,const char*,int, int, int), _gcry_register_primegen_progress (cb, cb_data); _gcry_register_random_progress (cb, cb_data); } + + + +/* This is a helper for the regression test suite to test Libgcrypt's locks. + It works using a one test lock with CMD controlling what to do: + + 30111 - Allocate and init lock + 30112 - Take lock + 30113 - Release lock + 30114 - Destroy lock. + + This function is used by tests/t-lock.c - it is not part of the + public API! + */ +static gpg_err_code_t +external_lock_test (int cmd) +{ + GPGRT_LOCK_DEFINE (testlock); + gpg_err_code_t rc = 0; + + switch (cmd) + { + case 30111: /* Init Lock. */ + rc = gpgrt_lock_init (&testlock); + break; + + case 30112: /* Take Lock. */ + rc = gpgrt_lock_lock (&testlock); + break; + + case 30113: /* Release Lock. */ + rc = gpgrt_lock_unlock (&testlock); + break; + + case 30114: /* Destroy Lock. */ + rc = gpgrt_lock_destroy (&testlock); + break; + + default: + rc = GPG_ERR_INV_OP; + break; + } + + return rc; +} diff --git a/tests/Makefile.am b/tests/Makefile.am index 884fb3d..f0a4633 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -20,7 +20,7 @@ tests_bin = \ version mpitests t-sexp t-convert \ - t-mpi-bit t-mpi-point curves \ + t-mpi-bit t-mpi-point curves t-lock \ prime basic keygen pubkey hmac hashtest t-kdf keygrip \ fips186-dsa aeswrap pkcs1v2 random dsa-rfc6979 t-ed25519 @@ -45,11 +45,17 @@ TESTS_ENVIRONMENT = GCRYPT_IN_REGRESSION_TEST=1 AM_CPPFLAGS = -I../src -I$(top_srcdir)/src AM_CFLAGS = $(GPG_ERROR_CFLAGS) -LDADD = ../src/libgcrypt.la $(DL_LIBS) ../compat/libcompat.la $(GPG_ERROR_LIBS) +default_ldadd = \ + ../src/libgcrypt.la $(DL_LIBS) \ + ../compat/libcompat.la $(GPG_ERROR_LIBS) EXTRA_PROGRAMS = testapi pkbench noinst_PROGRAMS = $(tests_bin) $(tests_bin_last) fipsdrv rsacvt genhashdata +noinst_HEADERS = t-common.h EXTRA_DIST = README rsa-16k.key cavs_tests.sh cavs_driver.pl \ pkcs1v2-oaep.h pkcs1v2-pss.h pkcs1v2-v15c.h pkcs1v2-v15s.h \ t-ed25519.inp stopwatch.h hashtest-256g.in + +LDADD = $(default_ldadd) +t_lock_LDADD = $(default_ldadd) $(LIBMULTITHREAD) diff --git a/tests/t-common.h b/tests/t-common.h new file mode 100644 index 0000000..288963d --- /dev/null +++ b/tests/t-common.h @@ -0,0 +1,99 @@ +/* t-common.h - Common code for the tests. + * Copyright (C) 2013 g10 Code GmbH + * + * This file is part of libgpg-error. + * + * libgpg-error is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * libgpg-error is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program; if not, see . + */ + +#include + +#include "../src/gcrypt.h" + +#ifndef PGM +# error Macro PGM not defined. +#endif + + +static int verbose; +static int debug; +static int errorcount; + + +static void +die (const char *format, ...) +{ + va_list arg_ptr ; + + fflush (stdout); +#ifdef HAVE_FLOCKFILE + flockfile (stderr); +#endif + fprintf (stderr, "%s: ", PGM); + va_start (arg_ptr, format) ; + vfprintf (stderr, format, arg_ptr); + va_end (arg_ptr); + if (*format && format[strlen(format)-1] != '\n') + putc ('\n', stderr); +#ifdef HAVE_FLOCKFILE + funlockfile (stderr); +#endif + exit (1); +} + + +static void +fail (const char *format, ...) +{ + va_list arg_ptr; + + fflush (stdout); +#ifdef HAVE_FLOCKFILE + flockfile (stderr); +#endif + fprintf (stderr, "%s: ", PGM); + va_start (arg_ptr, format); + vfprintf (stderr, format, arg_ptr); + va_end (arg_ptr); + if (*format && format[strlen(format)-1] != '\n') + putc ('\n', stderr); +#ifdef HAVE_FLOCKFILE + funlockfile (stderr); +#endif + errorcount++; + if (errorcount >= 50) + die ("stopped after 50 errors."); +} + + +static void +show (const char *format, ...) +{ + va_list arg_ptr; + + if (!verbose) + return; +#ifdef HAVE_FLOCKFILE + flockfile (stderr); +#endif + fprintf (stderr, "%s: ", PGM); + va_start (arg_ptr, format); + vfprintf (stderr, format, arg_ptr); + if (*format && format[strlen(format)-1] != '\n') + putc ('\n', stderr); + va_end (arg_ptr); +#ifdef HAVE_FLOCKFILE + funlockfile (stderr); +#endif +} diff --git a/tests/t-lock.c b/tests/t-lock.c new file mode 100644 index 0000000..c6c1e41 --- /dev/null +++ b/tests/t-lock.c @@ -0,0 +1,460 @@ +/* t-lock.c - Check the lock functions + * Copyright (C) 2014 g10 Code GmbH + * + * This file is part of Libgcrypt. + * + * Libgcrypt is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * Libgcrypt 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 . + */ + +#if HAVE_CONFIG_H +# include +#endif + +#include +#include +#include +#include +#include +#include +#if HAVE_PTHREAD +# include +#endif + +#define PGM "t-lock" + +#include "t-common.h" + +/* Mingw requires us to include windows.h after winsock2.h which is + included by gcrypt.h. */ +#ifdef _WIN32 +# include +#endif + +#ifdef _WIN32 +# define THREAD_RET_TYPE DWORD WINAPI +# define THREAD_RET_VALUE 0 +#else +# define THREAD_RET_TYPE void * +# define THREAD_RET_VALUE NULL +#endif + +#define PRIV_CTL_EXTERNAL_LOCK_TEST 61 +#define EXTERNAL_LOCK_TEST_INIT 30111 +#define EXTERNAL_LOCK_TEST_LOCK 30112 +#define EXTERNAL_LOCK_TEST_UNLOCK 30113 +#define EXTERNAL_LOCK_TEST_DESTROY 30114 + + +/* Number of threads to run. */ +#define N_NONCE_THREADS 8 +/* Number of interations. */ +#define N_NONCE_ITERATIONS 1000 +/* Requested nonce size. */ +#define NONCE_SIZE 11 + + +/* This tests works by having a a couple of accountant threads which do + random transactions between accounts and a revision threads which + checks that the balance of all accounts is invariant. The idea for + this check is due to Bruno Haible. */ +#define N_ACCOUNT 8 +#define ACCOUNT_VALUE 42 +static int account[N_ACCOUNT]; + +/* Number of transactions done by each accountant. */ +#define N_TRANSACTIONS 1000 + +/* Number of accountants to run. */ +#define N_ACCOUNTANTS 5 + +/* Maximum transaction value. A quite low value is used so that we + would get an integer overflow. */ +#define MAX_TRANSACTION_VALUE 50 + +/* Flag to tell the revision thread to finish. */ +static volatile int stop_revision_thread; + + +struct thread_arg_s +{ + int no; +}; + + + + +/* Wrapper functions to access Libgcrypt's internal test lock. */ +static void +external_lock_test_init (int line) +{ + gpg_error_t err; + + err = gcry_control (PRIV_CTL_EXTERNAL_LOCK_TEST, EXTERNAL_LOCK_TEST_INIT); + if (err) + fail ("init lock failed at %d: %s", line, gpg_strerror (err)); +} + +static void +external_lock_test_lock (int line) +{ + gpg_error_t err; + + err = gcry_control (PRIV_CTL_EXTERNAL_LOCK_TEST, EXTERNAL_LOCK_TEST_LOCK); + if (err) + fail ("taking lock failed at %d: %s", line, gpg_strerror (err)); +} + +static void +external_lock_test_unlock (int line) +{ + gpg_error_t err; + + err = gcry_control (PRIV_CTL_EXTERNAL_LOCK_TEST, EXTERNAL_LOCK_TEST_UNLOCK); + if (err) + fail ("releasing lock failed at %d: %s", line, gpg_strerror (err)); + +} + +static void +external_lock_test_destroy (int line) +{ + gpg_error_t err; + + err = gcry_control (PRIV_CTL_EXTERNAL_LOCK_TEST, EXTERNAL_LOCK_TEST_DESTROY); + if (err) + fail ("destroying lock failed at %d: %s", line, gpg_strerror (err)); +} + + + + +/* The nonce thread. We simply request a couple of nonces and + return. */ +static THREAD_RET_TYPE +nonce_thread (void *argarg) +{ + struct thread_arg_s *arg = argarg; + int i; + char nonce[NONCE_SIZE]; + + for (i = 0; i < N_NONCE_ITERATIONS; i++) + { + gcry_create_nonce (nonce, sizeof nonce); + if (i && !(i%100)) + show ("thread %d created %d nonces so far", arg->no, i); + } + + gcry_free (arg); + return THREAD_RET_VALUE; +} + + +/* To check our locking function we run several threads all accessing + the nonce functions. If this function returns we know that there + are no obvious deadlocks or failed lock initialization. */ +static void +check_nonce_lock (void) +{ + struct thread_arg_s *arg; +#ifdef _WIN32 + HANDLE threads[N_NONCE_THREADS]; + int i; + int rc; + + for (i=0; i < N_NONCE_THREADS; i++) + { + arg = gcry_xmalloc (sizeof *arg); + arg->no = i; + threads[i] = CreateThread (NULL, 0, nonce_thread, arg, 0, NULL); + if (!threads[i]) + die ("error creating nonce thread %d: rc=%d", + i, (int)GetLastError ()); + } + + for (i=0; i < N_NONCE_THREADS; i++) + { + rc = WaitForSingleObject (threads[i], INFINITE); + if (rc == WAIT_OBJECT_0) + show ("nonce thread %d has terminated", i); + else + fail ("waiting for nonce thread %d failed: %d", + i, (int)GetLastError ()); + CloseHandle (threads[i]); + } + +#elif HAVE_PTHREAD + pthread_t threads[N_NONCE_THREADS]; + int rc, i; + + for (i=0; i < N_NONCE_THREADS; i++) + { + arg = gcry_xmalloc (sizeof *arg); + arg->no = i; + pthread_create (&threads[i], NULL, nonce_thread, arg); + } + + for (i=0; i < N_NONCE_THREADS; i++) + { + rc = pthread_join (threads[i], NULL); + if (rc) + fail ("pthread_join failed for nonce thread %d: %s", + i, strerror (errno)); + else + show ("nonce thread %d has terminated", i); + } + +#endif /*!_WIN32*/ +} + + +/* Initialze all accounts. */ +static void +init_accounts (void) +{ + int i; + + for (i=0; i < N_ACCOUNT; i++) + account[i] = ACCOUNT_VALUE; +} + + +/* Check that the sum of all accounts matches the intial sum. */ +static void +check_accounts (void) +{ + int i, sum; + + sum = 0; + for (i = 0; i < N_ACCOUNT; i++) + sum += account[i]; + if (sum != N_ACCOUNT * ACCOUNT_VALUE) + die ("accounts out of balance"); +} + + +static void +print_accounts (void) +{ + int i; + + for (i=0; i < N_ACCOUNT; i++) + printf ("account %d: %6d\n", i, account[i]); +} + + +/* Get a a random integer value in the range 0 to HIGH. */ +static unsigned int +get_rand (int high) +{ + return (unsigned int)(1+(int)((double)(high+1)*rand ()/(RAND_MAX+1.0))) - 1; +} + + +/* Pick a random account. Note that this fucntion is not + thread-safe. */ +static int +pick_account (void) +{ + return get_rand (N_ACCOUNT - 1); +} + + +/* Pick a random value for a transaction. This is not thread-safe. */ +static int +pick_value (void) +{ + return get_rand (MAX_TRANSACTION_VALUE); +} + + +/* This is the revision department. */ +static THREAD_RET_TYPE +revision_thread (void *arg) +{ + (void)arg; + + while (!stop_revision_thread) + { + external_lock_test_lock (__LINE__); + check_accounts (); + external_lock_test_unlock (__LINE__); + } + return THREAD_RET_VALUE; +} + + +/* This is one of our accountants. */ +static THREAD_RET_TYPE +accountant_thread (void *arg) +{ + int i; + int acc1, acc2; + int value; + + (void)arg; + + for (i = 0; i < N_TRANSACTIONS; i++) + { + external_lock_test_lock (__LINE__); + acc1 = pick_account (); + acc2 = pick_account (); + value = pick_value (); + account[acc1] += value; + account[acc2] -= value; + external_lock_test_unlock (__LINE__); + } + return THREAD_RET_VALUE; +} + + +static void +run_test (void) +{ +#ifdef _WIN32 + HANDLE rthread; + HANDLE athreads[N_ACCOUNTANTS]; + int i; + int rc; + + external_lock_test_init (__LINE__); + stop_revision_thread = 0; + rthread = CreateThread (NULL, 0, revision_thread, NULL, 0, NULL); + if (!rthread) + die ("error creating revision thread: rc=%d", (int)GetLastError ()); + + for (i=0; i < N_ACCOUNTANTS; i++) + { + athreads[i] = CreateThread (NULL, 0, accountant_thread, NULL, 0, NULL); + if (!athreads[i]) + die ("error creating accountant thread %d: rc=%d", + i, (int)GetLastError ()); + } + + for (i=0; i < N_ACCOUNTANTS; i++) + { + rc = WaitForSingleObject (athreads[i], INFINITE); + if (rc == WAIT_OBJECT_0) + show ("accountant thread %d has terminated", i); + else + fail ("waiting for accountant thread %d failed: %d", + i, (int)GetLastError ()); + CloseHandle (athreads[i]); + } + stop_revision_thread = 1; + + rc = WaitForSingleObject (rthread, INFINITE); + if (rc == WAIT_OBJECT_0) + show ("revision thread has terminated"); + else + fail ("waiting for revision thread failed: %d", (int)GetLastError ()); + CloseHandle (rthread); + +#else /*!_WIN32*/ + pthread_t rthread; + pthread_t athreads[N_ACCOUNTANTS]; + int rc, i; + + external_lock_test_init (__LINE__); + stop_revision_thread = 0; + pthread_create (&rthread, NULL, revision_thread, NULL); + + for (i=0; i < N_ACCOUNTANTS; i++) + pthread_create (&athreads[i], NULL, accountant_thread, NULL); + + for (i=0; i < N_ACCOUNTANTS; i++) + { + rc = pthread_join (athreads[i], NULL); + if (rc) + fail ("pthread_join failed for accountant thread %d: %s", + i, strerror (errno)); + else + show ("accountant thread %d has terminated", i); + } + + stop_revision_thread = 1; + rc = pthread_join (rthread, NULL); + if (rc) + fail ("pthread_join failed for the revision thread: %s", strerror (errno)); + else + show ("revision thread has terminated"); + +#endif /*!_WIN32*/ + + external_lock_test_destroy (__LINE__); +} + + + +int +main (int argc, char **argv) +{ + int last_argc = -1; + + if (argc) + { + argc--; argv++; + } + while (argc && last_argc != argc ) + { + last_argc = argc; + if (!strcmp (*argv, "--help")) + { + puts ( +"usage: ./t-lock [options]\n" +"\n" +"Options:\n" +" --verbose Show what is going on\n" +" --debug Flyswatter\n" +); + exit (0); + } + if (!strcmp (*argv, "--verbose")) + { + verbose = 1; + argc--; argv++; + } + else if (!strcmp (*argv, "--debug")) + { + verbose = debug = 1; + argc--; argv++; + } + } + + srand (time(NULL)*getpid()); + + if (debug) + gcry_control (GCRYCTL_SET_DEBUG_FLAGS, 1u, 0); + gcry_control (GCRYCTL_DISABLE_SECMEM, 0); + if (!gcry_check_version (GCRYPT_VERSION)) + die ("version mismatch"); + gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0); + gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); + + check_nonce_lock (); + + init_accounts (); + check_accounts (); + + run_test (); + check_accounts (); + + /* Run a second time to check deinit code. */ + run_test (); + check_accounts (); + + if (verbose) + print_accounts (); + + return errorcount ? 1 : 0; +} commit 24e65d715812cea28732397870cb1585b8435521 Author: Werner Koch Date: Thu Jan 9 19:14:09 2014 +0100 Check compiler features only for the relevant platform. * mpi/config.links (mpi_cpu_arch): Always set for ARM. Set for HPPA. Set to "undefined" for unknown platforms. (try_asm_modules): Act upon only after having detected the CPU. * configure.ac: Move the call to config.links before the platform specific compiler checks. Check platform specific features only if the platform is targeted. -- There is no need to check x86 options if we are targeting ARM and vice versa. This may only introduce build problems. With this patch the summary output at the end of the compiler also shows more reasonable messages. Signed-off-by: Werner Koch (cherry picked from commit 04d478d9b0f92d80105ddaf2c011f40ae8260cfb) diff --git a/configure.ac b/configure.ac index c3ab96f..1d5027a 100644 --- a/configure.ac +++ b/configure.ac @@ -575,10 +575,6 @@ AC_ARG_ENABLE(padlock-support, [Disable support for the PadLock Engine of VIA processors]), padlocksupport=$enableval,padlocksupport=yes) AC_MSG_RESULT($padlocksupport) -if test x"$padlocksupport" = xyes ; then - AC_DEFINE(ENABLE_PADLOCK_SUPPORT, 1, - [Enable support for the PadLock engine.]) -fi # Implementation of the --disable-aesni-support switch. AC_MSG_CHECKING([whether AESNI support is requested]) @@ -603,10 +599,6 @@ AC_ARG_ENABLE(drng-support, [Disable support for the Intel DRNG (RDRAND instruction)]), drngsupport=$enableval,drngsupport=yes) AC_MSG_RESULT($drngsupport) -if test x"$drngsupport" = xyes ; then - AC_DEFINE(ENABLE_DRNG_SUPPORT, 1, - [Enable support for Intel DRNG (RDRAND instruction).]) -fi # Implementation of the --disable-avx-support switch. AC_MSG_CHECKING([whether AVX support is requested]) @@ -995,19 +987,121 @@ fi # +# Check whether GCC assembler supports features needed for our ARM +# implementations. This needs to be done before setting up the +# assembler stuff. +# +AC_CACHE_CHECK([whether GCC assembler is compatible for ARM assembly implementations], + [gcry_cv_gcc_arm_platform_as_ok], + [gcry_cv_gcc_arm_platform_as_ok=no + AC_COMPILE_IFELSE([AC_LANG_SOURCE( + [[__asm__( + /* Test if assembler supports UAL syntax. */ + ".syntax unified\n\t" + ".arm\n\t" /* our assembly code is in ARM mode */ + /* Following causes error if assembler ignored '.syntax unified'. */ + "asmfunc:\n\t" + "add %r0, %r0, %r4, ror #12;\n\t" + + /* Test if '.type' and '.size' are supported. */ + ".size asmfunc,.-asmfunc;\n\t" + ".type asmfunc,%function;\n\t" + );]])], + [gcry_cv_gcc_arm_platform_as_ok=yes])]) +if test "$gcry_cv_gcc_arm_platform_as_ok" = "yes" ; then + AC_DEFINE(HAVE_COMPATIBLE_GCC_ARM_PLATFORM_AS,1, + [Defined if underlying assembler is compatible with ARM assembly implementations]) +fi + + +# +# Check whether underscores in symbols are required. This needs to be +# done before setting up the assembler stuff. +# +GNUPG_SYS_SYMBOL_UNDERSCORE() + + +################################# +#### #### +#### Setup assembler stuff. #### +#### Define mpi_cpu_arch. #### +#### #### +################################# +AC_ARG_ENABLE(mpi-path, + AC_HELP_STRING([--enable-mpi-path=EXTRA_PATH], + [prepend EXTRA_PATH to list of CPU specific optimizations]), + mpi_extra_path="$enableval",mpi_extra_path="") +AC_MSG_CHECKING(architecture and mpi assembler functions) +if test -f $srcdir/mpi/config.links ; then + . $srcdir/mpi/config.links + AC_CONFIG_LINKS("$mpi_ln_list") + ac_cv_mpi_sflags="$mpi_sflags" + AC_MSG_RESULT($mpi_cpu_arch) +else + AC_MSG_RESULT(failed) + AC_MSG_ERROR([mpi/config.links missing!]) +fi +MPI_SFLAGS="$ac_cv_mpi_sflags" +AC_SUBST(MPI_SFLAGS) + +AM_CONDITIONAL(MPI_MOD_ASM_MPIH_ADD1, test "$mpi_mod_asm_mpih_add1" = yes) +AM_CONDITIONAL(MPI_MOD_ASM_MPIH_SUB1, test "$mpi_mod_asm_mpih_sub1" = yes) +AM_CONDITIONAL(MPI_MOD_ASM_MPIH_MUL1, test "$mpi_mod_asm_mpih_mul1" = yes) +AM_CONDITIONAL(MPI_MOD_ASM_MPIH_MUL2, test "$mpi_mod_asm_mpih_mul2" = yes) +AM_CONDITIONAL(MPI_MOD_ASM_MPIH_MUL3, test "$mpi_mod_asm_mpih_mul3" = yes) +AM_CONDITIONAL(MPI_MOD_ASM_MPIH_LSHIFT, test "$mpi_mod_asm_mpih_lshift" = yes) +AM_CONDITIONAL(MPI_MOD_ASM_MPIH_RSHIFT, test "$mpi_mod_asm_mpih_rshift" = yes) +AM_CONDITIONAL(MPI_MOD_ASM_UDIV, test "$mpi_mod_asm_udiv" = yes) +AM_CONDITIONAL(MPI_MOD_ASM_UDIV_QRNND, test "$mpi_mod_asm_udiv_qrnnd" = yes) +AM_CONDITIONAL(MPI_MOD_C_MPIH_ADD1, test "$mpi_mod_c_mpih_add1" = yes) +AM_CONDITIONAL(MPI_MOD_C_MPIH_SUB1, test "$mpi_mod_c_mpih_sub1" = yes) +AM_CONDITIONAL(MPI_MOD_C_MPIH_MUL1, test "$mpi_mod_c_mpih_mul1" = yes) +AM_CONDITIONAL(MPI_MOD_C_MPIH_MUL2, test "$mpi_mod_c_mpih_mul2" = yes) +AM_CONDITIONAL(MPI_MOD_C_MPIH_MUL3, test "$mpi_mod_c_mpih_mul3" = yes) +AM_CONDITIONAL(MPI_MOD_C_MPIH_LSHIFT, test "$mpi_mod_c_mpih_lshift" = yes) +AM_CONDITIONAL(MPI_MOD_C_MPIH_RSHIFT, test "$mpi_mod_c_mpih_rshift" = yes) +AM_CONDITIONAL(MPI_MOD_C_UDIV, test "$mpi_mod_c_udiv" = yes) +AM_CONDITIONAL(MPI_MOD_C_UDIV_QRNND, test "$mpi_mod_c_udiv_qrnnd" = yes) + +# Reset non applicable feature flags. +if test "$mpi_cpu_arch" != "x86" ; then + aesnisupport="n/a" + pclmulsupport="n/a" + avxsupport="n/a" + avx2support="n/a" + padlocksupport="n/a" + drngsupport="n/a" +fi + +if test "$mpi_cpu_arch" != "arm" ; then + neonsupport="n/a" +fi + + +############################################# +#### #### +#### Platform specific compiler checks. #### +#### #### +############################################# + +# # Check whether GCC inline assembler supports SSSE3 instructions # This is required for the AES-NI instructions. # AC_CACHE_CHECK([whether GCC inline assembler supports SSSE3 instructions], [gcry_cv_gcc_inline_asm_ssse3], - [gcry_cv_gcc_inline_asm_ssse3=no - AC_COMPILE_IFELSE([AC_LANG_SOURCE( + [if test "$mpi_cpu_arch" != "x86" ; then + gcry_cv_gcc_inline_asm_ssse3="n/a" + else + gcry_cv_gcc_inline_asm_ssse3=no + AC_COMPILE_IFELSE([AC_LANG_SOURCE( [[static unsigned char be_mask[16] __attribute__ ((aligned (16))) = { 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 }; void a(void) { __asm__("pshufb %[mask], %%xmm2\n\t"::[mask]"m"(*be_mask):); }]])], - [gcry_cv_gcc_inline_asm_ssse3=yes])]) + [gcry_cv_gcc_inline_asm_ssse3=yes]) + fi]) if test "$gcry_cv_gcc_inline_asm_ssse3" = "yes" ; then AC_DEFINE(HAVE_GCC_INLINE_ASM_SSSE3,1, [Defined if inline assembler supports SSSE3 instructions]) @@ -1019,12 +1113,16 @@ fi # AC_CACHE_CHECK([whether GCC inline assembler supports PCLMUL instructions], [gcry_cv_gcc_inline_asm_pclmul], - [gcry_cv_gcc_inline_asm_pclmul=no - AC_COMPILE_IFELSE([AC_LANG_SOURCE( + [if test "$mpi_cpu_arch" != "x86" ; then + gcry_cv_gcc_inline_asm_pclmul="n/a" + else + gcry_cv_gcc_inline_asm_pclmul=no + AC_COMPILE_IFELSE([AC_LANG_SOURCE( [[void a(void) { __asm__("pclmulqdq \$0, %%xmm1, %%xmm3\n\t":::"cc"); }]])], - [gcry_cv_gcc_inline_asm_pclmul=yes])]) + [gcry_cv_gcc_inline_asm_pclmul=yes]) + fi]) if test "$gcry_cv_gcc_inline_asm_pclmul" = "yes" ; then AC_DEFINE(HAVE_GCC_INLINE_ASM_PCLMUL,1, [Defined if inline assembler supports PCLMUL instructions]) @@ -1036,12 +1134,16 @@ fi # AC_CACHE_CHECK([whether GCC inline assembler supports AVX instructions], [gcry_cv_gcc_inline_asm_avx], - [gcry_cv_gcc_inline_asm_avx=no - AC_COMPILE_IFELSE([AC_LANG_SOURCE( + [if test "$mpi_cpu_arch" != "x86" ; then + gcry_cv_gcc_inline_asm_avx="n/a" + else + gcry_cv_gcc_inline_asm_avx=no + AC_COMPILE_IFELSE([AC_LANG_SOURCE( [[void a(void) { __asm__("xgetbv; vaesdeclast (%[mem]),%%xmm0,%%xmm7\n\t"::[mem]"r"(0):); }]])], - [gcry_cv_gcc_inline_asm_avx=yes])]) + [gcry_cv_gcc_inline_asm_avx=yes]) + fi]) if test "$gcry_cv_gcc_inline_asm_avx" = "yes" ; then AC_DEFINE(HAVE_GCC_INLINE_ASM_AVX,1, [Defined if inline assembler supports AVX instructions]) @@ -1053,12 +1155,16 @@ fi # AC_CACHE_CHECK([whether GCC inline assembler supports AVX2 instructions], [gcry_cv_gcc_inline_asm_avx2], - [gcry_cv_gcc_inline_asm_avx2=no - AC_COMPILE_IFELSE([AC_LANG_SOURCE( + [if test "$mpi_cpu_arch" != "x86" ; then + gcry_cv_gcc_inline_asm_avx2="n/a" + else + gcry_cv_gcc_inline_asm_avx2=no + AC_COMPILE_IFELSE([AC_LANG_SOURCE( [[void a(void) { __asm__("xgetbv; vpbroadcastb %%xmm7,%%ymm1\n\t":::"cc"); }]])], - [gcry_cv_gcc_inline_asm_avx2=yes])]) + [gcry_cv_gcc_inline_asm_avx2=yes]) + fi]) if test "$gcry_cv_gcc_inline_asm_avx2" = "yes" ; then AC_DEFINE(HAVE_GCC_INLINE_ASM_AVX2,1, [Defined if inline assembler supports AVX2 instructions]) @@ -1070,12 +1176,16 @@ fi # AC_CACHE_CHECK([whether GCC inline assembler supports BMI2 instructions], [gcry_cv_gcc_inline_asm_bmi2], - [gcry_cv_gcc_inline_asm_bmi2=no - AC_COMPILE_IFELSE([AC_LANG_SOURCE( + [if test "$mpi_cpu_arch" != "x86" ; then + gcry_cv_gcc_inline_asm_bmi2="n/a" + else + gcry_cv_gcc_inline_asm_bmi2=no + AC_COMPILE_IFELSE([AC_LANG_SOURCE( [[void a(void) { __asm__("rorxl \$23, %%eax, %%edx\\n\\t":::"memory"); }]])], - [gcry_cv_gcc_inline_asm_bmi2=yes])]) + [gcry_cv_gcc_inline_asm_bmi2=yes]) + fi]) if test "$gcry_cv_gcc_inline_asm_bmi2" = "yes" ; then AC_DEFINE(HAVE_GCC_INLINE_ASM_BMI2,1, [Defined if inline assembler supports BMI2 instructions]) @@ -1120,8 +1230,11 @@ fi if test $amd64_as_feature_detection = yes; then AC_CACHE_CHECK([whether GCC assembler is compatible for amd64 assembly implementations], [gcry_cv_gcc_amd64_platform_as_ok], - [gcry_cv_gcc_amd64_platform_as_ok=no - AC_COMPILE_IFELSE([AC_LANG_SOURCE( + [if test "$mpi_cpu_arch" != "x86" ; then + gcry_cv_gcc_amd64_platform_as_ok="n/a" + else + gcry_cv_gcc_amd64_platform_as_ok=no + AC_COMPILE_IFELSE([AC_LANG_SOURCE( [[__asm__( /* Test if '.type' and '.size' are supported. */ /* These work only on ELF targets. */ @@ -1137,7 +1250,8 @@ if test $amd64_as_feature_detection = yes; then * to be disable on this machine. */ "xorl \$(123456789/12345678), %ebp;\n\t" );]])], - [gcry_cv_gcc_amd64_platform_as_ok=yes])]) + [gcry_cv_gcc_amd64_platform_as_ok=yes]) + fi]) if test "$gcry_cv_gcc_amd64_platform_as_ok" = "yes" ; then AC_DEFINE(HAVE_COMPATIBLE_GCC_AMD64_PLATFORM_AS,1, [Defined if underlying assembler is compatible with amd64 assembly implementations]) @@ -1151,8 +1265,11 @@ fi # AC_CACHE_CHECK([whether GCC assembler is compatible for Intel syntax assembly implementations], [gcry_cv_gcc_platform_as_ok_for_intel_syntax], - [gcry_cv_gcc_platform_as_ok_for_intel_syntax=no - AC_COMPILE_IFELSE([AC_LANG_SOURCE( + [if test "$mpi_cpu_arch" != "x86" ; then + gcry_cv_gcc_platform_as_ok_for_intel_syntax="n/a" + else + gcry_cv_gcc_platform_as_ok_for_intel_syntax=no + AC_COMPILE_IFELSE([AC_LANG_SOURCE( [[__asm__( ".intel_syntax noprefix\n\t" "pxor xmm1, xmm7;\n\t" @@ -1172,7 +1289,8 @@ AC_CACHE_CHECK([whether GCC assembler is compatible for Intel syntax assembly im "add VAL_A, VAL_B;\n\t" "add VAL_B, 0b10101;\n\t" );]])], - [gcry_cv_gcc_platform_as_ok_for_intel_syntax=yes])]) + [gcry_cv_gcc_platform_as_ok_for_intel_syntax=yes]) + fi]) if test "$gcry_cv_gcc_platform_as_ok_for_intel_syntax" = "yes" ; then AC_DEFINE(HAVE_INTEL_SYNTAX_PLATFORM_AS,1, [Defined if underlying assembler is compatible with Intel syntax assembly implementations]) @@ -1184,7 +1302,10 @@ fi # AC_CACHE_CHECK([whether compiler is configured for ARMv6 or newer architecture], [gcry_cv_cc_arm_arch_is_v6], - [AC_EGREP_CPP(yes, + [if test "$mpi_cpu_arch" != "arm" ; then + gcry_cv_cc_arm_arch_is_v6="n/a" + else + AC_EGREP_CPP(yes, [#if defined(__arm__) && \ ((defined(__ARM_ARCH) && __ARM_ARCH >= 6) \ || defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) \ @@ -1195,7 +1316,8 @@ AC_CACHE_CHECK([whether compiler is configured for ARMv6 or newer architecture], || defined(__ARM_ARCH_7EM__)) yes #endif - ], gcry_cv_cc_arm_arch_is_v6=yes, gcry_cv_cc_arm_arch_is_v6=no)]) + ], gcry_cv_cc_arm_arch_is_v6=yes, gcry_cv_cc_arm_arch_is_v6=no) + fi]) if test "$gcry_cv_cc_arm_arch_is_v6" = "yes" ; then AC_DEFINE(HAVE_ARM_ARCH_V6,1, [Defined if ARM architecture is v6 or newer]) @@ -1207,8 +1329,11 @@ fi # AC_CACHE_CHECK([whether GCC inline assembler supports NEON instructions], [gcry_cv_gcc_inline_asm_neon], - [gcry_cv_gcc_inline_asm_neon=no - AC_COMPILE_IFELSE([AC_LANG_SOURCE( + [if test "$mpi_cpu_arch" != "arm" ; then + gcry_cv_gcc_inline_asm_neon="n/a" + else + gcry_cv_gcc_inline_asm_neon=no + AC_COMPILE_IFELSE([AC_LANG_SOURCE( [[__asm__( ".syntax unified\n\t" ".thumb\n\t" @@ -1219,40 +1344,14 @@ AC_CACHE_CHECK([whether GCC inline assembler supports NEON instructions], "vadd.s64 %d3, %d2, %d3;\n\t" ); ]])], - [gcry_cv_gcc_inline_asm_neon=yes])]) + [gcry_cv_gcc_inline_asm_neon=yes]) + fi]) if test "$gcry_cv_gcc_inline_asm_neon" = "yes" ; then AC_DEFINE(HAVE_GCC_INLINE_ASM_NEON,1, [Defined if inline assembler supports NEON instructions]) fi -# -# Check whether GCC assembler supports features needed for our ARM -# implementations -# -AC_CACHE_CHECK([whether GCC assembler is compatible for ARM assembly implementations], - [gcry_cv_gcc_arm_platform_as_ok], - [gcry_cv_gcc_arm_platform_as_ok=no - AC_COMPILE_IFELSE([AC_LANG_SOURCE( - [[__asm__( - /* Test if assembler supports UAL syntax. */ - ".syntax unified\n\t" - ".arm\n\t" /* our assembly code is in ARM mode */ - /* Following causes error if assembler ignored '.syntax unified'. */ - "asmfunc:\n\t" - "add %r0, %r0, %r4, ror #12;\n\t" - - /* Test if '.type' and '.size' are supported. */ - ".size asmfunc,.-asmfunc;\n\t" - ".type asmfunc,%function;\n\t" - );]])], - [gcry_cv_gcc_arm_platform_as_ok=yes])]) -if test "$gcry_cv_gcc_arm_platform_as_ok" = "yes" ; then - AC_DEFINE(HAVE_COMPATIBLE_GCC_ARM_PLATFORM_AS,1, - [Defined if underlying assembler is compatible with ARM assembly implementations]) -fi - - ####################################### #### Checks for library functions. #### ####################################### @@ -1368,48 +1467,8 @@ fi # -# Setup assembler stuff. -# -# Note that config.links also defines mpi_cpu_arch, which is required -# later on. +# Other defines # -GNUPG_SYS_SYMBOL_UNDERSCORE() -AC_ARG_ENABLE(mpi-path, - AC_HELP_STRING([--enable-mpi-path=EXTRA_PATH], - [prepend EXTRA_PATH to list of CPU specific optimizations]), - mpi_extra_path="$enableval",mpi_extra_path="") -AC_MSG_CHECKING(for mpi assembler functions) -if test -f $srcdir/mpi/config.links ; then - . $srcdir/mpi/config.links - AC_CONFIG_LINKS("$mpi_ln_list") - ac_cv_mpi_sflags="$mpi_sflags" - AC_MSG_RESULT(done) -else - AC_MSG_RESULT(failed) - AC_MSG_ERROR([mpi/config.links missing!]) -fi -MPI_SFLAGS="$ac_cv_mpi_sflags" -AC_SUBST(MPI_SFLAGS) - -AM_CONDITIONAL(MPI_MOD_ASM_MPIH_ADD1, test "$mpi_mod_asm_mpih_add1" = yes) -AM_CONDITIONAL(MPI_MOD_ASM_MPIH_SUB1, test "$mpi_mod_asm_mpih_sub1" = yes) -AM_CONDITIONAL(MPI_MOD_ASM_MPIH_MUL1, test "$mpi_mod_asm_mpih_mul1" = yes) -AM_CONDITIONAL(MPI_MOD_ASM_MPIH_MUL2, test "$mpi_mod_asm_mpih_mul2" = yes) -AM_CONDITIONAL(MPI_MOD_ASM_MPIH_MUL3, test "$mpi_mod_asm_mpih_mul3" = yes) -AM_CONDITIONAL(MPI_MOD_ASM_MPIH_LSHIFT, test "$mpi_mod_asm_mpih_lshift" = yes) -AM_CONDITIONAL(MPI_MOD_ASM_MPIH_RSHIFT, test "$mpi_mod_asm_mpih_rshift" = yes) -AM_CONDITIONAL(MPI_MOD_ASM_UDIV, test "$mpi_mod_asm_udiv" = yes) -AM_CONDITIONAL(MPI_MOD_ASM_UDIV_QRNND, test "$mpi_mod_asm_udiv_qrnnd" = yes) -AM_CONDITIONAL(MPI_MOD_C_MPIH_ADD1, test "$mpi_mod_c_mpih_add1" = yes) -AM_CONDITIONAL(MPI_MOD_C_MPIH_SUB1, test "$mpi_mod_c_mpih_sub1" = yes) -AM_CONDITIONAL(MPI_MOD_C_MPIH_MUL1, test "$mpi_mod_c_mpih_mul1" = yes) -AM_CONDITIONAL(MPI_MOD_C_MPIH_MUL2, test "$mpi_mod_c_mpih_mul2" = yes) -AM_CONDITIONAL(MPI_MOD_C_MPIH_MUL3, test "$mpi_mod_c_mpih_mul3" = yes) -AM_CONDITIONAL(MPI_MOD_C_MPIH_LSHIFT, test "$mpi_mod_c_mpih_lshift" = yes) -AM_CONDITIONAL(MPI_MOD_C_MPIH_RSHIFT, test "$mpi_mod_c_mpih_rshift" = yes) -AM_CONDITIONAL(MPI_MOD_C_UDIV, test "$mpi_mod_c_udiv" = yes) -AM_CONDITIONAL(MPI_MOD_C_UDIV_QRNND, test "$mpi_mod_c_udiv_qrnnd" = yes) - if test mym4_isgit = "yes"; then AC_DEFINE(IS_DEVELOPMENT_VERSION,1, [Defined if this is not a regular release]) @@ -1538,6 +1597,14 @@ if test x"$neonsupport" = xyes ; then AC_DEFINE(ENABLE_NEON_SUPPORT,1, [Enable support for ARM NEON instructions.]) fi +if test x"$padlocksupport" = xyes ; then + AC_DEFINE(ENABLE_PADLOCK_SUPPORT, 1, + [Enable support for the PadLock engine.]) +fi +if test x"$drngsupport" = xyes ; then + AC_DEFINE(ENABLE_DRNG_SUPPORT, 1, + [Enable support for Intel DRNG (RDRAND instruction).]) +fi # Define conditional sources and config.h symbols depending on the diff --git a/mpi/config.links b/mpi/config.links index a79b03b..57e6c2a 100644 --- a/mpi/config.links +++ b/mpi/config.links @@ -21,6 +21,10 @@ # sourced by ../configure to get the list of files to link # this should set $mpi_ln_list. # Note: this is called from the above directory. +# +# Reguired variables: +# $ac_cv_sys_symbol_underscore +# $gcry_cv_gcc_arm_platform_as_ok mpi_sflags= mpi_extra_modules= @@ -39,7 +43,6 @@ mpi_optional_modules=`$AWK '/^#BEGIN_ASM_LIST/,/^#END_ASM_LIST/ { echo '/* created by config.links - do not edit */' >./mpi/asm-syntax.h echo "/* Host: ${host} */" >>./mpi/asm-syntax.h -if test "$try_asm_modules" = "yes" ; then case "${host}" in powerpc-apple-darwin* | \ i[34567]86*-*-openbsd[12]* | \ @@ -142,10 +145,10 @@ case "${host}" in mpi_cpu_arch="aarch64" ;; arm*-*-*) + mpi_cpu_arch="arm" if test "$gcry_cv_gcc_arm_platform_as_ok" = "yes" ; then echo '/* configured for arm */' >>./mpi/asm-syntax.h path="arm" - mpi_cpu_arch="arm" else echo '/* No assembler modules configured */' >>./mpi/asm-syntax.h path="" @@ -155,16 +158,19 @@ case "${host}" in echo '/* configured for HPPA (pa7000) */' >>./mpi/asm-syntax.h path="hppa1.1 hppa" mpi_extra_modules="udiv-qrnnd" + mpi_cpu_arch="hppa" ;; hppa1.0*-*-*) echo '/* configured for HPPA 1.0 */' >>./mpi/asm-syntax.h path="hppa" mpi_extra_modules="udiv-qrnnd" + mpi_cpu_arch="hppa" ;; hppa*-*-*) # assume pa7100 echo '/* configured for HPPA (pa7100) */' >>./mpi/asm-syntax.h path="pa7100 hppa1.1 hppa" mpi_extra_modules="udiv-qrnnd" + mpi_cpu_arch="hppa" ;; sparc64-*-linux-gnu) echo '/* No working assembler modules available */' >>./mpi/asm-syntax.h @@ -300,6 +306,7 @@ case "${host}" in mpi_sflags="-Wa,-mpwr" path="power" mpi_extra_modules="udiv-w-sdiv" + mpi_cpu_arch="ppc" ;; rs6000-*-* | \ power-*-* | \ @@ -333,13 +340,23 @@ case "${host}" in mpi_cpu_arch="ppc" ;; *) - echo '/* No assembler modules configured */' >>./mpi/asm-syntax.h + echo '/* Platform not known */' >>./mpi/asm-syntax.h path="" ;; esac -else - echo '/* Assembler modules disabled on request */' >>./mpi/asm-syntax.h + +# If asm modules are disabled reset the found variables but keep +# mpi_cpu_arch. +if test "$try_asm_modules" != "yes" ; then + echo '/* Assembler modules disabled on request */' >./mpi/asm-syntax.h path="" + mpi_sflags="" + mpi_extra_modules="" +fi + +# Make sure that mpi_cpu_arch is not the empty string. +if test x"$mpi_cpu_arch" = x ; then + mpi_cpu_arch="unknown" fi ----------------------------------------------------------------------- Summary of changes: cipher/rmd160.c | 2 +- configure.ac | 281 ++++++++++++++++++++------------ m4/gpg-error.m4 | 38 +++-- mpi/config.links | 27 +++- src/global.c | 50 +++++- tests/Makefile.am | 12 +- tests/basic.c | 12 +- tests/t-common.h | 99 ++++++++++++ tests/t-lock.c | 460 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 9 files changed, 847 insertions(+), 134 deletions(-) create mode 100644 tests/t-common.h create mode 100644 tests/t-lock.c hooks/post-receive -- The GNU crypto library http://git.gnupg.org From cvs at cvs.gnupg.org Mon Jan 27 14:35:36 2014 From: cvs at cvs.gnupg.org (by Dmitry Eremin-Solenikov) Date: Mon, 27 Jan 2014 14:35:36 +0100 Subject: [git] GCRYPT - branch, master, updated. libgcrypt-1.6.0-48-g5c150ec Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The GNU crypto library". The branch, master has been updated via 5c150ece094bf0a504a111ce6c7b72e8d0b0457a (commit) via 6d87e6abdfb7552323a95401f14e6367398a3e5a (commit) from 5d23e7b9a77421f3ebfda4a84c459a8729f3bb41 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 5c150ece094bf0a504a111ce6c7b72e8d0b0457a Author: Dmitry Eremin-Solenikov Date: Sat Jan 25 03:21:39 2014 +0400 Fix most of memory leaks in tests code * tests/basic.c (check_ccm_cipher): Close cipher after use. * tests/basic.c (check_one_cipher): Correct length of used buffer. * tests/benchmark.c (cipher_bench): Use xcalloc to make buffer initialized. * tests/keygen.c (check_ecc_keys): Release generated key. * tests/t-mpi-point.c (context_param): Release mpi Q. * tests/t-sexp.c (check_extract_param): Release extracted number. -- The only remaining reported memory leak is one expected leak from mpitests.c. Signed-off-by: Dmitry Eremin-Solenikov diff --git a/tests/basic.c b/tests/basic.c index e85e4e1..4474a9d 100644 --- a/tests/basic.c +++ b/tests/basic.c @@ -2213,6 +2213,8 @@ check_ccm_cipher (void) if (memcmp (buf, tag, taglen) != 0) fail ("cipher-ccm-large, encrypt mismatch entry\n"); + + gcry_cipher_close (hde); } #if 0 @@ -2305,6 +2307,8 @@ check_ccm_cipher (void) if (memcmp (buf, tag, taglen) != 0) fail ("cipher-ccm-huge, encrypt mismatch entry\n"); + + gcry_cipher_close (hde); } if (verbose) @@ -3496,7 +3500,7 @@ check_one_cipher (int algo, int mode, int flags) return; /* Pass 2: Key not aligned and data not aligned. */ - memmove (plain+1, plain, 1024); + memmove (plain+1, plain, 1040); if (check_one_cipher_core (algo, mode, flags, key+1, 32, plain+1, 1040, bufshift, 2+10*bufshift)) return; diff --git a/tests/benchmark.c b/tests/benchmark.c index e009c22..5efc083 100644 --- a/tests/benchmark.c +++ b/tests/benchmark.c @@ -656,7 +656,7 @@ cipher_bench ( const char *algoname ) } repetitions *= cipher_repetitions; - raw_buf = gcry_xmalloc (allocated_buflen+15); + raw_buf = gcry_xcalloc (allocated_buflen+15, 1); buf = (raw_buf + ((16 - ((size_t)raw_buf & 0x0f)) % buffer_alignment)); outbuf = raw_outbuf = gcry_xmalloc (allocated_buflen+15); diff --git a/tests/keygen.c b/tests/keygen.c index e8cf7c5..4aff9c9 100644 --- a/tests/keygen.c +++ b/tests/keygen.c @@ -413,6 +413,7 @@ check_ecc_keys (void) show_sexp ("ECC key:\n", key); check_generated_ecc_key (key); + gcry_sexp_release (key); if (verbose) show ("creating ECC key using curve Ed25519 for ECDSA (nocomp)\n"); diff --git a/tests/mpitests.c b/tests/mpitests.c index 9d1206e..d75aca9 100644 --- a/tests/mpitests.c +++ b/tests/mpitests.c @@ -212,6 +212,7 @@ test_opaque (void) if (debug) gcry_log_debugmpi ("mpi", a); + gcry_mpi_release (a); p = gcry_xstrdup ("This is a test buffer"); a = gcry_mpi_set_opaque_copy (NULL, p, 21*8+1); diff --git a/tests/t-mpi-point.c b/tests/t-mpi-point.c index d60b3f0..88bb5bd 100644 --- a/tests/t-mpi-point.c +++ b/tests/t-mpi-point.c @@ -601,6 +601,7 @@ context_param (void) if (err) fail ("setting Q for nistp256 failed: %s\n", gpg_strerror (err)); get_and_cmp_mpi ("q", sample_p256_q, "nistp256(2)", ctx); + gcry_mpi_release (q); /* Get as s-expression. */ err = gcry_pubkey_get_sexp (&sexp, 0, ctx); diff --git a/tests/t-sexp.c b/tests/t-sexp.c index ec8b280..4c48277 100644 --- a/tests/t-sexp.c +++ b/tests/t-sexp.c @@ -1035,6 +1035,7 @@ check_extract_param (void) gcry_log_debugmpi (" got", mpis[0]); } + gcry_free (ioarray[0].data); gcry_mpi_release (mpis[0]); gcry_sexp_release (sxp); commit 6d87e6abdfb7552323a95401f14e6367398a3e5a Author: Dmitry Eremin-Solenikov Date: Sat Jan 25 03:21:38 2014 +0400 Fix memory leaks in ecc code * cipher/ecc-curves.c (_gcry_ecc_update_curve_param): Release passed mpi values. * cipher/ecc.c (compute_keygrip): Fix potential memory leak in error path. * cipher/ecc.c (_gcry_ecc_get_curve): Release temporary mpi. -- ==11657== 252 (80 direct, 172 indirect) bytes in 4 blocks are definitely lost in loss record 8 of 8 ==11657== at 0x4028A28: malloc (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so) ==11657== by 0x404178F: _gcry_private_malloc (stdmem.c:113) ==11657== by 0x403CED1: do_malloc.constprop.4 (global.c:768) ==11657== by 0x403DD01: _gcry_xmalloc (global.c:790) ==11657== by 0x409EAE0: _gcry_mpi_alloc (mpiutil.c:84) ==11657== by 0x409C4E4: _gcry_mpi_scan (mpicoder.c:466) ==11657== by 0x404009C: _gcry_sexp_nth_mpi (sexp.c:796) ==11657== by 0x40410B5: _gcry_sexp_vextract_param (sexp.c:2327) ==11657== by 0x4041396: _gcry_sexp_extract_param (sexp.c:2378) ==11657== by 0x407B895: compute_keygrip (ecc.c:1492) ==11657== by 0x404BBE8: _gcry_pk_get_keygrip (pubkey.c:674) ==11657== by 0x403B1BF: gcry_pk_get_keygrip (visibility.c:1056) ==16502== 144 (60 direct, 84 indirect) bytes in 3 blocks are definitely lost in loss record 3 of 7 ==16502== at 0x4028A28: malloc (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so) ==16502== by 0x404B4DE: _gcry_private_malloc (stdmem.c:113) ==16502== by 0x404667B: do_malloc (global.c:768) ==16502== by 0x40466E7: _gcry_malloc (global.c:790) ==16502== by 0x4046A55: _gcry_xmalloc (global.c:944) ==16502== by 0x40CD25B: _gcry_mpi_alloc (mpiutil.c:84) ==16502== by 0x40CAC3E: _gcry_mpi_scan (mpicoder.c:548) ==16502== by 0x40A72B2: scanval (ecc-curves.c:432) ==16502== by 0x40A7B0D: _gcry_ecc_get_curve (ecc-curves.c:685) ==16502== by 0x4058164: _gcry_pk_get_curve (pubkey.c:747) ==16502== by 0x4043E14: gcry_pk_get_curve (visibility.c:1067) ==16502== by 0x8048934: check_matching (curves.c:124) Signed-off-by: Dmitry Eremin-Solenikov diff --git a/cipher/ecc-curves.c b/cipher/ecc-curves.c index dc74ee0..0f622f7 100644 --- a/cipher/ecc-curves.c +++ b/cipher/ecc-curves.c @@ -575,6 +575,7 @@ _gcry_ecc_update_curve_param (const char *name, return gpg_err_code_from_syserror (); strcpy (stpcpy (stpcpy (buf, "0x04"), domain_parms[idx].g_x+2), domain_parms[idx].g_y+2); + _gcry_mpi_release (*g); *g = scanval (buf); xfree (buf); } @@ -583,13 +584,25 @@ _gcry_ecc_update_curve_param (const char *name, if (dialect) *dialect = domain_parms[idx].dialect; if (p) - *p = scanval (domain_parms[idx].p); + { + _gcry_mpi_release (*p); + *p = scanval (domain_parms[idx].p); + } if (a) - *a = scanval (domain_parms[idx].a); + { + _gcry_mpi_release (*a); + *a = scanval (domain_parms[idx].a); + } if (b) - *b = scanval (domain_parms[idx].b); + { + _gcry_mpi_release (*b); + *b = scanval (domain_parms[idx].b); + } if (n) - *n = scanval (domain_parms[idx].n); + { + _gcry_mpi_release (*n); + *n = scanval (domain_parms[idx].n); + } return 0; } @@ -669,6 +682,7 @@ _gcry_ecc_get_curve (gcry_sexp_t keyparms, int iterator, unsigned int *r_nbits) for (idx = 0; domain_parms[idx].desc; idx++) { + mpi_free (tmp); tmp = scanval (domain_parms[idx].p); if (!mpi_cmp (tmp, E.p)) { diff --git a/cipher/ecc.c b/cipher/ecc.c index 0e5776c..e0be2d4 100644 --- a/cipher/ecc.c +++ b/cipher/ecc.c @@ -1520,7 +1520,7 @@ compute_keygrip (gcry_md_hd_t md, gcry_sexp_t keyparms) &values[0], &values[1], &values[2], &values[3], &values[4]); if (rc) - return rc; + goto leave; } } ----------------------------------------------------------------------- Summary of changes: cipher/ecc-curves.c | 22 ++++++++++++++++++---- cipher/ecc.c | 2 +- tests/basic.c | 6 +++++- tests/benchmark.c | 2 +- tests/keygen.c | 1 + tests/mpitests.c | 1 + tests/t-mpi-point.c | 1 + tests/t-sexp.c | 1 + 8 files changed, 29 insertions(+), 7 deletions(-) hooks/post-receive -- The GNU crypto library http://git.gnupg.org From cvs at cvs.gnupg.org Mon Jan 27 14:53:30 2014 From: cvs at cvs.gnupg.org (by Dmitry Eremin-Solenikov) Date: Mon, 27 Jan 2014 14:53:30 +0100 Subject: [git] GCRYPT - branch, LIBGCRYPT-1-6-BRANCH, updated. libgcrypt-1.6.0-18-g41cc0f7 Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The GNU crypto library". The branch, LIBGCRYPT-1-6-BRANCH has been updated via 41cc0f72e6c964eb20a2decaa4ea61776c511d96 (commit) via 48cc151e9a6372b82a3e8ba03c271b93d783a411 (commit) via a180117d20ec36ac89bbe33e210358fcfb18ac2a (commit) from 04d478d9b0f92d80105ddaf2c011f40ae8260cfb (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 41cc0f72e6c964eb20a2decaa4ea61776c511d96 Author: Dmitry Eremin-Solenikov Date: Fri Jan 24 15:02:15 2014 +0400 tests: Pass -no-install to libtool * tests/Makefile.am: add AM_LDFLAGS = -no-install -- There is little point building tests with support for installation. Passing -no-install stops libtool from building wrapper scripts, thus allowing direct gdb/valgrind invocation on programs in tests/ subdirectory. Signed-off-by: Dmitry Eremin-Solenikov (cherry picked from commit bf34bfa5c458ee5ece91f25e3b4194d768498ab6) diff --git a/tests/Makefile.am b/tests/Makefile.am index 99d3ecd..6cde99f 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -44,6 +44,7 @@ TESTS_ENVIRONMENT = GCRYPT_IN_REGRESSION_TEST=1 # a built header. AM_CPPFLAGS = -I../src -I$(top_srcdir)/src AM_CFLAGS = $(GPG_ERROR_CFLAGS) +AM_LDFLAGS = -no-install default_ldadd = \ ../src/libgcrypt.la $(DL_LIBS) \ commit 48cc151e9a6372b82a3e8ba03c271b93d783a411 Author: Dmitry Eremin-Solenikov Date: Sat Jan 25 03:21:39 2014 +0400 Fix most of memory leaks in tests code * tests/basic.c (check_ccm_cipher): Close cipher after use. * tests/basic.c (check_one_cipher): Correct length of used buffer. * tests/benchmark.c (cipher_bench): Use xcalloc to make buffer initialized. * tests/keygen.c (check_ecc_keys): Release generated key. * tests/t-mpi-point.c (context_param): Release mpi Q. * tests/t-sexp.c (check_extract_param): Release extracted number. -- The only remaining reported memory leak is one expected leak from mpitests.c. Signed-off-by: Dmitry Eremin-Solenikov (cherry picked from commit 5c150ece094bf0a504a111ce6c7b72e8d0b0457a) diff --git a/tests/basic.c b/tests/basic.c index 97276d0..bebfa67 100644 --- a/tests/basic.c +++ b/tests/basic.c @@ -2213,6 +2213,8 @@ check_ccm_cipher (void) if (memcmp (buf, tag, taglen) != 0) fail ("cipher-ccm-large, encrypt mismatch entry\n"); + + gcry_cipher_close (hde); } #if 0 @@ -2305,6 +2307,8 @@ check_ccm_cipher (void) if (memcmp (buf, tag, taglen) != 0) fail ("cipher-ccm-huge, encrypt mismatch entry\n"); + + gcry_cipher_close (hde); } if (verbose) @@ -3496,7 +3500,7 @@ check_one_cipher (int algo, int mode, int flags) return; /* Pass 2: Key not aligned and data not aligned. */ - memmove (plain+1, plain, 1024); + memmove (plain+1, plain, 1040); if (check_one_cipher_core (algo, mode, flags, key+1, 32, plain+1, 1040, bufshift, 2+10*bufshift)) return; diff --git a/tests/benchmark.c b/tests/benchmark.c index e009c22..5efc083 100644 --- a/tests/benchmark.c +++ b/tests/benchmark.c @@ -656,7 +656,7 @@ cipher_bench ( const char *algoname ) } repetitions *= cipher_repetitions; - raw_buf = gcry_xmalloc (allocated_buflen+15); + raw_buf = gcry_xcalloc (allocated_buflen+15, 1); buf = (raw_buf + ((16 - ((size_t)raw_buf & 0x0f)) % buffer_alignment)); outbuf = raw_outbuf = gcry_xmalloc (allocated_buflen+15); diff --git a/tests/keygen.c b/tests/keygen.c index e8cf7c5..4aff9c9 100644 --- a/tests/keygen.c +++ b/tests/keygen.c @@ -413,6 +413,7 @@ check_ecc_keys (void) show_sexp ("ECC key:\n", key); check_generated_ecc_key (key); + gcry_sexp_release (key); if (verbose) show ("creating ECC key using curve Ed25519 for ECDSA (nocomp)\n"); diff --git a/tests/mpitests.c b/tests/mpitests.c index 9d1206e..d75aca9 100644 --- a/tests/mpitests.c +++ b/tests/mpitests.c @@ -212,6 +212,7 @@ test_opaque (void) if (debug) gcry_log_debugmpi ("mpi", a); + gcry_mpi_release (a); p = gcry_xstrdup ("This is a test buffer"); a = gcry_mpi_set_opaque_copy (NULL, p, 21*8+1); diff --git a/tests/t-mpi-point.c b/tests/t-mpi-point.c index ae52601..5ab0598 100644 --- a/tests/t-mpi-point.c +++ b/tests/t-mpi-point.c @@ -611,6 +611,7 @@ context_param (void) if (err) fail ("setting Q for nistp256 failed: %s\n", gpg_strerror (err)); get_and_cmp_mpi ("q", sample_p256_q, "nistp256(2)", ctx); + gcry_mpi_release (q); /* Get as s-expression. */ err = gcry_pubkey_get_sexp (&sexp, 0, ctx); diff --git a/tests/tsexp.c b/tests/tsexp.c index 1ab9802..704f9b1 100644 --- a/tests/tsexp.c +++ b/tests/tsexp.c @@ -1035,6 +1035,7 @@ check_extract_param (void) gcry_log_debugmpi (" got", mpis[0]); } + gcry_free (ioarray[0].data); gcry_mpi_release (mpis[0]); gcry_sexp_release (sxp); commit a180117d20ec36ac89bbe33e210358fcfb18ac2a Author: Dmitry Eremin-Solenikov Date: Sat Jan 25 03:21:38 2014 +0400 Fix memory leaks in ecc code * cipher/ecc-curves.c (_gcry_ecc_update_curve_param): Release passed mpi values. * cipher/ecc.c (compute_keygrip): Fix potential memory leak in error path. * cipher/ecc.c (_gcry_ecc_get_curve): Release temporary mpi. -- ==11657== 252 (80 direct, 172 indirect) bytes in 4 blocks are definitely lost in loss record 8 of 8 ==11657== at 0x4028A28: malloc (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so) ==11657== by 0x404178F: _gcry_private_malloc (stdmem.c:113) ==11657== by 0x403CED1: do_malloc.constprop.4 (global.c:768) ==11657== by 0x403DD01: _gcry_xmalloc (global.c:790) ==11657== by 0x409EAE0: _gcry_mpi_alloc (mpiutil.c:84) ==11657== by 0x409C4E4: _gcry_mpi_scan (mpicoder.c:466) ==11657== by 0x404009C: _gcry_sexp_nth_mpi (sexp.c:796) ==11657== by 0x40410B5: _gcry_sexp_vextract_param (sexp.c:2327) ==11657== by 0x4041396: _gcry_sexp_extract_param (sexp.c:2378) ==11657== by 0x407B895: compute_keygrip (ecc.c:1492) ==11657== by 0x404BBE8: _gcry_pk_get_keygrip (pubkey.c:674) ==11657== by 0x403B1BF: gcry_pk_get_keygrip (visibility.c:1056) ==16502== 144 (60 direct, 84 indirect) bytes in 3 blocks are definitely lost in loss record 3 of 7 ==16502== at 0x4028A28: malloc (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so) ==16502== by 0x404B4DE: _gcry_private_malloc (stdmem.c:113) ==16502== by 0x404667B: do_malloc (global.c:768) ==16502== by 0x40466E7: _gcry_malloc (global.c:790) ==16502== by 0x4046A55: _gcry_xmalloc (global.c:944) ==16502== by 0x40CD25B: _gcry_mpi_alloc (mpiutil.c:84) ==16502== by 0x40CAC3E: _gcry_mpi_scan (mpicoder.c:548) ==16502== by 0x40A72B2: scanval (ecc-curves.c:432) ==16502== by 0x40A7B0D: _gcry_ecc_get_curve (ecc-curves.c:685) ==16502== by 0x4058164: _gcry_pk_get_curve (pubkey.c:747) ==16502== by 0x4043E14: gcry_pk_get_curve (visibility.c:1067) ==16502== by 0x8048934: check_matching (curves.c:124) Signed-off-by: Dmitry Eremin-Solenikov (cherry picked from commit 6d87e6abdfb7552323a95401f14e6367398a3e5a) diff --git a/cipher/ecc-curves.c b/cipher/ecc-curves.c index ed629fc..41adfd1 100644 --- a/cipher/ecc-curves.c +++ b/cipher/ecc-curves.c @@ -473,6 +473,7 @@ _gcry_ecc_update_curve_param (const char *name, return gpg_err_code_from_syserror (); strcpy (stpcpy (stpcpy (buf, "0x04"), domain_parms[idx].g_x+2), domain_parms[idx].g_y+2); + _gcry_mpi_release (*g); *g = scanval (buf); xfree (buf); } @@ -481,13 +482,25 @@ _gcry_ecc_update_curve_param (const char *name, if (dialect) *dialect = domain_parms[idx].dialect; if (p) - *p = scanval (domain_parms[idx].p); + { + _gcry_mpi_release (*p); + *p = scanval (domain_parms[idx].p); + } if (a) - *a = scanval (domain_parms[idx].a); + { + _gcry_mpi_release (*a); + *a = scanval (domain_parms[idx].a); + } if (b) - *b = scanval (domain_parms[idx].b); + { + _gcry_mpi_release (*b); + *b = scanval (domain_parms[idx].b); + } if (n) - *n = scanval (domain_parms[idx].n); + { + _gcry_mpi_release (*n); + *n = scanval (domain_parms[idx].n); + } return 0; } @@ -567,6 +580,7 @@ _gcry_ecc_get_curve (gcry_sexp_t keyparms, int iterator, unsigned int *r_nbits) for (idx = 0; domain_parms[idx].desc; idx++) { + mpi_free (tmp); tmp = scanval (domain_parms[idx].p); if (!mpi_cmp (tmp, E.p)) { diff --git a/cipher/ecc.c b/cipher/ecc.c index 06bfb47..debb71b 100644 --- a/cipher/ecc.c +++ b/cipher/ecc.c @@ -1520,7 +1520,7 @@ compute_keygrip (gcry_md_hd_t md, gcry_sexp_t keyparms) &values[0], &values[1], &values[2], &values[3], &values[4]); if (rc) - return rc; + goto leave; } } ----------------------------------------------------------------------- Summary of changes: cipher/ecc-curves.c | 22 ++++++++++++++++++---- cipher/ecc.c | 2 +- tests/Makefile.am | 1 + tests/basic.c | 6 +++++- tests/benchmark.c | 2 +- tests/keygen.c | 1 + tests/mpitests.c | 1 + tests/t-mpi-point.c | 1 + tests/tsexp.c | 1 + 9 files changed, 30 insertions(+), 7 deletions(-) hooks/post-receive -- The GNU crypto library http://git.gnupg.org From cvs at cvs.gnupg.org Mon Jan 27 16:44:07 2014 From: cvs at cvs.gnupg.org (by Werner Koch) Date: Mon, 27 Jan 2014 16:44:07 +0100 Subject: [git] GCRYPT - branch, LIBGCRYPT-1-6-BRANCH, updated. libgcrypt-1.6.0-19-g420f42a Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The GNU crypto library". The branch, LIBGCRYPT-1-6-BRANCH has been updated via 420f42a5752e90a8b27d58ffa1ddfe6e4ab341e8 (commit) from 41cc0f72e6c964eb20a2decaa4ea61776c511d96 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 420f42a5752e90a8b27d58ffa1ddfe6e4ab341e8 Author: Werner Koch Date: Thu Jan 9 19:14:09 2014 +0100 mpi: Minor fix for Atari-mint. * mpi/config.links [m68k-atari-mint]: Do not assume 68020. Suggested by Alan Hourihane. diff --git a/mpi/config.links b/mpi/config.links index 57e6c2a..0217d35 100644 --- a/mpi/config.links +++ b/mpi/config.links @@ -260,7 +260,7 @@ case "${host}" in m68k-atari-mint) echo '#define MIT_SYNTAX' >>./mpi/asm-syntax.h cat $srcdir/mpi/m68k/syntax.h >>./mpi/asm-syntax.h - path="m68k/mc68020 m68k" + path="m68k" mpi_cpu_arch="m68k" ;; m68000*-*-* | \ ----------------------------------------------------------------------- Summary of changes: mpi/config.links | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- The GNU crypto library http://git.gnupg.org From cvs at cvs.gnupg.org Mon Jan 27 17:22:06 2014 From: cvs at cvs.gnupg.org (by Sam Tuke) Date: Mon, 27 Jan 2014 17:22:06 +0100 Subject: [git] gnupg-doc - branch, master, updated. 45455ced4e5c6d2f3cbc765fd599029da95579d7 Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The GnuPG website and other docs". The branch, master has been updated via 45455ced4e5c6d2f3cbc765fd599029da95579d7 (commit) from 95adf65c74548fb48a677076da8d4e89ac649cf5 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 45455ced4e5c6d2f3cbc765fd599029da95579d7 Author: Sam Tuke Date: Mon Jan 27 17:22:15 2014 +0100 Added new blog post "find us at fosdem" diff --git a/misc/blog.gnupg.org/20140127-find-fosdem.html b/misc/blog.gnupg.org/20140127-find-fosdem.html new file mode 100644 index 0000000..5d2720c --- /dev/null +++ b/misc/blog.gnupg.org/20140127-find-fosdem.html @@ -0,0 +1,182 @@ + + + + + + Find us at FOSDEM - Blog - GnuPG + + + + ++ + + + + + + + + + + + + + +
      + + + + + + + + + + + + + + + + + +
        + [GnuPG Logo]  
      + · English ·   +    
      +
      + + + + + + + + + + + + + + + +
      Links + +  
        
       
      +
      + + + + + + + + + + + + + + + +
      + + + +
      + +
      + +

      Keysigning at FOSDEM

      +
      + +

      Find us at FOSDEM

      +
      Posted 27th January 2014 by Sam Tuke
      + +

      On Friday Werner and Sam are heading to FOSDEM, the largest Free Software conference in Europe, along with many GnuPG hackers, users, and supporters. Get in touch if you'd like to talk about the existing or future campaigns while we're there.

      + +

      There won't be a GnuPG booth this year but, we shall be busy with meetings and mingling. Notes and contacts for us can be left at the FSFE booth.

      + +

      And don't forget that you're invited to the continent's biggest keysigning party, organised by FOSDEM volunteers. Today is the last opportunity to submit your key, which is necessary for participation. Get to it!.

      + +

      Bring your ideas. See you there.

      + +
      + + + +
       
        
       
      +
        +
      + + + + + + + + + + + + +
       Technical resources for this
      + service are sponsered by
       
        + OpenIT +  
      +
      + +

      + + Valid XHTML 1.0! +     + + Digital Respect for the Masses +     + + Peace! +     + + Valid CSS! +

      + + + +
      +
      + + + + + + + \ No newline at end of file diff --git a/misc/blog.gnupg.org/img/keysigning-party-s.jpg b/misc/blog.gnupg.org/img/keysigning-party-s.jpg new file mode 100644 index 0000000..40af0bf Binary files /dev/null and b/misc/blog.gnupg.org/img/keysigning-party-s.jpg differ diff --git a/misc/blog.gnupg.org/index.html b/misc/blog.gnupg.org/index.html index 1f62357..dd1ad1c 100644 --- a/misc/blog.gnupg.org/index.html +++ b/misc/blog.gnupg.org/index.html @@ -69,547 +69,571 @@ -

      Blogs

      +

      GnuPG Blog

      -
      - -

      How good is Goteo? An appraisal

      -
      -
      Posted 30th December 2013 by Sam Tuke
      +
      -
      - -

      A wall of donor faces on Goteo

      -
      - -

      "One question: why did you choose the quite unknown Spanish crowdfunding site Goteo?" So shot back the reply to the press release I had just sent to a few dozen selected journalists announcing the launch of the GnuPG crowdfunding campaign. "You won't get any exposure on there, we got a few hundred thousand hits just from being on indiegogo" I was told by one experienced crowdfunder at my favourite Berlin hackerspace last month. "What's Goteo?" has been one of the most frequently asked questions of this campaign from friends and supporters.

      - -

      I ummed and ahhed over which crowfunding platform to choose. It's a decision that has a huge impact on the campaign - market exposure, transaction costs, and design and layout are just a few of the many factors that have to be taken into account. This is a crowded market - new crowdfunding sites are popping up each week as more companies try to cash in on what is recognised a key tech trend of 2013. An estimated $5bn was raised by crowdfunders this year. That equates to around $35m in commission fees for the platforms hosting these campaigns, who typically charge between 5-10%. It's no surprise that everyone wants a slice.

      - -
      - -

      "Non-economic donations"

      -
      - -

      Goteo however, is unique. Right now it's the only crowdfunding software that is itself Free Software, allowing everyone to inspect how it works and run their own copy. Even though I don't plan to run my own Kickstarter competitor any time soon, the fact we can check its code, make improvements, and follow the development process is really important. I want Goteo to prosper profitably because, aside from all its other good points, I know some of that profit will be invested in the platform itself, which shall remain free and accessible to everyone under the terms of the AGPL3 license.

      - -

      Goteo is also the only such site to my knowledge that's built with public money. Funded by Spain's Department for Education, Culture and Sport, Barcelona's City Council, and The University of Andalucia, Goteo exists to host projects which "contribute to the common good, free knowledge, and open code". Everything about the platform and the projects it hosts point to common goods, shared resources, and collaborative effort.

      - -

      Besides that, these other features make it stand out:

      - -
        -
      • Signup and donation workflow is smooth and simple
      • -
      • Great focus on social media and sharing links (we had hundreds of tweets from these)
      • -
      • Users can login with many social networks, including OpenID and LinkedIn
      • -
      • Clean and professional design with easy access to key information
      • -
      • Built in license chooser for all "goods" projects produce (categories for software, artwork, etc.)
      • -
      • Mandatory delivery timeframe / deadline setter with public calendar
      • -
      • Nice "image wall widget" of donors faces has potential, provides public recognition of donations
      • -
      • Web forms for project creation are comprehensive and well designed
      • -
      • Crowdsourcing of extra skills ("non-economic donations") works well
      • -
      • Donations are guaranteed by PayPal and Goteo, not pledged or retractable
      • -
      • Goteo staff are friendly and knowledgable, providing personal guidance and assistance
      • -
      • Many funding successes, including a few related to hardware, software, and Hackerspaces
      • -
      - -Many of those benefits are obvious before launching a campaign. However, on the list of problems I experienced with the platform, most weren't discovered until the point of execution (orange = fix in progress): - -
        -
      • User-set passwords are automatically emailed in plain text after registration (insecure)
      • -
      • Rewards can't be customised, e.g. select t-shirt size
      • -
      • Once a campaign is launched, no aspect can be edited directly (though news can be added)
      • -
      • The order of images for the campaign page is random - the first image visitors see can't be specified
      • -
      • The launch date of the campaign is chosen by Goteo administrators, it can't be specified
      • -
      • No markup is available for text formatting
      • -
      • Pictures are limited and can't be placed between text to break up the page
      • -
      • There's a bug that causes double posting of news items
      • -
      • Shipping for rewards is not configurable - international shipping can't be billed
      • -
      • The website is not mobile friendly (minimum page width is 940px)
      • -
      • HTTPS is not available to donors for transferring personal details
      • -
      - -Besides that, I spotted a few opportunities for improvement: - -
        -
      • Send emails to people who didn't complete their donation ("abandoned carts" - indiegogo does this)
      • -
      • Allow managers to specify the content of social media messages
      • -
      - -
      - -

      Goteo's license on GitHub

      -
      +
      + +

      Keysigning at FOSDEM

      +
      -

      Some of the problems listed are a real pain. Because I couldn't choose the launch date, and hadn't planned for an in-depth human review by Goteo, our project went public days later than I expected, at a time when I was travelling and without connectivity. Goteo's campaigns team is helpful and responsive however, and even in the last few weeks several translation problems have been fixed which I had previously reported. I'm confident that the other most serious issues will be addressed in a timely manner.

      + +

      Find us at FOSDEM

      +
      +
      Posted 27th January 2014 by Sam Tuke
      -

      In all, we took a gamble by using Goteo, but one that paid off. It's focus on communal work and rewards is unique amongst its competitors, and when it comes to copyleft licensing they stand alone in practicing what they preach. Nearly all the convenient features that you'd expect from more established platforms are included, together with a pleasant functional interface. Donations are worry-free for both donors and recipients (though I can't comment on the final transfer process until later next month).

      +

      On Friday Werner and Sam are heading to FOSDEM, the largest Free Software conference in Europe, along with many GnuPG hackers, users, and supporters. Get in touch if you'd like to talk about the existing or future campaigns while we're there.

      -

      Best of all perhaps, staff at Goteo are knowledgable and supportive and have time to invest in making projects a success. And when launch day comes and you're expecting the unexpected, that's very reassuring.

      +

      There won't be a GnuPG booth this year, but we shall be busy with meetings and mingling. Notes and contacts for us can be left at the FSFE booth.

      -

      +

      And don't forget that you're invited to the continent's biggest keysigning party, organised by FOSDEM volunteers. Today is the last opportunity to submit your key, which is necessary for participation. Get to it!

      -
      +

      Bring your ideas. See you there.

      -
      -

      16 Years of protecting privacy

      -
      Posted 20th December 2013 by Sam Tuke
      +

      -

      -Today marks 16 years since the first release of GNU Privacy Guard -(GnuPG). In that time the project has grown from being a hacker?s -hobby into one of the world?s most critical anti-surveillance -tools. Today GnuPG stands at the front line of the battle between -invasive surveillance and civil liberties. -

      - -

      -?Time has proven Free Software to be the most trustworthy defender -against companies and governments seeking to undermine citizen -privacy? said Werner Koch, GnuPG Founder and Lead Developer. ?Although -funding our work has not always been easy, the need for universally -accessible privacy tools has never been more apparent?. -

      - -

      -Some of the world?s top security specialists are now counted among -GnuPG users, including Bruce Schneier, Jacob Appelbaum, and Phil -Zimmerman, inventor of PGP. This summer the world learned of the -extent of Government spying thanks to whistleblowers and journalists -communicating using GnuPG encrypted emails. Market leading servers -from Red Hat and Debian have built their reputation for security on -the foundation of GnuPG-verified software. -

      - -

      -?The success of GnuPG?s -first crowdfunding campaign, which received 90% of it?s target in 24 -hours, shows a fresh willingness among users to support GnuPG in it?s -16th year, and points to new opportunities for the project in future? -said Sam Tuke, GnuPG Campaign Manager. ?The release of GnuPG 2.1 and -the launch of a newly designed website later this year will bring -GnuPG and its clients for Windows, Mac, Gnu/Linux, and Android to new -audiences?. -

      - -

      -Over the years GnuPG has kept up to date with new algorithms, such as -Elliptic Curve Cryptography, and reactive to new threats, such as key -extraction via acoustic monitoring, which was announced two days ago -by researchers as GnuPG updates were released, in coordination with -developers. Members remain confident of the future of GnuPG and look -forward to facing the privacy threats of tomorrow with community -support. -

      - - -

      - -
      - - -
      -

      Press release: GnuPG encryption project launches crowdfunding - campaign

      -
      Posted 19th December 2013 by Sam Tuke
      - - -

      Today GNU Privacy Guard (GnuPG) has launched its first - crowdfunding campaign with the aim of building a new - website and long term infrastructure. The 24.000 EUR target will - fund:

      - -
        -
      • Fresh web interfaces for gnupg.org including mobile
      • -
      • Completion and release of GnuPG 2.1
      • -
      • Anonymous Tor network access to the website
      • -
      • A new user friendly download page suitable for all devices
      • -
      • A new server for web services
      • -
      • New pages convening external guides, videos, and handbooks
      • -
      • Facilities for processing recurring donations for long - term project support
      • -
      - -

      Project founder and Lead Developer Werner Koch said ?GnuPG has - seen a huge upsurge in popularity following recent state - spying revelations. After 16 years of continuous development, - we are now asking for community support to capitalise on - consumer demand for privacy, and make GnuPG easy to access for - mainstream audiences?.

      - -

      GnuPG is one of the few tools remaining above suspicion in the - wake of leaked NSA documents. Edward Snowden and his contacts - including Bruce Schneier switched to GnuPG when they began handling - the secret - documents earlier - this year. The Wall Street Journal, The Committee to Protect - Journalists, - and ProPublica - have all embraced GnuPG for protection of staff and sources. Phil - Zimmermann, original inventor of Pretty Good Privacy (PGP), has also - moved to GnuPG in wake of the news.

      - -

      ?GnuPG is a key part of modern privacy infrastructure? said - Sam Tuke, Campaign Manager, GnuPG. ?Millions of users rely on - GnuPG to work securely on servers, laptops and smartphones, - but 2013 donations totaling 3.000 EUR to date have not even - covered fixed costs. Supporting new algorithms like elliptical - curve and fixing newfound exploits fast takes a lot of work - which is done voluntarily. Now is the time for people to - contribute to making GnuPG slick and more sustainable in - future?.

      - -

      Jacob Appelbaum, Tor Project developer, added ?GnuPG is - important - it allows us the assurances we need to do our - work. Community funding is a critical part of a confident - outlook for GnuPG in future.?

      - - -

      For further information, please contact Sam Tuke.
      - Email: samtuke [at] gnupg.org
      - Phone: +49 176 81923811 -

      - -

      About GNU Privacy Guard

      - -

      GnuPG is a leading cryptography app that protects emails and - data from interception. It is developed by a community of Free - Software engineers led by Werner Koch. GnuPG is used and - recommended by the world?s top security experts, including - Bruce Schneier and Phil Zimmermann. It offers best in class - privacy free of charge and restriction. Hundreds of companies - have integrated GnuPG into their products to perform mission - critical security, including Red Hat, Deutsche Bahn, and many - others.

      - -

      http://gnupg.org

      - -

      -
      +
      - - -
      -

      Getting Goteo approval

      -
      Posted 18th December 2013 by Sam Tuke
      - -
      - -

      Pending project on Goteo

      -
      - -

      The targets are set, the rewards are prepared, the press release - has been edited and translated, and now we?re waiting for - approval from the crowdfunding - platform Goteo.

      - -

      Goteo is like indiegogo, but more forward thinking. It has a - special focus on communal benefits and rewards - projects that - benefit society as a whole, not just project donors (though they - can get special rewards too).

      - - -

      Every ?good? produced by a campaign on Goteo, be it artwork, - software, event, or manufactured product, has a license assigned - to it, like GPL or Creative Commons, and as well as asking for - money, projects ask for other forms of help called ?non-economic - needs?, like translations or product - testing. Goteo?s own - source code is Free Software too, meaning anyone can run - their own Goteo crowdfunding server. That?s the feature that - swung our decision to use it for GnuPG.

      - - -

      Because the type of project on Goteo is quite specific - however, the acceptance phase of launching crowdfunding is - taking us longer than expected. Right now we?re working with - Goteo?s small team to answer questions which aren?t on the - webforms you fill out when you design your project with their - system.

      - -

      I?m hoping to provide what?s necesasry and get acceptance - quickly. As soon as we have it the crowdfunding will launch - and newsletter subscribers - and Twitter followers - will be the first to know.

      - -

      - - -
      - - - - -
      -

      Speedups in Libgcrypt 1.6

      -
      Posted 15 December 2013 by Werner Koch
      -

      - [...] To check how the forthcoming version 1.6.0 of Libgcrypt - compares to the older 1.5 version of Libgcrypt, I did some benchmarks - using a Thinkpad X220 which features an i5-2410M processor at 2.3GHz - running a 64 bit Debian Wheezy. - {more} -

      -

      -
      - -
      -

      Preparing for launch

      - -
      Posted 13th December 2013 by Sam Tuke
      - -

      Mid December, giving season, and nearly time for the GnuPG - Crowdfunding to commence. We've been working hard on - preparations. Drafts of the new mobile website design have been published and met positive feedback, and a community-contibuted - promo video was posted on YouTube. GnuPG coverage on Twitter - continues to grow with many articles - (The - Guardian, Kaspersky - Labs, The - EFF, Lifehacker, - ...) and 252 new followers in 6 weeks.

      - -
      - -
      - -
      - - - -

      New mobile site draft

      -
      - -

      Last Friday I announced the crowdfunding to a crowded audience at - Berlin event - "Whatever - happened to privacy", and Markus Beckedahl - (Netzpolitik) - and Jacob - Appelbaum (Tor Project and Wikileaks) amplified the importance - of supporting the project. Hugo Roy (FSFE) gave a talk on Wednesday - about the campaign at the Paris - 'Hackadon' - a new conference for - Free Software giving, organised by three - crowdfunding - organisations. His slides are online in the - GPG presentations - repository.

      - -

      Hopefully the crowdfunding page on Goteo (a Free Software - Kickstarter) will be ready for launch next week. Email me if you can - help with translating the press release - we're aiming for at least - three languages. And don't forget you can still sign up for email - updates (form below). Thanks for all your support so far!

      - - - - - -
      -
      - - -
      - -

      -
      - - -
      -

      Friends tell friends they love GnuPG

      - -
      Posted 13th November 2013 by Sam Tuke
      - -
      - -

      GnuPG can run almost anywhere

      -
      - -

      Email encryption is one of those pleasures that can't be enjoyed - alone. Sending yourself messages secured with 4096-bit RSA is great - for proof of concept, but meaningful communication requires two - parties. GnuPG requires both those parties to have their own - keys.

      - -

      Less than 1% of all email - traffic is PGP encrypted, meaning that those of us who do make our - messages private routinely find ourselves in the frustrating - predicament of having to share our thoughts insecurely, even though - we know they're being intercepted, even though this is easily - avoidable, and even though we've already taken steps to do so. All - because our friends and colleagues don't know the - benefits of GnuPG.

      - -

      Windows, Gnu/Linux, Mac, and Android all have point and click - GnuPG interfaces - at this point, all bases except iPhone are more - or less covered. That means the reason your contacts aren't OpenPGP - ready is not technical. And because GnuPG is Free - Software (and free of charge), it can't be about price.

      - -

      A recommendation from you is the most effective way you can - increase the number of GnuPG users, and consequently increase the - percentage of the messages you send that are meaningfully - encrypted. That's why we're asking people in our community to think - of pithy explanations of why GnuPG is important and how it enables - them.

      - -

      We've already got quotes from some big names like Bruce Schneier, - Jacob Appelbaum, and Richard Stallman. But the chances are - that your name carries more weight among your - peers. Please use it to share your appreciation for GnuPG!

      - -

      If you use social networks, you can - use #iloveGPG to connect your messages to other - people's, and make is easier for us to find and repeat them.

      - -

      Look out for weekly quotes posted from the - GnuPG Twitter - and Diaspora - accounts if you need inspiration. Let's fill up - the keyservers - with fresh keys from new users!

      - -

      -
      - -
      -

      Securing the future of GPG

      -
      Posted 5th November 2013 by Sam Tuke
      - -

      If you've noticed some changes around here, there's a good reason - why. We have a plan for securing the long term stability of GnuPG - development by giving more to our users, and asking more from them - in return.

      - -

      You already know that GnuPG is important, and as months of fresh - government spying revelations go by, it's becoming obvious that - GnuPG is one of the very few tools that can still be trusted to keep - our data safe from the overwhelming efforts of international law - enforcement. But developing GnuPG takes work - regular monitoring - for newfound threats and exploits, and new features to keep it sharp - with the latest encryption algorithms. We also need to reach out to - the millions of potential GnuPG users who are asking themselves how - they can make their email secure. Public-private key cryptography - hasn't yet gained mainstream acceptance, but it could if it were - just a little more appealing and accessible.

      - -

      To maintain progress within the project we need to make it easier - for GnuPG users to support the work that we do. Ours is an app that - is often hidden from view, relied upon daily by hundreds of - thousands of people, often in life-threatening circumstances, yet - low profile and rarely supported by publicity or donations.

      - -

      To change that we're going to launch a new - website with a fresh design, more friendly and accessible - information, and new resources to grow and strengthen our user - group. The new site will also allow the project to accept and manage - new forms of financial support, including automatic subscriptions to - sustain development long term.

      - -

      Designing, building and populating the new site will take a few - months, and in order to cover the costs there will be - a crowd-funding campaign with a modest target, in - early December. We have some rewards up our sleeves for those who - donate.

      - -

      When that time comes, we'll need your help - - telling your contacts, forwarding the announcement to your - communities, and contributing financially if you can.

      - -

      You can subscribe to updates about the campaign using this - form. This is separate to other GnuPG mailing lists - update will be - sent here, and only here.

      - - - - - -
      -
      - - -
      - -

      -
      - -
      -

      New blog, first post

      -
      Posted 30th October 2013 by Sam Tuke
      - -

      Welcome to Gnu Privacy Guard's new blog! We're planning some - major changes to gnupg.org and how the project communicates in - general. I'm Sam, and I'll be writing updates here as our work - progresses. In future this blog will be replaced with a more - beautiful and featureful alternative, but bear with us as we get - from here to there.

      - -

      For more timely updates you can follow our Twitter - accounts: @GnuPrivacyGuard - and @GnuPG. - That's right, we have two! But I'm going to combine them shortly so - it's easier to keep track [UPDATE: accounts now merged! - Stick with @GnuPG].

      - -

      For more information, see - our press - contact page hosted on Totem. That's all for now.

      - -

      -
      +
      + +

      How good is Goteo? An appraisal

      +
      +
      Posted 30th December 2013 by Sam Tuke
      + +
      + +

      A wall of donor faces on Goteo

      +
      + +

      "One question: why did you choose the quite unknown Spanish crowdfunding site Goteo?" So shot back the reply to the press release I had just sent to a few dozen selected journalists announcing the launch of the GnuPG crowdfunding campaign. "You won't get any exposure on there, we got a few hundred thousand hits just from being on indiegogo" I was told by one experienced crowdfunder at my favourite Berlin hackerspace last month. "What's Goteo?" has been one of the most frequently asked questions of this campaign from friends and supporters.

      + +

      I ummed and ahhed over which crowfunding platform to choose. It's a decision that has a huge impact on the campaign - market exposure, transaction costs, and design and layout are just a few of the many factors that have to be taken into account. This is a crowded market - new crowdfunding sites are popping up each week as more companies try to cash in on what is recognised a key tech trend of 2013. An estimated $5bn was raised by crowdfunders this year. That equates to around $35m in commission fees for the platforms hosting these campaigns, who typically charge between 5-10%. It's no surprise that everyone wants a slice.

      + +
      + +

      "Non-economic donations"

      +
      + +

      Goteo however, is unique. Right now it's the only crowdfunding software that is itself Free Software, allowing everyone to inspect how it works and run their own copy. Even though I don't plan to run my own Kickstarter competitor any time soon, the fact we can check its code, make improvements, and follow the development process is really important. I want Goteo to prosper profitably because, aside from all its other good points, I know some of that profit will be invested in the platform itself, which shall remain free and accessible to everyone under the terms of the AGPL3 license.

      + +

      Goteo is also the only such site to my knowledge that's built with public money. Funded by Spain's Department for Education, Culture and Sport, Barcelona's City Council, and The University of Andalucia, Goteo exists to host projects which "contribute to the common good, free knowledge, and open code". Everything about the platform and the projects it hosts point to common goods, shared resources, and collaborative effort.

      + +

      Besides that, these other features make it stand out:

      + +
        +
      • Signup and donation workflow is smooth and simple
      • +
      • Great focus on social media and sharing links (we had hundreds of tweets from these)
      • +
      • Users can login with many social networks, including OpenID and LinkedIn
      • +
      • Clean and professional design with easy access to key information
      • +
      • Built in license chooser for all "goods" projects produce (categories for software, artwork, etc.)
      • +
      • Mandatory delivery timeframe / deadline setter with public calendar
      • +
      • Nice "image wall widget" of donors faces has potential, provides public recognition of donations
      • +
      • Web forms for project creation are comprehensive and well designed
      • +
      • Crowdsourcing of extra skills ("non-economic donations") works well
      • +
      • Donations are guaranteed by PayPal and Goteo, not pledged or retractable
      • +
      • Goteo staff are friendly and knowledgable, providing personal guidance and assistance
      • +
      • Many funding successes, including a few related to hardware, software, and Hackerspaces
      • +
      + + Many of those benefits are obvious before launching a campaign. However, on the list of problems I experienced with the platform, most weren't discovered until the point of execution (orange = fix in progress): + +
        +
      • User-set passwords are automatically emailed in plain text after registration (insecure)
      • +
      • Rewards can't be customised, e.g. select t-shirt size
      • +
      • Once a campaign is launched, no aspect can be edited directly (though news can be added)
      • +
      • The order of images for the campaign page is random - the first image visitors see can't be specified
      • +
      • The launch date of the campaign is chosen by Goteo administrators, it can't be specified
      • +
      • No markup is available for text formatting
      • +
      • Pictures are limited and can't be placed between text to break up the page
      • +
      • There's a bug that causes double posting of news items
      • +
      • Shipping for rewards is not configurable - international shipping can't be billed
      • +
      • The website is not mobile friendly (minimum page width is 940px)
      • +
      • HTTPS is not available to donors for transferring personal details
      • +
      + + Besides that, I spotted a few opportunities for improvement: + +
        +
      • Send emails to people who didn't complete their donation ("abandoned carts" - indiegogo does this)
      • +
      • Allow managers to specify the content of social media messages
      • +
      + +
      + +

      Goteo's license on GitHub

      +
      + +

      Some of the problems listed are a real pain. Because I couldn't choose the launch date, and hadn't planned for an in-depth human review by Goteo, our project went public days later than I expected, at a time when I was travelling and without connectivity. Goteo's campaigns team is helpful and responsive however, and even in the last few weeks several translation problems have been fixed which I had previously reported. I'm confident that the other most serious issues will be addressed in a timely manner.

      + +

      In all, we took a gamble by using Goteo, but one that paid off. It's focus on communal work and rewards is unique amongst its competitors, and when it comes to copyleft licensing they stand alone in practicing what they preach. Nearly all the convenient features that you'd expect from more established platforms are included, together with a pleasant functional interface. Donations are worry-free for both donors and recipients (though I can't comment on the final transfer process until later next month).

      + +

      Best of all perhaps, staff at Goteo are knowledgable and supportive and have time to invest in making projects a success. And when launch day comes and you're expecting the unexpected, that's very reassuring.

      + +

      + +
      + +
      +

      16 Years of protecting privacy

      +
      Posted 20th December 2013 by Sam Tuke
      + +

      + Today marks 16 years since the first release of GNU Privacy Guard + (GnuPG). In that time the project has grown from being a hacker?s + hobby into one of the world?s most critical anti-surveillance + tools. Today GnuPG stands at the front line of the battle between + invasive surveillance and civil liberties. +

      + +

      + ?Time has proven Free Software to be the most trustworthy defender + against companies and governments seeking to undermine citizen + privacy? said Werner Koch, GnuPG Founder and Lead Developer. ?Although + funding our work has not always been easy, the need for universally + accessible privacy tools has never been more apparent?. +

      + +

      + Some of the world?s top security specialists are now counted among + GnuPG users, including Bruce Schneier, Jacob Appelbaum, and Phil + Zimmerman, inventor of PGP. This summer the world learned of the + extent of Government spying thanks to whistleblowers and journalists + communicating using GnuPG encrypted emails. Market leading servers + from Red Hat and Debian have built their reputation for security on + the foundation of GnuPG-verified software. +

      + +

      + ?The success of GnuPG?s + first crowdfunding campaign, which received 90% of it?s target in 24 + hours, shows a fresh willingness among users to support GnuPG in it?s + 16th year, and points to new opportunities for the project in future? + said Sam Tuke, GnuPG Campaign Manager. ?The release of GnuPG 2.1 and + the launch of a newly designed website later this year will bring + GnuPG and its clients for Windows, Mac, Gnu/Linux, and Android to new + audiences?. +

      + +

      + Over the years GnuPG has kept up to date with new algorithms, such as + Elliptic Curve Cryptography, and reactive to new threats, such as key + extraction via acoustic monitoring, which was announced two days ago + by researchers as GnuPG updates were released, in coordination with + developers. Members remain confident of the future of GnuPG and look + forward to facing the privacy threats of tomorrow with community + support. +

      + + +

      + +
      + + +
      +

      Press release: GnuPG encryption project launches crowdfunding + campaign

      +
      Posted 19th December 2013 by Sam Tuke
      + + +

      Today GNU Privacy Guard (GnuPG) has launched its first + crowdfunding campaign with the aim of building a new + website and long term infrastructure. The 24.000 EUR target will + fund:

      + +
        +
      • Fresh web interfaces for gnupg.org including mobile
      • +
      • Completion and release of GnuPG 2.1
      • +
      • Anonymous Tor network access to the website
      • +
      • A new user friendly download page suitable for all devices
      • +
      • A new server for web services
      • +
      • New pages convening external guides, videos, and handbooks
      • +
      • Facilities for processing recurring donations for long + term project support
      • +
      + +

      Project founder and Lead Developer Werner Koch said ?GnuPG has + seen a huge upsurge in popularity following recent state + spying revelations. After 16 years of continuous development, + we are now asking for community support to capitalise on + consumer demand for privacy, and make GnuPG easy to access for + mainstream audiences?.

      + +

      GnuPG is one of the few tools remaining above suspicion in the + wake of leaked NSA documents. Edward Snowden and his contacts + including Bruce Schneier switched to GnuPG when they began handling + the secret + documents earlier + this year. The Wall Street Journal, The Committee to Protect + Journalists, + and ProPublica + have all embraced GnuPG for protection of staff and sources. Phil + Zimmermann, original inventor of Pretty Good Privacy (PGP), has also + moved to GnuPG in wake of the news.

      + +

      ?GnuPG is a key part of modern privacy infrastructure? said + Sam Tuke, Campaign Manager, GnuPG. ?Millions of users rely on + GnuPG to work securely on servers, laptops and smartphones, + but 2013 donations totaling 3.000 EUR to date have not even + covered fixed costs. Supporting new algorithms like elliptical + curve and fixing newfound exploits fast takes a lot of work + which is done voluntarily. Now is the time for people to + contribute to making GnuPG slick and more sustainable in + future?.

      + +

      Jacob Appelbaum, Tor Project developer, added ?GnuPG is + important - it allows us the assurances we need to do our + work. Community funding is a critical part of a confident + outlook for GnuPG in future.?

      + + +

      For further information, please contact Sam Tuke.
      + Email: samtuke [at] gnupg.org
      + Phone: +49 176 81923811 +

      + +

      About GNU Privacy Guard

      + +

      GnuPG is a leading cryptography app that protects emails and + data from interception. It is developed by a community of Free + Software engineers led by Werner Koch. GnuPG is used and + recommended by the world?s top security experts, including + Bruce Schneier and Phil Zimmermann. It offers best in class + privacy free of charge and restriction. Hundreds of companies + have integrated GnuPG into their products to perform mission + critical security, including Red Hat, Deutsche Bahn, and many + others.

      + +

      http://gnupg.org

      + +

      +
      + + + +
      +

      Getting Goteo approval

      +
      Posted 18th December 2013 by Sam Tuke
      + +
      + +

      Pending project on Goteo

      +
      + +

      The targets are set, the rewards are prepared, the press release + has been edited and translated, and now we?re waiting for + approval from the crowdfunding + platform Goteo.

      + +

      Goteo is like indiegogo, but more forward thinking. It has a + special focus on communal benefits and rewards - projects that + benefit society as a whole, not just project donors (though they + can get special rewards too).

      + + +

      Every ?good? produced by a campaign on Goteo, be it artwork, + software, event, or manufactured product, has a license assigned + to it, like GPL or Creative Commons, and as well as asking for + money, projects ask for other forms of help called ?non-economic + needs?, like translations or product + testing. Goteo?s own + source code is Free Software too, meaning anyone can run + their own Goteo crowdfunding server. That?s the feature that + swung our decision to use it for GnuPG.

      + + +

      Because the type of project on Goteo is quite specific + however, the acceptance phase of launching crowdfunding is + taking us longer than expected. Right now we?re working with + Goteo?s small team to answer questions which aren?t on the + webforms you fill out when you design your project with their + system.

      + +

      I?m hoping to provide what?s necesasry and get acceptance + quickly. As soon as we have it the crowdfunding will launch + and newsletter subscribers + and Twitter followers + will be the first to know.

      + +

      + + +
      + + + + +
      +

      Speedups in Libgcrypt 1.6

      +
      Posted 15 December 2013 by Werner Koch
      +

      + [...] To check how the forthcoming version 1.6.0 of Libgcrypt + compares to the older 1.5 version of Libgcrypt, I did some benchmarks + using a Thinkpad X220 which features an i5-2410M processor at 2.3GHz + running a 64 bit Debian Wheezy. + {more} +

      +

      +
      + +
      +

      Preparing for launch

      + +
      Posted 13th December 2013 by Sam Tuke
      + +

      Mid December, giving season, and nearly time for the GnuPG + Crowdfunding to commence. We've been working hard on + preparations. Drafts of the new mobile website design have been published and met positive feedback, and a community-contibuted + promo video was posted on YouTube. GnuPG coverage on Twitter + continues to grow with many articles + (The + Guardian, Kaspersky + Labs, The + EFF, Lifehacker, + ...) and 252 new followers in 6 weeks.

      + +
      + +
      + +
      + + + +

      New mobile site draft

      +
      + +

      Last Friday I announced the crowdfunding to a crowded audience at + Berlin event + "Whatever + happened to privacy", and Markus Beckedahl + (Netzpolitik) + and Jacob + Appelbaum (Tor Project and Wikileaks) amplified the importance + of supporting the project. Hugo Roy (FSFE) gave a talk on Wednesday + about the campaign at the Paris + 'Hackadon' - a new conference for + Free Software giving, organised by three + crowdfunding + organisations. His slides are online in the + GPG presentations + repository.

      + +

      Hopefully the crowdfunding page on Goteo (a Free Software + Kickstarter) will be ready for launch next week. Email me if you can + help with translating the press release - we're aiming for at least + three languages. And don't forget you can still sign up for email + updates (form below). Thanks for all your support so far!

      + + + + + +
      +
      + + +
      + +

      +
      + + +
      +

      Friends tell friends they love GnuPG

      + +
      Posted 13th November 2013 by Sam Tuke
      + +
      + +

      GnuPG can run almost anywhere

      +
      + +

      Email encryption is one of those pleasures that can't be enjoyed + alone. Sending yourself messages secured with 4096-bit RSA is great + for proof of concept, but meaningful communication requires two + parties. GnuPG requires both those parties to have their own + keys.

      + +

      Less than 1% of all email + traffic is PGP encrypted, meaning that those of us who do make our + messages private routinely find ourselves in the frustrating + predicament of having to share our thoughts insecurely, even though + we know they're being intercepted, even though this is easily + avoidable, and even though we've already taken steps to do so. All + because our friends and colleagues don't know the + benefits of GnuPG.

      + +

      Windows, Gnu/Linux, Mac, and Android all have point and click + GnuPG interfaces - at this point, all bases except iPhone are more + or less covered. That means the reason your contacts aren't OpenPGP + ready is not technical. And because GnuPG is Free + Software (and free of charge), it can't be about price.

      + +

      A recommendation from you is the most effective way you can + increase the number of GnuPG users, and consequently increase the + percentage of the messages you send that are meaningfully + encrypted. That's why we're asking people in our community to think + of pithy explanations of why GnuPG is important and how it enables + them.

      + +

      We've already got quotes from some big names like Bruce Schneier, + Jacob Appelbaum, and Richard Stallman. But the chances are + that your name carries more weight among your + peers. Please use it to share your appreciation for GnuPG!

      + +

      If you use social networks, you can + use #iloveGPG to connect your messages to other + people's, and make is easier for us to find and repeat them.

      + +

      Look out for weekly quotes posted from the + GnuPG Twitter + and Diaspora + accounts if you need inspiration. Let's fill up + the keyservers + with fresh keys from new users!

      + +

      +
      + +
      +

      Securing the future of GPG

      +
      Posted 5th November 2013 by Sam Tuke
      + +

      If you've noticed some changes around here, there's a good reason + why. We have a plan for securing the long term stability of GnuPG + development by giving more to our users, and asking more from them + in return.

      + +

      You already know that GnuPG is important, and as months of fresh + government spying revelations go by, it's becoming obvious that + GnuPG is one of the very few tools that can still be trusted to keep + our data safe from the overwhelming efforts of international law + enforcement. But developing GnuPG takes work - regular monitoring + for newfound threats and exploits, and new features to keep it sharp + with the latest encryption algorithms. We also need to reach out to + the millions of potential GnuPG users who are asking themselves how + they can make their email secure. Public-private key cryptography + hasn't yet gained mainstream acceptance, but it could if it were + just a little more appealing and accessible.

      + +

      To maintain progress within the project we need to make it easier + for GnuPG users to support the work that we do. Ours is an app that + is often hidden from view, relied upon daily by hundreds of + thousands of people, often in life-threatening circumstances, yet + low profile and rarely supported by publicity or donations.

      + +

      To change that we're going to launch a new + website with a fresh design, more friendly and accessible + information, and new resources to grow and strengthen our user + group. The new site will also allow the project to accept and manage + new forms of financial support, including automatic subscriptions to + sustain development long term.

      + +

      Designing, building and populating the new site will take a few + months, and in order to cover the costs there will be + a crowd-funding campaign with a modest target, in + early December. We have some rewards up our sleeves for those who + donate.

      + +

      When that time comes, we'll need your help - + telling your contacts, forwarding the announcement to your + communities, and contributing financially if you can.

      + +

      You can subscribe to updates about the campaign using this + form. This is separate to other GnuPG mailing lists - update will be + sent here, and only here.

      + + + + + +
      +
      + + +
      + +

      +
      + +
      +

      New blog, first post

      +
      Posted 30th October 2013 by Sam Tuke
      + +

      Welcome to Gnu Privacy Guard's new blog! We're planning some + major changes to gnupg.org and how the project communicates in + general. I'm Sam, and I'll be writing updates here as our work + progresses. In future this blog will be replaced with a more + beautiful and featureful alternative, but bear with us as we get + from here to there.

      + +

      For more timely updates you can follow our Twitter + accounts: @GnuPrivacyGuard + and @GnuPG. + That's right, we have two! But I'm going to combine them shortly so + it's easier to keep track [UPDATE: accounts now merged! + Stick with @GnuPG].

      + +

      For more information, see + our press + contact page hosted on Totem. That's all for now.

      + +

      +
      ----------------------------------------------------------------------- Summary of changes: ...{entry.templ.html => 20140127-find-fosdem.html} | 29 +- misc/blog.gnupg.org/img/keysigning-party-s.jpg | Bin 0 -> 53102 bytes misc/blog.gnupg.org/index.html | 1086 ++++++++++---------- 3 files changed, 576 insertions(+), 539 deletions(-) copy misc/blog.gnupg.org/{entry.templ.html => 20140127-find-fosdem.html} (74%) create mode 100644 misc/blog.gnupg.org/img/keysigning-party-s.jpg hooks/post-receive -- The GnuPG website and other docs http://git.gnupg.org From cvs at cvs.gnupg.org Mon Jan 27 17:26:17 2014 From: cvs at cvs.gnupg.org (by Sam Tuke) Date: Mon, 27 Jan 2014 17:26:17 +0100 Subject: [git] gnupg-doc - branch, master, updated. 7b17aa6d546251e04257bea9dc7c8e2b343726e2 Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The GnuPG website and other docs". The branch, master has been updated via 7b17aa6d546251e04257bea9dc7c8e2b343726e2 (commit) from 45455ced4e5c6d2f3cbc765fd599029da95579d7 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 7b17aa6d546251e04257bea9dc7c8e2b343726e2 Author: Sam Tuke Date: Mon Jan 27 17:26:56 2014 +0100 Removed superflous diff --git a/misc/blog.gnupg.org/20140127-find-fosdem.html b/misc/blog.gnupg.org/20140127-find-fosdem.html index 5d2720c..30e9401 100644 --- a/misc/blog.gnupg.org/20140127-find-fosdem.html +++ b/misc/blog.gnupg.org/20140127-find-fosdem.html @@ -85,7 +85,7 @@

      There won't be a GnuPG booth this year but, we shall be busy with meetings and mingling. Notes and contacts for us can be left at the FSFE booth.

      -

      And don't forget that you're invited to the continent's biggest keysigning party, organised by FOSDEM volunteers. Today is the last opportunity to submit your key, which is necessary for participation. Get to it!.

      +

      And don't forget that you're invited to the continent's biggest keysigning party, organised by FOSDEM volunteers. Today is the last opportunity to submit your key, which is necessary for participation. Get to it!.

      Bring your ideas. See you there.

      ----------------------------------------------------------------------- Summary of changes: misc/blog.gnupg.org/20140127-find-fosdem.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- The GnuPG website and other docs http://git.gnupg.org From cvs at cvs.gnupg.org Tue Jan 28 13:04:34 2014 From: cvs at cvs.gnupg.org (by Werner Koch) Date: Tue, 28 Jan 2014 13:04:34 +0100 Subject: [git] GCRYPT - branch, master, updated. libgcrypt-1.6.0-51-gcbdc355 Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The GNU crypto library". The branch, master has been updated via cbdc355415f83ed62da4f3618767eba54d7e6d37 (commit) via 7460e9243b3cc050631c37ed4f2713ae7bcb6762 (commit) via 3caa0f1319dc4779e0d6eee4460c1af2a12b2c3c (commit) from 5c150ece094bf0a504a111ce6c7b72e8d0b0457a (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit cbdc355415f83ed62da4f3618767eba54d7e6d37 Author: Werner Koch Date: Thu Jan 9 19:14:09 2014 +0100 sexp: Fix broken gcry_sexp_nth. * src/sexp.c (_gcry_sexp_nth): Return a valid S-expression for a data element. (NODE): Remove unused typedef. (ST_HINT): Comment unused macro. * tests/t-sexp.c (bug_1594): New. (main): Run new test. -- Before 1.6.0 gcry_sexp_nth (list, 0) with a LIST of "(a (b 3:pqr) (c 3:456) (d 3:xyz))" returned the entire list. 1.6.0 instead returned NULL. However, this is also surprising and the expected value would be "(a)". This patch fixes this. Somewhat related to that gcry_sexp_nth returned a broken list if requesting index 1 of a list like "(n foo)". It returned just the "foo" but not as a list which is required by the S-expression specs. Due to this patch the returned value is now "(foo)". Thanks to Ludovic Court?s for pointing out these problems. GnuPG-bug-id: 1594 diff --git a/doc/gcrypt.texi b/doc/gcrypt.texi index 4a91790..c5c3b45 100644 --- a/doc/gcrypt.texi +++ b/doc/gcrypt.texi @@ -4064,8 +4064,9 @@ no such element, @code{NULL} is returned. @deftypefun gcry_sexp_t gcry_sexp_car (@w{const gcry_sexp_t @var{list}}) Create and return a new S-expression from the first element in - at var{list}; this called the "type" and should always exist and be a -string. @code{NULL} is returned in case of a problem. + at var{list}; this is called the "type" and should always exist per +S-expression specification and in general be a string. @code{NULL} is +returned in case of a problem. @end deftypefun @deftypefun gcry_sexp_t gcry_sexp_cdr (@w{const gcry_sexp_t @var{list}}) diff --git a/src/sexp.c b/src/sexp.c index f31da00..0e4af52 100644 --- a/src/sexp.c +++ b/src/sexp.c @@ -1,7 +1,7 @@ /* sexp.c - S-Expression handling * Copyright (C) 1999, 2000, 2001, 2002, 2003, * 2004, 2006, 2007, 2008, 2011 Free Software Foundation, Inc. - * Copyright (C) 2013 g10 Code GmbH + * Copyright (C) 2013, 2014 g10 Code GmbH * * This file is part of Libgcrypt. * @@ -32,7 +32,55 @@ #define GCRYPT_NO_MPI_MACROS 1 #include "g10lib.h" -typedef struct gcry_sexp *NODE; + +/* Notes on the internal memory layout. + + We store an S-expression as one memory buffer with tags, length and + value. The simplest list would thus be: + + /----------+----------+---------+------+-----------+----------\ + | open_tag | data_tag | datalen | data | close_tag | stop_tag | + \----------+----------+---------+------+-----------+----------/ + + Expressed more compact and with an example: + + /----+----+----+---+----+----\ + | OT | DT | DL | D | CT | ST | "(foo)" + \----+----+----+---+----+----/ + + The open tag must always be the first tag of a list as requires by + the S-expression specs. At least data element (data_tag, datalen, + data) is required as well. The close_tag finishes the list and + would actually be sufficient. For fail-safe reasons a final stop + tag is always the last byte in a buffer; it has a value of 0 so + that string function accidently applied to an S-expression will + never access unallocated data. We do not support display hints and + thus don't need to represent them. A list may have more an + arbitrary number of data elements but at least one is required. + The length of each data must be greater than 0 and has a current + limit to 65535 bytes (by means of the DATALEN type). + + A list with two data elements: + + /----+----+----+---+----+----+---+----+----\ + | OT | DT | DL | D | DT | DL | D | CT | ST | "(foo bar)" + \----+----+----+---+----+----+---+----+----/ + + In the above example both DL fields have a value of 3. + A list of a list with one data element: + + /----+----+----+----+---+----+----+----\ + | OT | OT | DT | DL | D | CT | CT | ST | "((foo))" + \----+----+----+----+---+----+----+----/ + + A list with one element followed by another list: + + /----+----+----+---+----+----+----+---+----+----+----\ + | OT | DT | DL | D | OT | DT | DL | D | CT | CT | ST | "(foo (bar))" + \----+----+----+---+----+----+----+---+----+----+----/ + + */ + typedef unsigned short DATALEN; struct gcry_sexp @@ -42,11 +90,11 @@ struct gcry_sexp #define ST_STOP 0 #define ST_DATA 1 /* datalen follows */ -#define ST_HINT 2 /* datalen follows */ +/*#define ST_HINT 2 datalen follows (currently not used) */ #define ST_OPEN 3 #define ST_CLOSE 4 -/* the atoi macros assume that the buffer has only valid digits */ +/* The atoi macros assume that the buffer has only valid digits. */ #define atoi_1(p) (*(p) - '0' ) #define xtoi_1(p) (*(p) <= '9'? (*(p)- '0'): \ *(p) <= 'F'? (*(p)-'A'+10):(*(p)-'a'+10)) @@ -167,9 +215,10 @@ _gcry_sexp_dump (const gcry_sexp_t a) } } -/**************** - * Pass list through except when it is an empty list - in that case - * return NULL and release the passed list. + +/* Pass list through except when it is an empty list - in that case + * return NULL and release the passed list. This is used to make sure + * that no forbidden empty lists are created. */ static gcry_sexp_t normalize ( gcry_sexp_t list ) @@ -501,7 +550,7 @@ _gcry_sexp_length (const gcry_sexp_t list) /* Return the internal lengths offset of LIST. That is the size of - the buffer from the first ST_OPEN, which is retruned at R_OFF, to + the buffer from the first ST_OPEN, which is returned at R_OFF, to the corresponding ST_CLOSE inclusive. */ static size_t get_internal_buffer (const gcry_sexp_t list, size_t *r_off) @@ -542,8 +591,8 @@ get_internal_buffer (const gcry_sexp_t list, size_t *r_off) -/* Extract the CAR of the given list. May return NULL for bad lists - or memory failure. */ +/* Extract the n-th element of the given LIST. Returns NULL for + no-such-element, a corrupt list, or memory failure. */ gcry_sexp_t _gcry_sexp_nth (const gcry_sexp_t list, int number) { @@ -587,15 +636,16 @@ _gcry_sexp_nth (const gcry_sexp_t list, int number) if (*p == ST_DATA) { - memcpy (&n, p, sizeof n); - p += sizeof n; - newlist = xtrymalloc (sizeof *newlist + n + 1); + memcpy (&n, p+1, sizeof n); + newlist = xtrymalloc (sizeof *newlist + 1 + 1 + sizeof n + n + 1); if (!newlist) return NULL; d = newlist->d; - memcpy (d, p, n); - d += n; - *d++ = ST_STOP; + *d++ = ST_OPEN; + memcpy (d, p, 1 + sizeof n + n); + d += 1 + sizeof n + n; + *d++ = ST_CLOSE; + *d = ST_STOP; } else if (*p == ST_OPEN) { @@ -639,6 +689,7 @@ _gcry_sexp_nth (const gcry_sexp_t list, int number) return normalize (newlist); } + gcry_sexp_t _gcry_sexp_car (const gcry_sexp_t list) { diff --git a/tests/t-sexp.c b/tests/t-sexp.c index 3510382..1051723 100644 --- a/tests/t-sexp.c +++ b/tests/t-sexp.c @@ -978,6 +978,74 @@ check_extract_param (void) } +/* A test based on bug 1594. */ +static void +bug_1594 (void) +{ +static char thing[] = + "(signature" + " (public-key" + " (rsa" + " (n #00A53A6B3A50BE571F805BD98ECE1FCE4CE291C3D4D3E971740E1EE6D447F526" + " 6AC8973DDC82F0ADD234CC82E0A0A3F48B81ACC8B038DB8ACC3E78DC2ED2642F" + " 6BA353FCA60F47C2801DEB477B37FB8B2F5508AA1C6D922780DB142DEA19B812" + " C4E64F1138AD3BD61C58DB2D2591BE0BF36A1AC588AA45763BCDFF581050ABA8" + " CA47BD9723ADD6A308AE28471EDD2B16D03C941D4F2B7E019C43AF8972880633" + " 54E97B7E19F1677D84B69A26B184A77B719DD72C48E0EE36107046F786566A9D" + " 13BAD724D6D78F24700FC22FC000E1B2A8C1B08ED62008395B0764CD9B55E80D" + " A0A2B61C698DC27EA98E68BB576ACFC2B91B4D7283E7D960948D049D6E3C4CB1" + " F489B460A120A4BB6C04A843FD3A67454136DE61CF68A927871EFFA9141BD372" + " A748593C703E0301F039A9E674C50301BFC385BABE5B154250E7D57B82DB31F1" + " E1AC696F870DCD8FE8DEC75608B988FCA3B484F1FD7755BF452F99597269AF02" + " E8AF87D0F93DB427291659183D077254C835BFB6DDFD87CD0B5E0738682FCD34" + " 923F22551F73944E6CBE3ED6879B4414676B5DA0F30ED21DFA12BD2230C3C5D2" + " EA116A3EFEB4AEC21C58E63FAFA549A63190F01859445E9B80F427B80FD4C884" + " 2AD41FE760A3E9DEDFB56CEBE8EA783838B2B392CACDDC760CCE212E388AFBC1" + " 95DC6D0ED87E9091F82A82CE372738C8DE8ABD76ACD06AC8B80AA0597162DF59" + " 67#)" + " (e #010001#))))"; + gcry_sexp_t sig, pubkey, n, n_val; + + info ("checking fix for bug 1594\n"); + + if (gcry_sexp_new (&sig, thing, 0, 1)) + die ("scanning fixed string failed\n"); + pubkey = gcry_sexp_find_token (sig, "public-key", 0); + gcry_sexp_release (sig); + if (!pubkey) + { + fail ("'public-key' token not found"); + return; + } + n = gcry_sexp_find_token (pubkey, "n", 0); + if (!n) + { + fail ("'n' token not found"); + gcry_sexp_release (pubkey); + return; + } + n_val = gcry_sexp_nth (n, 1); + /* Bug 1594 would require the following test: + * if (n_val) + * fail ("extracting 1-th of 'n' list did not fail"); + * However, we meanwhile modified the S-expression functions to + * behave like Scheme to allow the access of any element of a list. + */ + if (!n_val) + fail ("extracting 1-th of 'n' list failed"); + /*gcry_log_debugsxp ("1-th", n_val); => "(#00A5...#)" */ + gcry_sexp_release (n_val); + n_val = gcry_sexp_nth (n, 2); + if (n_val) + fail ("extracting 2-th of 'n' list did not fail"); + n_val = gcry_sexp_nth (n, 0); + if (!n_val) + fail ("extracting 0-th of 'n' list failed"); + /*gcry_log_debugsxp ("0-th", n_val); => "(n)" */ + if (gcry_sexp_nth (n_val, 1)) + fail ("extracting 1-th of car of 'n' list did not fail"); + gcry_sexp_release (n_val); +} int @@ -1040,6 +1108,7 @@ main (int argc, char **argv) back_and_forth (); check_sscan (); check_extract_param (); + bug_1594 (); return errorcount? 1:0; } commit 7460e9243b3cc050631c37ed4f2713ae7bcb6762 Author: Werner Koch Date: Thu Jan 9 19:14:09 2014 +0100 tests: Improve t-common.h. * tests/t-common.h: Add couple of macros. Check that config.h has been included. (show): Rename to info. * tests/t-lock.c, tests/t-sexp.c: Adjust for changes. Signed-off-by: Werner Koch diff --git a/tests/t-common.h b/tests/t-common.h index 288963d..3546986 100644 --- a/tests/t-common.h +++ b/tests/t-common.h @@ -21,16 +21,39 @@ #include "../src/gcrypt.h" -#ifndef PGM -# error Macro PGM not defined. +#ifndef PGMNAME +# error Macro PGMNAME not defined. #endif +#ifndef _GCRYPT_CONFIG_H_INCLUDED +# error config.h not included +#endif + +/* A couple of useful macros. */ +#ifndef DIM +# define DIM(v) (sizeof(v)/sizeof((v)[0])) +#endif +#define my_isascii(c) (!((c) & 0x80)) +#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)) +#define xmalloc(a) gcry_xmalloc ((a)) +#define xcalloc(a,b) gcry_xcalloc ((a),(b)) +#define xstrdup(a) gcry_xstrdup ((a)) +#define xfree(a) gcry_free ((a)) +#define pass() do { ; } while (0) +/* Standard global variables. */ static int verbose; static int debug; static int errorcount; +/* Reporting functions. */ static void die (const char *format, ...) { @@ -40,7 +63,7 @@ die (const char *format, ...) #ifdef HAVE_FLOCKFILE flockfile (stderr); #endif - fprintf (stderr, "%s: ", PGM); + fprintf (stderr, "%s: ", PGMNAME); va_start (arg_ptr, format) ; vfprintf (stderr, format, arg_ptr); va_end (arg_ptr); @@ -62,7 +85,7 @@ fail (const char *format, ...) #ifdef HAVE_FLOCKFILE flockfile (stderr); #endif - fprintf (stderr, "%s: ", PGM); + fprintf (stderr, "%s: ", PGMNAME); va_start (arg_ptr, format); vfprintf (stderr, format, arg_ptr); va_end (arg_ptr); @@ -78,7 +101,7 @@ fail (const char *format, ...) static void -show (const char *format, ...) +info (const char *format, ...) { va_list arg_ptr; @@ -87,7 +110,7 @@ show (const char *format, ...) #ifdef HAVE_FLOCKFILE flockfile (stderr); #endif - fprintf (stderr, "%s: ", PGM); + fprintf (stderr, "%s: ", PGMNAME); va_start (arg_ptr, format); vfprintf (stderr, format, arg_ptr); if (*format && format[strlen(format)-1] != '\n') diff --git a/tests/t-lock.c b/tests/t-lock.c index c6c1e41..22b67ef 100644 --- a/tests/t-lock.c +++ b/tests/t-lock.c @@ -31,7 +31,7 @@ # include #endif -#define PGM "t-lock" +#define PGMNAME "t-lock" #include "t-common.h" @@ -152,7 +152,7 @@ nonce_thread (void *argarg) { gcry_create_nonce (nonce, sizeof nonce); if (i && !(i%100)) - show ("thread %d created %d nonces so far", arg->no, i); + info ("thread %d created %d nonces so far", arg->no, i); } gcry_free (arg); @@ -186,7 +186,7 @@ check_nonce_lock (void) { rc = WaitForSingleObject (threads[i], INFINITE); if (rc == WAIT_OBJECT_0) - show ("nonce thread %d has terminated", i); + info ("nonce thread %d has terminated", i); else fail ("waiting for nonce thread %d failed: %d", i, (int)GetLastError ()); @@ -211,7 +211,7 @@ check_nonce_lock (void) fail ("pthread_join failed for nonce thread %d: %s", i, strerror (errno)); else - show ("nonce thread %d has terminated", i); + info ("nonce thread %d has terminated", i); } #endif /*!_WIN32*/ @@ -345,7 +345,7 @@ run_test (void) { rc = WaitForSingleObject (athreads[i], INFINITE); if (rc == WAIT_OBJECT_0) - show ("accountant thread %d has terminated", i); + info ("accountant thread %d has terminated", i); else fail ("waiting for accountant thread %d failed: %d", i, (int)GetLastError ()); @@ -355,7 +355,7 @@ run_test (void) rc = WaitForSingleObject (rthread, INFINITE); if (rc == WAIT_OBJECT_0) - show ("revision thread has terminated"); + info ("revision thread has terminated"); else fail ("waiting for revision thread failed: %d", (int)GetLastError ()); CloseHandle (rthread); @@ -379,7 +379,7 @@ run_test (void) fail ("pthread_join failed for accountant thread %d: %s", i, strerror (errno)); else - show ("accountant thread %d has terminated", i); + info ("accountant thread %d has terminated", i); } stop_revision_thread = 1; @@ -387,7 +387,7 @@ run_test (void) if (rc) fail ("pthread_join failed for the revision thread: %s", strerror (errno)); else - show ("revision thread has terminated"); + info ("revision thread has terminated"); #endif /*!_WIN32*/ @@ -438,6 +438,9 @@ main (int argc, char **argv) gcry_control (GCRYCTL_DISABLE_SECMEM, 0); if (!gcry_check_version (GCRYPT_VERSION)) die ("version mismatch"); + /* We are using non-public interfaces - check the exact version. */ + if (strcmp (gcry_check_version (NULL), GCRYPT_VERSION)) + die ("exact version match failed"); gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0); gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); diff --git a/tests/t-sexp.c b/tests/t-sexp.c index 4c48277..3510382 100644 --- a/tests/t-sexp.c +++ b/tests/t-sexp.c @@ -1,5 +1,6 @@ /* t-sexp.c - S-expression regression tests - * Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc. + * Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc. + * Copyright (C) 2014 g10 Code GmbH * * This file is part of Libgcrypt. * @@ -14,8 +15,7 @@ * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + * License along with this program; if not, see . */ #ifdef HAVE_CONFIG_H @@ -29,72 +29,7 @@ #include "../src/gcrypt-int.h" #define PGMNAME "t-sexp" - -#ifndef DIM -# define DIM(v) (sizeof(v)/sizeof((v)[0])) -#endif -#define my_isascii(c) (!((c) & 0x80)) -#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)) -#define xmalloc(a) gcry_xmalloc ((a)) -#define xcalloc(a,b) gcry_xcalloc ((a),(b)) -#define xstrdup(a) gcry_xstrdup ((a)) -#define xfree(a) gcry_free ((a)) -#define pass() do { ; } while (0) - - -static int verbose; -static int error_count; - -static void -die (const char *format, ...) -{ - va_list arg_ptr ; - - fflush (stdout); - fprintf (stderr, "%s: ", PGMNAME); - va_start( arg_ptr, format ) ; - vfprintf (stderr, format, arg_ptr ); - va_end(arg_ptr); - if (*format && format[strlen(format)-1] != '\n') - putc ('\n', stderr); - exit (1); -} - -static void -info (const char *format, ...) -{ - va_list arg_ptr; - - if (verbose) - { - va_start( arg_ptr, format ) ; - vfprintf (stderr, format, arg_ptr ); - va_end(arg_ptr); - if (*format && format[strlen(format)-1] != '\n') - putc ('\n', stderr); - } -} - -static void -fail ( const char *format, ... ) -{ - va_list arg_ptr ; - - fputs (PGMNAME ": ", stderr); - va_start( arg_ptr, format ) ; - vfprintf (stderr, format, arg_ptr ); - va_end(arg_ptr); - if (*format && format[strlen(format)-1] != '\n') - putc ('\n', stderr); - error_count++; -} - +#include "t-common.h" /* Convert STRING consisting of hex characters into its binary @@ -1043,14 +978,62 @@ check_extract_param (void) } + + int main (int argc, char **argv) { - if (argc > 1 && !strcmp (argv[1], "--verbose")) - verbose = 1; + int last_argc = -1; + + if (argc) + { + argc--; argv++; + } + while (argc && last_argc != argc ) + { + last_argc = argc; + if (!strcmp (*argv, "--")) + { + argc--; argv++; + break; + } + else if (!strcmp (*argv, "--help")) + { + puts ( +"usage: " PGMNAME " [options]\n" +"\n" +"Options:\n" +" --verbose Show what is going on\n" +" --debug Flyswatter\n" +); + exit (0); + } + else if (!strcmp (*argv, "--verbose")) + { + verbose = 1; + argc--; argv++; + } + else if (!strcmp (*argv, "--debug")) + { + verbose = debug = 1; + argc--; argv++; + } + else if (!strncmp (*argv, "--", 2)) + die ("unknown option '%s'", *argv); + } + if (debug) + gcry_control (GCRYCTL_SET_DEBUG_FLAGS, 1u, 0); gcry_control (GCRYCTL_DISABLE_SECMEM_WARN); gcry_control (GCRYCTL_INIT_SECMEM, 16384, 0); + if (!gcry_check_version (GCRYPT_VERSION)) + die ("version mismatch"); + /* #include "../src/gcrypt-int.h" indicates that internal interfaces + may be used; thus better do an exact version check. */ + if (strcmp (gcry_check_version (NULL), GCRYPT_VERSION)) + die ("exact version match failed"); + gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0); + gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); basic (); canon_len (); @@ -1058,5 +1041,5 @@ main (int argc, char **argv) check_sscan (); check_extract_param (); - return error_count? 1:0; + return errorcount? 1:0; } commit 3caa0f1319dc4779e0d6eee4460c1af2a12b2c3c Author: Werner Koch Date: Thu Jan 9 19:14:09 2014 +0100 mpi: Minor fix for Atari-mint. * mpi/config.links [m68k-atari-mint]: Do not assume 68020. Suggested by Alan Hourihane. (cherry picked from commit 420f42a5752e90a8b27d58ffa1ddfe6e4ab341e8) diff --git a/mpi/config.links b/mpi/config.links index 57e6c2a..0217d35 100644 --- a/mpi/config.links +++ b/mpi/config.links @@ -260,7 +260,7 @@ case "${host}" in m68k-atari-mint) echo '#define MIT_SYNTAX' >>./mpi/asm-syntax.h cat $srcdir/mpi/m68k/syntax.h >>./mpi/asm-syntax.h - path="m68k/mc68020 m68k" + path="m68k" mpi_cpu_arch="m68k" ;; m68000*-*-* | \ ----------------------------------------------------------------------- Summary of changes: doc/gcrypt.texi | 5 +- mpi/config.links | 2 +- src/sexp.c | 83 ++++++++++++++++++----- tests/t-common.h | 35 ++++++++-- tests/t-lock.c | 19 +++--- tests/t-sexp.c | 196 ++++++++++++++++++++++++++++++++++-------------------- 6 files changed, 235 insertions(+), 105 deletions(-) hooks/post-receive -- The GNU crypto library http://git.gnupg.org From cvs at cvs.gnupg.org Tue Jan 28 16:05:41 2014 From: cvs at cvs.gnupg.org (by Werner Koch) Date: Tue, 28 Jan 2014 16:05:41 +0100 Subject: [git] GCRYPT - branch, LIBGCRYPT-1-6-BRANCH, updated. libgcrypt-1.6.0-20-g8ca5966 Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The GNU crypto library". The branch, LIBGCRYPT-1-6-BRANCH has been updated via 8ca5966198b4d0d3932978880dc21cb75bf75d56 (commit) from 420f42a5752e90a8b27d58ffa1ddfe6e4ab341e8 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 8ca5966198b4d0d3932978880dc21cb75bf75d56 Author: Werner Koch Date: Thu Jan 9 19:14:09 2014 +0100 sexp: Fix broken gcry_sexp_nth. * src/sexp.c (_gcry_sexp_nth): Return a valid S-expression for a data element. (NODE): Remove unused typedef. (ST_HINT): Comment unused macro. * tests/tsexp.c (bug_1594): New. (main): Run new test. -- Before 1.6.0 gcry_sexp_nth (list, 0) with a LIST of "(a (b 3:pqr) (c 3:456) (d 3:xyz))" returned the entire list. 1.6.0 instead returned NULL. However, this is also surprising and the expected value would be "(a)". This patch fixes this. Somewhat related to that gcry_sexp_nth returned a broken list if requesting index 1 of a list like "(n foo)". It returned just the "foo" but not as a list which is required by the S-expression specs. Due to this patch the returned value is now "(foo)". Thanks to Ludovic Court?s for pointing out these problems. GnuPG-bug-id: 1594 (cherry picked from commit cbdc355415f83ed62da4f3618767eba54d7e6d37) Resolved conflicts: tests/tsexp.c: Fix for renamed file in master. diff --git a/doc/gcrypt.texi b/doc/gcrypt.texi index c2534a2..58491fb 100644 --- a/doc/gcrypt.texi +++ b/doc/gcrypt.texi @@ -4137,8 +4137,9 @@ no such element, @code{NULL} is returned. @deftypefun gcry_sexp_t gcry_sexp_car (@w{const gcry_sexp_t @var{list}}) Create and return a new S-expression from the first element in - at var{list}; this called the "type" and should always exist and be a -string. @code{NULL} is returned in case of a problem. + at var{list}; this is called the "type" and should always exist per +S-expression specification and in general be a string. @code{NULL} is +returned in case of a problem. @end deftypefun @deftypefun gcry_sexp_t gcry_sexp_cdr (@w{const gcry_sexp_t @var{list}}) diff --git a/src/sexp.c b/src/sexp.c index f31da00..0e4af52 100644 --- a/src/sexp.c +++ b/src/sexp.c @@ -1,7 +1,7 @@ /* sexp.c - S-Expression handling * Copyright (C) 1999, 2000, 2001, 2002, 2003, * 2004, 2006, 2007, 2008, 2011 Free Software Foundation, Inc. - * Copyright (C) 2013 g10 Code GmbH + * Copyright (C) 2013, 2014 g10 Code GmbH * * This file is part of Libgcrypt. * @@ -32,7 +32,55 @@ #define GCRYPT_NO_MPI_MACROS 1 #include "g10lib.h" -typedef struct gcry_sexp *NODE; + +/* Notes on the internal memory layout. + + We store an S-expression as one memory buffer with tags, length and + value. The simplest list would thus be: + + /----------+----------+---------+------+-----------+----------\ + | open_tag | data_tag | datalen | data | close_tag | stop_tag | + \----------+----------+---------+------+-----------+----------/ + + Expressed more compact and with an example: + + /----+----+----+---+----+----\ + | OT | DT | DL | D | CT | ST | "(foo)" + \----+----+----+---+----+----/ + + The open tag must always be the first tag of a list as requires by + the S-expression specs. At least data element (data_tag, datalen, + data) is required as well. The close_tag finishes the list and + would actually be sufficient. For fail-safe reasons a final stop + tag is always the last byte in a buffer; it has a value of 0 so + that string function accidently applied to an S-expression will + never access unallocated data. We do not support display hints and + thus don't need to represent them. A list may have more an + arbitrary number of data elements but at least one is required. + The length of each data must be greater than 0 and has a current + limit to 65535 bytes (by means of the DATALEN type). + + A list with two data elements: + + /----+----+----+---+----+----+---+----+----\ + | OT | DT | DL | D | DT | DL | D | CT | ST | "(foo bar)" + \----+----+----+---+----+----+---+----+----/ + + In the above example both DL fields have a value of 3. + A list of a list with one data element: + + /----+----+----+----+---+----+----+----\ + | OT | OT | DT | DL | D | CT | CT | ST | "((foo))" + \----+----+----+----+---+----+----+----/ + + A list with one element followed by another list: + + /----+----+----+---+----+----+----+---+----+----+----\ + | OT | DT | DL | D | OT | DT | DL | D | CT | CT | ST | "(foo (bar))" + \----+----+----+---+----+----+----+---+----+----+----/ + + */ + typedef unsigned short DATALEN; struct gcry_sexp @@ -42,11 +90,11 @@ struct gcry_sexp #define ST_STOP 0 #define ST_DATA 1 /* datalen follows */ -#define ST_HINT 2 /* datalen follows */ +/*#define ST_HINT 2 datalen follows (currently not used) */ #define ST_OPEN 3 #define ST_CLOSE 4 -/* the atoi macros assume that the buffer has only valid digits */ +/* The atoi macros assume that the buffer has only valid digits. */ #define atoi_1(p) (*(p) - '0' ) #define xtoi_1(p) (*(p) <= '9'? (*(p)- '0'): \ *(p) <= 'F'? (*(p)-'A'+10):(*(p)-'a'+10)) @@ -167,9 +215,10 @@ _gcry_sexp_dump (const gcry_sexp_t a) } } -/**************** - * Pass list through except when it is an empty list - in that case - * return NULL and release the passed list. + +/* Pass list through except when it is an empty list - in that case + * return NULL and release the passed list. This is used to make sure + * that no forbidden empty lists are created. */ static gcry_sexp_t normalize ( gcry_sexp_t list ) @@ -501,7 +550,7 @@ _gcry_sexp_length (const gcry_sexp_t list) /* Return the internal lengths offset of LIST. That is the size of - the buffer from the first ST_OPEN, which is retruned at R_OFF, to + the buffer from the first ST_OPEN, which is returned at R_OFF, to the corresponding ST_CLOSE inclusive. */ static size_t get_internal_buffer (const gcry_sexp_t list, size_t *r_off) @@ -542,8 +591,8 @@ get_internal_buffer (const gcry_sexp_t list, size_t *r_off) -/* Extract the CAR of the given list. May return NULL for bad lists - or memory failure. */ +/* Extract the n-th element of the given LIST. Returns NULL for + no-such-element, a corrupt list, or memory failure. */ gcry_sexp_t _gcry_sexp_nth (const gcry_sexp_t list, int number) { @@ -587,15 +636,16 @@ _gcry_sexp_nth (const gcry_sexp_t list, int number) if (*p == ST_DATA) { - memcpy (&n, p, sizeof n); - p += sizeof n; - newlist = xtrymalloc (sizeof *newlist + n + 1); + memcpy (&n, p+1, sizeof n); + newlist = xtrymalloc (sizeof *newlist + 1 + 1 + sizeof n + n + 1); if (!newlist) return NULL; d = newlist->d; - memcpy (d, p, n); - d += n; - *d++ = ST_STOP; + *d++ = ST_OPEN; + memcpy (d, p, 1 + sizeof n + n); + d += 1 + sizeof n + n; + *d++ = ST_CLOSE; + *d = ST_STOP; } else if (*p == ST_OPEN) { @@ -639,6 +689,7 @@ _gcry_sexp_nth (const gcry_sexp_t list, int number) return normalize (newlist); } + gcry_sexp_t _gcry_sexp_car (const gcry_sexp_t list) { diff --git a/tests/tsexp.c b/tests/tsexp.c index 704f9b1..5a02c26 100644 --- a/tests/tsexp.c +++ b/tests/tsexp.c @@ -1043,6 +1043,76 @@ check_extract_param (void) } +/* A test based on bug 1594. */ +static void +bug_1594 (void) +{ +static char thing[] = + "(signature" + " (public-key" + " (rsa" + " (n #00A53A6B3A50BE571F805BD98ECE1FCE4CE291C3D4D3E971740E1EE6D447F526" + " 6AC8973DDC82F0ADD234CC82E0A0A3F48B81ACC8B038DB8ACC3E78DC2ED2642F" + " 6BA353FCA60F47C2801DEB477B37FB8B2F5508AA1C6D922780DB142DEA19B812" + " C4E64F1138AD3BD61C58DB2D2591BE0BF36A1AC588AA45763BCDFF581050ABA8" + " CA47BD9723ADD6A308AE28471EDD2B16D03C941D4F2B7E019C43AF8972880633" + " 54E97B7E19F1677D84B69A26B184A77B719DD72C48E0EE36107046F786566A9D" + " 13BAD724D6D78F24700FC22FC000E1B2A8C1B08ED62008395B0764CD9B55E80D" + " A0A2B61C698DC27EA98E68BB576ACFC2B91B4D7283E7D960948D049D6E3C4CB1" + " F489B460A120A4BB6C04A843FD3A67454136DE61CF68A927871EFFA9141BD372" + " A748593C703E0301F039A9E674C50301BFC385BABE5B154250E7D57B82DB31F1" + " E1AC696F870DCD8FE8DEC75608B988FCA3B484F1FD7755BF452F99597269AF02" + " E8AF87D0F93DB427291659183D077254C835BFB6DDFD87CD0B5E0738682FCD34" + " 923F22551F73944E6CBE3ED6879B4414676B5DA0F30ED21DFA12BD2230C3C5D2" + " EA116A3EFEB4AEC21C58E63FAFA549A63190F01859445E9B80F427B80FD4C884" + " 2AD41FE760A3E9DEDFB56CEBE8EA783838B2B392CACDDC760CCE212E388AFBC1" + " 95DC6D0ED87E9091F82A82CE372738C8DE8ABD76ACD06AC8B80AA0597162DF59" + " 67#)" + " (e #010001#))))"; + gcry_sexp_t sig, pubkey, n, n_val; + + info ("checking fix for bug 1594\n"); + + if (gcry_sexp_new (&sig, thing, 0, 1)) + die ("scanning fixed string failed\n"); + pubkey = gcry_sexp_find_token (sig, "public-key", 0); + gcry_sexp_release (sig); + if (!pubkey) + { + fail ("'public-key' token not found"); + return; + } + n = gcry_sexp_find_token (pubkey, "n", 0); + if (!n) + { + fail ("'n' token not found"); + gcry_sexp_release (pubkey); + return; + } + n_val = gcry_sexp_nth (n, 1); + /* Bug 1594 would require the following test: + * if (n_val) + * fail ("extracting 1-th of 'n' list did not fail"); + * However, we meanwhile modified the S-expression functions to + * behave like Scheme to allow the access of any element of a list. + */ + if (!n_val) + fail ("extracting 1-th of 'n' list failed"); + /*gcry_log_debugsxp ("1-th", n_val); => "(#00A5...#)" */ + gcry_sexp_release (n_val); + n_val = gcry_sexp_nth (n, 2); + if (n_val) + fail ("extracting 2-th of 'n' list did not fail"); + n_val = gcry_sexp_nth (n, 0); + if (!n_val) + fail ("extracting 0-th of 'n' list failed"); + /*gcry_log_debugsxp ("0-th", n_val); => "(n)" */ + if (gcry_sexp_nth (n_val, 1)) + fail ("extracting 1-th of car of 'n' list did not fail"); + gcry_sexp_release (n_val); +} + + int main (int argc, char **argv) { @@ -1057,6 +1127,7 @@ main (int argc, char **argv) back_and_forth (); check_sscan (); check_extract_param (); + bug_1594 (); return error_count? 1:0; } ----------------------------------------------------------------------- Summary of changes: doc/gcrypt.texi | 5 ++-- src/sexp.c | 83 ++++++++++++++++++++++++++++++++++++++++++++----------- tests/tsexp.c | 71 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 141 insertions(+), 18 deletions(-) hooks/post-receive -- The GNU crypto library http://git.gnupg.org From cvs at cvs.gnupg.org Tue Jan 28 17:03:08 2014 From: cvs at cvs.gnupg.org (by Werner Koch) Date: Tue, 28 Jan 2014 17:03:08 +0100 Subject: [git] GCRYPT - branch, master, updated. libgcrypt-1.6.0-52-g52f7c48 Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The GNU crypto library". The branch, master has been updated via 52f7c48c901a3de51bd690a218f3de2f71e8d790 (commit) from cbdc355415f83ed62da4f3618767eba54d7e6d37 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 52f7c48c901a3de51bd690a218f3de2f71e8d790 Author: Werner Koch Date: Tue Jan 28 17:00:27 2014 +0100 cipher: Take care of ENABLE_NEON_SUPPORT. * cipher/salsa20.c (USE_ARM_NEON_ASM): Define only if ENABLE_NEON_SUPPORT is defined. * cipher/serpent.c (USE_NEON): Ditto. * cipher/sha1.c (USE_NEON): Ditto. * cipher/sha512.c (USE_ARM_NEON_ASM): Ditto. -- The generic C source files must only include NEON support if that is enabled. The dedicated ASM files are conditionally compiled and thus do not need to use it. GnuPG-bug-id: 1603 Signed-off-by: Werner Koch diff --git a/cipher/salsa20.c b/cipher/salsa20.c index 72b28b0..d75fe51 100644 --- a/cipher/salsa20.c +++ b/cipher/salsa20.c @@ -49,12 +49,13 @@ /* USE_ARM_NEON_ASM indicates whether to enable ARM NEON assembly code. */ #undef USE_ARM_NEON_ASM -#if defined(HAVE_ARM_ARCH_V6) && defined(__ARMEL__) -# if defined(HAVE_COMPATIBLE_GCC_ARM_PLATFORM_AS) && \ - defined(HAVE_GCC_INLINE_ASM_NEON) +#ifdef ENABLE_NEON_SUPPORT +# if defined(HAVE_ARM_ARCH_V6) && defined(__ARMEL__) \ + && defined(HAVE_COMPATIBLE_GCC_ARM_PLATFORM_AS) \ + && defined(HAVE_GCC_INLINE_ASM_NEON) # define USE_ARM_NEON_ASM 1 # endif -#endif +#endif /*ENABLE_NEON_SUPPORT*/ #define SALSA20_MIN_KEY_SIZE 16 /* Bytes. */ diff --git a/cipher/serpent.c b/cipher/serpent.c index 8e647d4..0be49da 100644 --- a/cipher/serpent.c +++ b/cipher/serpent.c @@ -48,13 +48,13 @@ /* USE_NEON indicates whether to enable ARM NEON assembly code. */ #undef USE_NEON -#if defined(HAVE_ARM_ARCH_V6) && defined(__ARMEL__) -# if defined(HAVE_COMPATIBLE_GCC_ARM_PLATFORM_AS) && \ - defined(HAVE_GCC_INLINE_ASM_NEON) +#ifdef ENABLE_NEON_SUPPORT +# if defined(HAVE_ARM_ARCH_V6) && defined(__ARMEL__) \ + && defined(HAVE_COMPATIBLE_GCC_ARM_PLATFORM_AS) \ + && defined(HAVE_GCC_INLINE_ASM_NEON) # define USE_NEON 1 # endif -#endif - +#endif /*ENABLE_NEON_SUPPORT*/ /* Number of rounds per Serpent encrypt/decrypt operation. */ #define ROUNDS 32 diff --git a/cipher/sha1.c b/cipher/sha1.c index 65bd686..00c57dd 100644 --- a/cipher/sha1.c +++ b/cipher/sha1.c @@ -66,12 +66,13 @@ /* USE_NEON indicates whether to enable ARM NEON assembly code. */ #undef USE_NEON -#if defined(HAVE_ARM_ARCH_V6) && defined(__ARMEL__) -# if defined(HAVE_COMPATIBLE_GCC_ARM_PLATFORM_AS) && \ - defined(HAVE_GCC_INLINE_ASM_NEON) +#ifdef ENABLE_NEON_SUPPORT +# if defined(HAVE_ARM_ARCH_V6) && defined(__ARMEL__) \ + && defined(HAVE_COMPATIBLE_GCC_ARM_PLATFORM_AS) \ + && defined(HAVE_GCC_INLINE_ASM_NEON) # define USE_NEON 1 # endif -#endif +#endif /*ENABLE_NEON_SUPPORT*/ /* A macro to test whether P is properly aligned for an u32 type. diff --git a/cipher/sha512.c b/cipher/sha512.c index 92b4913..7d60df0 100644 --- a/cipher/sha512.c +++ b/cipher/sha512.c @@ -57,12 +57,13 @@ /* USE_ARM_NEON_ASM indicates whether to enable ARM NEON assembly code. */ #undef USE_ARM_NEON_ASM -#if defined(HAVE_ARM_ARCH_V6) && defined(__ARMEL__) -# if defined(HAVE_COMPATIBLE_GCC_ARM_PLATFORM_AS) && \ - defined(HAVE_GCC_INLINE_ASM_NEON) +#ifdef ENABLE_NEON_SUPPORT +# if defined(HAVE_ARM_ARCH_V6) && defined(__ARMEL__) \ + && defined(HAVE_COMPATIBLE_GCC_ARM_PLATFORM_AS) \ + && defined(HAVE_GCC_INLINE_ASM_NEON) # define USE_ARM_NEON_ASM 1 # endif -#endif +#endif /*ENABLE_NEON_SUPPORT*/ /* USE_SSSE3 indicates whether to compile with Intel SSSE3 code. */ ----------------------------------------------------------------------- Summary of changes: cipher/salsa20.c | 9 +++++---- cipher/serpent.c | 10 +++++----- cipher/sha1.c | 9 +++++---- cipher/sha512.c | 9 +++++---- 4 files changed, 20 insertions(+), 17 deletions(-) hooks/post-receive -- The GNU crypto library http://git.gnupg.org From cvs at cvs.gnupg.org Tue Jan 28 23:50:25 2014 From: cvs at cvs.gnupg.org (by Werner Koch) Date: Tue, 28 Jan 2014 23:50:25 +0100 Subject: [git] GPG-ERROR - branch, master, updated. libgpg-error-1.12-20-g6245bf6 Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Error codes used by GnuPG et al.". The branch, master has been updated via 6245bf65fc2554c7c103324d451036de08869458 (commit) from e1aa030d7655743f0c3cdd5f7b26ae1b4665fbc6 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 6245bf65fc2554c7c103324d451036de08869458 Author: Werner Koch Date: Tue Jan 28 23:49:01 2014 +0100 Fix the name of the file in the comment of the output. * src/gen-posix-lock-obj.c (main): Chnage comment in created file. diff --git a/src/gen-posix-lock-obj.c b/src/gen-posix-lock-obj.c index 7644c6f..de2c8bc 100644 --- a/src/gen-posix-lock-obj.c +++ b/src/gen-posix-lock-obj.c @@ -66,7 +66,7 @@ main (void) /* To force a probably suitable alignment of the structure we use a union and include a long and a pointer to a long. */ - printf ("## lock-obj.%s.h\n" + printf ("## lock-obj-pub.%s.h\n" "## File created by " PGM " - DO NOT EDIT\n" "## To be included by mkheader into gpg-error.h\n" "\n" ----------------------------------------------------------------------- Summary of changes: src/gen-posix-lock-obj.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- Error codes used by GnuPG et al. http://git.gnupg.org From cvs at cvs.gnupg.org Wed Jan 29 00:36:27 2014 From: cvs at cvs.gnupg.org (by NIIBE Yutaka) Date: Wed, 29 Jan 2014 00:36:27 +0100 Subject: [git] GCRYPT - branch, master, updated. libgcrypt-1.6.0-53-g121a90d Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The GNU crypto library". The branch, master has been updated via 121a90d8931944974054f7d94f63b7f89df87fa5 (commit) from 52f7c48c901a3de51bd690a218f3de2f71e8d790 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 121a90d8931944974054f7d94f63b7f89df87fa5 Author: NIIBE Yutaka Date: Wed Jan 29 08:32:46 2014 +0900 Fix RSA Blinding. * cipher/rsa.c (rsa_decrypt): Loop to get multiplicative inverse. Signed-off-by: NIIBE Yutaka diff --git a/cipher/rsa.c b/cipher/rsa.c index e595e38..9a8d235 100644 --- a/cipher/rsa.c +++ b/cipher/rsa.c @@ -1023,13 +1023,12 @@ rsa_decrypt (gcry_sexp_t *r_plain, gcry_sexp_t s_data, gcry_sexp_t keyparms) ri = mpi_snew (ctx.nbits); bldata = mpi_snew (ctx.nbits); - _gcry_mpi_randomize (r, ctx.nbits, GCRY_WEAK_RANDOM); - mpi_mod (r, r, sk.n); - if (!mpi_invm (ri, r, sk.n)) + do { - rc = GPG_ERR_INTERNAL; - goto leave; + _gcry_mpi_randomize (r, ctx.nbits, GCRY_WEAK_RANDOM); + mpi_mod (r, r, sk.n); } + while (!mpi_invm (ri, r, sk.n)); /* Do blinding. We calculate: y = (x * r^e) mod n, where r is the random number, e is the public exponent, x is the ----------------------------------------------------------------------- Summary of changes: cipher/rsa.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) hooks/post-receive -- The GNU crypto library http://git.gnupg.org From cvs at cvs.gnupg.org Wed Jan 29 08:48:15 2014 From: cvs at cvs.gnupg.org (by Werner Koch) Date: Wed, 29 Jan 2014 08:48:15 +0100 Subject: [git] GPG-ERROR - branch, master, updated. libgpg-error-1.12-21-gbb5318a Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Error codes used by GnuPG et al.". The branch, master has been updated via bb5318aa5536fa48ec240c2ff48b9e2e1d9916ef (commit) from 6245bf65fc2554c7c103324d451036de08869458 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit bb5318aa5536fa48ec240c2ff48b9e2e1d9916ef Author: Werner Koch Date: Wed Jan 29 08:47:01 2014 +0100 Fix a syscfg/ file name. * src/syscfg/lock-obj.arm-unknown-linux-androideabi.h: Rename to ... * src/syscfg/lock-obj-pub.arm-unknown-linux-androideabi.h: this. * src/Makefile.am (lock_obj_pub): Fix file name. -- Ooops. A wrong comment in a generated header can make a lot of trouble. diff --git a/src/Makefile.am b/src/Makefile.am index 0a8a59a..e201cee 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -42,7 +42,7 @@ endif # Distributed lock object definitions for cross compilation. lock_obj_pub = \ syscfg/lock-obj-pub.mingw32.h \ - syscfg/lock-obj.arm-unknown-linux-androideabi.h + syscfg/lock-obj-pub.arm-unknown-linux-androideabi.h lib_LTLIBRARIES = libgpg-error.la include_HEADERS = gpg-error.h diff --git a/src/syscfg/lock-obj.arm-unknown-linux-androideabi.h b/src/syscfg/lock-obj-pub.arm-unknown-linux-androideabi.h similarity index 87% rename from src/syscfg/lock-obj.arm-unknown-linux-androideabi.h rename to src/syscfg/lock-obj-pub.arm-unknown-linux-androideabi.h index adcf46f..56319f5 100644 --- a/src/syscfg/lock-obj.arm-unknown-linux-androideabi.h +++ b/src/syscfg/lock-obj-pub.arm-unknown-linux-androideabi.h @@ -1,4 +1,4 @@ -## lock-obj.arm-unknown-linux-androideabi.h +## lock-obj-pub.arm-unknown-linux-androideabi.h ## File created by gen-posix-lock-obj - DO NOT EDIT ## To be included by mkheader into gpg-error.h ----------------------------------------------------------------------- Summary of changes: src/Makefile.am | 2 +- ...ux-androideabi.h => lock-obj-pub.arm-unknown-linux-androideabi.h} | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename src/syscfg/{lock-obj.arm-unknown-linux-androideabi.h => lock-obj-pub.arm-unknown-linux-androideabi.h} (87%) hooks/post-receive -- Error codes used by GnuPG et al. http://git.gnupg.org From cvs at cvs.gnupg.org Wed Jan 29 10:49:39 2014 From: cvs at cvs.gnupg.org (by Werner Koch) Date: Wed, 29 Jan 2014 10:49:39 +0100 Subject: [git] GCRYPT - branch, master, updated. libgcrypt-1.6.0-54-gaea96a6 Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The GNU crypto library". The branch, master has been updated via aea96a64fbc58a0b6f9f435e97e93294c6eb1052 (commit) from 121a90d8931944974054f7d94f63b7f89df87fa5 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit aea96a64fbc58a0b6f9f435e97e93294c6eb1052 Author: Werner Koch Date: Wed Jan 29 10:44:36 2014 +0100 Reserve control code for FIPS extensions. * src/gcrypt.h.in (GCRYCTL_INACTIVATE_FIPS_FLAG): New. (GCRYCTL_REACTIVATE_FIPS_FLAG): New. * src/global.c (_gcry_vcontrol): Add them but return not_implemented. diff --git a/src/gcrypt.h.in b/src/gcrypt.h.in index b06f259..c84a3f7 100644 --- a/src/gcrypt.h.in +++ b/src/gcrypt.h.in @@ -327,7 +327,9 @@ enum gcry_ctl_cmds GCRYCTL_DISABLE_LOCKED_SECMEM = 67, GCRYCTL_DISABLE_PRIV_DROP = 68, GCRYCTL_SET_CCM_LENGTHS = 69, - GCRYCTL_CLOSE_RANDOM_DEVICE = 70 + GCRYCTL_CLOSE_RANDOM_DEVICE = 70, + GCRYCTL_INACTIVATE_FIPS_FLAG = 71, + GCRYCTL_REACTIVATE_FIPS_FLAG = 72 }; /* Perform various operations defined by CMD. */ diff --git a/src/global.c b/src/global.c index ec0cc3f..4e8df86 100644 --- a/src/global.c +++ b/src/global.c @@ -666,6 +666,11 @@ _gcry_vcontrol (enum gcry_ctl_cmds cmd, va_list arg_ptr) | GCRY_SECMEM_FLAG_NO_PRIV_DROP)); break; + case GCRYCTL_INACTIVATE_FIPS_FLAG: + case GCRYCTL_REACTIVATE_FIPS_FLAG: + rc = GPG_ERR_NOT_IMPLEMENTED; + break; + default: _gcry_set_preferred_rng_type (0); rc = GPG_ERR_INV_OP; ----------------------------------------------------------------------- Summary of changes: src/gcrypt.h.in | 4 +++- src/global.c | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) hooks/post-receive -- The GNU crypto library http://git.gnupg.org From cvs at cvs.gnupg.org Wed Jan 29 10:50:57 2014 From: cvs at cvs.gnupg.org (by Werner Koch) Date: Wed, 29 Jan 2014 10:50:57 +0100 Subject: [git] GCRYPT - branch, LIBGCRYPT-1-6-BRANCH, updated. libgcrypt-1.6.0-24-gbb558c8 Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The GNU crypto library". The branch, LIBGCRYPT-1-6-BRANCH has been updated via bb558c86a8c1c0fba2e58874a100c121b2fcd033 (commit) via 16d558bd22cd3b3c819ac98135b7812e7ec3f0e5 (commit) via 7259af184e6ca0b8e3fffc264fb5e047f25a08b8 (commit) via f9948609a51fa10e440de19e877b1795534eff90 (commit) from 8ca5966198b4d0d3932978880dc21cb75bf75d56 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit bb558c86a8c1c0fba2e58874a100c121b2fcd033 Author: Werner Koch Date: Wed Jan 29 10:44:36 2014 +0100 Reserve control code for FIPS extensions. * src/gcrypt.h.in (GCRYCTL_INACTIVATE_FIPS_FLAG): New. (GCRYCTL_REACTIVATE_FIPS_FLAG): New. * src/global.c (_gcry_vcontrol): Add them but return not_implemented. (cherry picked from commit aea96a64fbc58a0b6f9f435e97e93294c6eb1052) diff --git a/src/gcrypt.h.in b/src/gcrypt.h.in index 9e94e87..dbf48e3 100644 --- a/src/gcrypt.h.in +++ b/src/gcrypt.h.in @@ -327,7 +327,9 @@ enum gcry_ctl_cmds GCRYCTL_DISABLE_LOCKED_SECMEM = 67, GCRYCTL_DISABLE_PRIV_DROP = 68, GCRYCTL_SET_CCM_LENGTHS = 69, - GCRYCTL_CLOSE_RANDOM_DEVICE = 70 + GCRYCTL_CLOSE_RANDOM_DEVICE = 70, + GCRYCTL_INACTIVATE_FIPS_FLAG = 71, + GCRYCTL_REACTIVATE_FIPS_FLAG = 72 }; /* Perform various operations defined by CMD. */ diff --git a/src/global.c b/src/global.c index 5677bde..6f9cbf9 100644 --- a/src/global.c +++ b/src/global.c @@ -675,6 +675,11 @@ _gcry_vcontrol (enum gcry_ctl_cmds cmd, va_list arg_ptr) | GCRY_SECMEM_FLAG_NO_PRIV_DROP)); break; + case GCRYCTL_INACTIVATE_FIPS_FLAG: + case GCRYCTL_REACTIVATE_FIPS_FLAG: + rc = GPG_ERR_NOT_IMPLEMENTED; + break; + default: _gcry_set_preferred_rng_type (0); rc = GPG_ERR_INV_OP; commit 16d558bd22cd3b3c819ac98135b7812e7ec3f0e5 Author: Werner Koch Date: Wed Jan 29 10:30:19 2014 +0100 Support non weak symbol pthread platforms. * m4/lock.m4, m4/threadlib.m4: New. From libgpg-error master. * m4/Makefile.am (EXTRA_DIST): Add them. * configure.ac (HAVE_PTHREAD): Remove test and ac_define. (gl_LOCK): Do not use under Windows. (LIBGCRYPT_CONFIG_LIBS): Add LIBTHREAD to support non-ELF pthread systems. * src/Makefile.am (dumpsexp_LDADD, mpicalc_LDADD, hmac256_LDADD) (gcryptrnd_LDADD): Add LIBTHREAD. * src/ath.c: Include pthread for any pthread version. (ath_init, ath_install, ath_mutex_init, ath_mutex_destroy) (ath_mutex_lock, ath_mutex_unlock): Support non-weak symbol pthread systems. * tests/Makefile.am (LDADD): Add LIBTHREAD. * tests/t-lock.c: Replace HAVE_PTHREAD by USE_POSIX_THREADS (run_test): Run only under W32 or pthread. -- This has been tested on "AIX power-aix 1 7" using gcc 4.8. Signed-off-by: Werner Koch diff --git a/configure.ac b/configure.ac index e6686a7..cb1a969 100644 --- a/configure.ac +++ b/configure.ac @@ -717,19 +717,27 @@ fi AC_SUBST(PTH_CFLAGS) AC_SUBST(PTH_LIBS) -# -# Check whether pthreads is available -# -AC_CHECK_LIB(pthread,pthread_create,have_pthread=yes) -if test "$have_pthread" = yes; then - AC_DEFINE(HAVE_PTHREAD, 1 ,[Define if we have pthread.]) -fi # # See which thread system we have -# FIXME: Thus duplicates the above check. # -gl_LOCK +# Windows has always thread support; thus we don't bother to test for +# it as it may lead to false results when cross building. +if test "$have_w32_system" = yes; then + AC_DEFINE([USE_WINDOWS_THREADS], [1]) + LIBTHREAD= + LTLIBTHREAD= + LIBMULTITHREAD= + LTLIBMULTITHREAD= + THREADLIB_CPPFLAGS="" + AC_SUBST([LIBTHREAD]) + AC_SUBST([LTLIBTHREAD]) + AC_SUBST([LIBMULTITHREAD]) + AC_SUBST([LTLIBMULTITHREAD]) +else + gl_LOCK +fi + # Solaris needs -lsocket and -lnsl. Unisys system includes # gethostbyname in libsocket but needs libnsl for socket. @@ -1348,6 +1356,13 @@ if test "$use_hmac_binary_check" = yes ; then fi AC_SUBST(DL_LIBS) +# +# Check whether we need to link with a pthreads library. +# +if test "x$LIBTHREAD" != x; then + LIBGCRYPT_CONFIG_LIBS="${LIBGCRYPT_CONFIG_LIBS} ${LIBTHREAD}" +fi + # # Check whether we can use Linux capabilities as requested. diff --git a/m4/Makefile.am b/m4/Makefile.am index 0c90875..0ee9ba7 100644 --- a/m4/Makefile.am +++ b/m4/Makefile.am @@ -1,2 +1,2 @@ EXTRA_DIST = libtool.m4 onceonly.m4 socklen.m4 sys_socket_h.m4 noexecstack.m4 -EXTRA_DIST += gpg-error.m4 +EXTRA_DIST += gpg-error.m4 lock.m4 threadlib.m4 diff --git a/m4/lock.m4 b/m4/lock.m4 new file mode 100644 index 0000000..73a3c54 --- /dev/null +++ b/m4/lock.m4 @@ -0,0 +1,42 @@ +# lock.m4 serial 13 (gettext-0.18.2) +dnl Copyright (C) 2005-2014 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Bruno Haible. + +AC_DEFUN([gl_LOCK], +[ + AC_REQUIRE([gl_THREADLIB]) + if test "$gl_threads_api" = posix; then + # OSF/1 4.0 and Mac OS X 10.1 lack the pthread_rwlock_t type and the + # pthread_rwlock_* functions. + AC_CHECK_TYPE([pthread_rwlock_t], + [AC_DEFINE([HAVE_PTHREAD_RWLOCK], [1], + [Define if the POSIX multithreading library has read/write locks.])], + [], + [#include ]) + # glibc defines PTHREAD_MUTEX_RECURSIVE as enum, not as a macro. + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM( + [[#include ]], + [[ +#if __FreeBSD__ == 4 +error "No, in FreeBSD 4.0 recursive mutexes actually don't work." +#elif (defined __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ \ + && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1070) +error "No, in Mac OS X < 10.7 recursive mutexes actually don't work." +#else +int x = (int)PTHREAD_MUTEX_RECURSIVE; +return !x; +#endif + ]])], + [AC_DEFINE([HAVE_PTHREAD_MUTEX_RECURSIVE], [1], + [Define if the defines PTHREAD_MUTEX_RECURSIVE.])]) + fi + gl_PREREQ_LOCK +]) + +# Prerequisites of lib/glthread/lock.c. +AC_DEFUN([gl_PREREQ_LOCK], [:]) diff --git a/m4/threadlib.m4 b/m4/threadlib.m4 new file mode 100644 index 0000000..b015365 --- /dev/null +++ b/m4/threadlib.m4 @@ -0,0 +1,349 @@ +# threadlib.m4 serial 10 (gettext-0.18.2) modified by wk 2014-01-24. +dnl Copyright (C) 2005-2014 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Bruno Haible. + +dnl gl_THREADLIB +dnl ------------ +dnl Tests for a multithreading library to be used. +dnl If the configure.ac contains a definition of the gl_THREADLIB_DEFAULT_NO +dnl (it must be placed before the invocation of gl_THREADLIB_EARLY!), then the +dnl default is 'no', otherwise it is system dependent. In both cases, the user +dnl can change the choice through the options --enable-threads=choice or +dnl --disable-threads. +dnl Defines at most one of the macros USE_POSIX_THREADS, USE_SOLARIS_THREADS, +dnl USE_WINDOWS_THREADS +dnl Sets the variables LIBTHREAD and LTLIBTHREAD to the linker options for use +dnl in a Makefile (LIBTHREAD for use without libtool, LTLIBTHREAD for use with +dnl libtool). +dnl Sets the variables LIBMULTITHREAD and LTLIBMULTITHREAD similarly, for +dnl programs that really need multithread functionality. The difference +dnl between LIBTHREAD and LIBMULTITHREAD is that on platforms supporting weak +dnl symbols, typically LIBTHREAD="" whereas LIBMULTITHREAD="-lpthread". +dnl Sets THREADLIB_CPPFLAGS to -D_REENTRANT or -D_THREAD_SAFE if needed for +dnl multithread-safe programs and adds THREADLIB_CPPFLAGS to CPPFLAGS. + +AC_DEFUN([gl_THREADLIB_EARLY], +[ + AC_REQUIRE([gl_THREADLIB_EARLY_BODY]) +]) + +dnl The guts of gl_THREADLIB_EARLY. Needs to be expanded only once. + +AC_DEFUN([gl_THREADLIB_EARLY_BODY], +[ + dnl Ordering constraints: This macro modifies CPPFLAGS in a way that + dnl influences the result of the autoconf tests that test for *_unlocked + dnl declarations, on AIX 5 at least. Therefore it must come early. + AC_BEFORE([$0], [gl_FUNC_GLIBC_UNLOCKED_IO])dnl + AC_BEFORE([$0], [gl_ARGP])dnl + + AC_REQUIRE([AC_CANONICAL_HOST]) + dnl _GNU_SOURCE is needed for pthread_rwlock_t on glibc systems. + dnl AC_USE_SYSTEM_EXTENSIONS was introduced in autoconf 2.60 and obsoletes + dnl AC_GNU_SOURCE. + m4_ifdef([AC_USE_SYSTEM_EXTENSIONS], + [AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])], + [AC_REQUIRE([AC_GNU_SOURCE])]) + dnl Check for multithreading. + THREADLIB_CPPFLAGS="" + m4_ifdef([gl_THREADLIB_DEFAULT_NO], + [m4_divert_text([DEFAULTS], [gl_use_threads_default=no])], + [m4_divert_text([DEFAULTS], [gl_use_threads_default=])]) + AC_ARG_ENABLE([threads], +AC_HELP_STRING([--enable-threads={posix|solaris|windows}], [specify multithreading API])m4_ifdef([gl_THREADLIB_DEFAULT_NO], [], [ +AC_HELP_STRING([--disable-threads], [build without multithread safety])]), + [gl_use_threads=$enableval], + [if test -n "$gl_use_threads_default"; then + gl_use_threads="$gl_use_threads_default" + else +changequote(,)dnl + case "$host_os" in + dnl Disable multithreading by default on OSF/1, because it interferes + dnl with fork()/exec(): When msgexec is linked with -lpthread, its + dnl child process gets an endless segmentation fault inside execvp(). + dnl Disable multithreading by default on Cygwin 1.5.x, because it has + dnl bugs that lead to endless loops or crashes. See + dnl . + osf*) gl_use_threads=no ;; + cygwin*) + case `uname -r` in + 1.[0-5].*) gl_use_threads=no ;; + *) gl_use_threads=yes ;; + esac + ;; + *) gl_use_threads=yes ;; + esac +changequote([,])dnl + fi + ]) + if test "$gl_use_threads" = yes || test "$gl_use_threads" = posix; then + # For using : + case "$host_os" in + osf*) + # On OSF/1, the compiler needs the flag -D_REENTRANT so that it + # groks . cc also understands the flag -pthread, but + # we don't use it because 1. gcc-2.95 doesn't understand -pthread, + # 2. putting a flag into CPPFLAGS that has an effect on the linker + # causes the AC_LINK_IFELSE test below to succeed unexpectedly, + # leading to wrong values of LIBTHREAD and LTLIBTHREAD. + THREADLIB_CPPFLAGS="$THREADLIB_CPPFLAGS -D_REENTRANT" + ;; + esac + # Some systems optimize for single-threaded programs by default, and + # need special flags to disable these optimizations. For example, the + # definition of 'errno' in . + case "$host_os" in + aix* | freebsd*) + THREADLIB_CPPFLAGS="$THREADLIB_CPPFLAGS -D_THREAD_SAFE" + ;; + solaris*) + THREADLIB_CPPFLAGS="$THREADLIB_CPPFLAGS -D_REENTRANT" + ;; + esac + fi + if test x"$THREADLIB_CPPFLAGS" != x ; then + CPPFLAGS="$CPPFLAGS $THREADLIB_CPPFLAGS" + fi +]) + +dnl The guts of gl_THREADLIB. Needs to be expanded only once. + +AC_DEFUN([gl_THREADLIB_BODY], +[ + AC_REQUIRE([gl_THREADLIB_EARLY_BODY]) + gl_threads_api=none + LIBTHREAD= + LTLIBTHREAD= + LIBMULTITHREAD= + LTLIBMULTITHREAD= + if test "$gl_use_threads" != no; then + dnl Check whether the compiler and linker support weak declarations. + AC_CACHE_CHECK([whether imported symbols can be declared weak], + [gl_cv_have_weak], + [gl_cv_have_weak=no + dnl First, test whether the compiler accepts it syntactically. + AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[extern void xyzzy (); +#pragma weak xyzzy]], + [[xyzzy();]])], + [gl_cv_have_weak=maybe]) + if test $gl_cv_have_weak = maybe; then + dnl Second, test whether it actually works. On Cygwin 1.7.2, with + dnl gcc 4.3, symbols declared weak always evaluate to the address 0. + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#pragma weak fputs +int main () +{ + return (fputs == NULL); +}]])], + [gl_cv_have_weak=yes], + [gl_cv_have_weak=no], + [dnl When cross-compiling, assume that only ELF platforms support + dnl weak symbols. + AC_EGREP_CPP([Extensible Linking Format], + [#ifdef __ELF__ + Extensible Linking Format + #endif + ], + [gl_cv_have_weak="guessing yes"], + [gl_cv_have_weak="guessing no"]) + ]) + fi + ]) + if test "$gl_use_threads" = yes || test "$gl_use_threads" = posix; then + # On OSF/1, the compiler needs the flag -pthread or -D_REENTRANT so that + # it groks . It's added above, in gl_THREADLIB_EARLY_BODY. + AC_CHECK_HEADER([pthread.h], + [gl_have_pthread_h=yes], [gl_have_pthread_h=no]) + if test "$gl_have_pthread_h" = yes; then + # Other possible tests: + # -lpthreads (FSU threads, PCthreads) + # -lgthreads + gl_have_pthread= + # Test whether both pthread_mutex_lock and pthread_mutexattr_init exist + # in libc. IRIX 6.5 has the first one in both libc and libpthread, but + # the second one only in libpthread, and lock.c needs it. + AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[#include ]], + [[pthread_mutex_lock((pthread_mutex_t*)0); + pthread_mutexattr_init((pthread_mutexattr_t*)0);]])], + [gl_have_pthread=yes]) + # Test for libpthread by looking for pthread_kill. (Not pthread_self, + # since it is defined as a macro on OSF/1.) + if test -n "$gl_have_pthread"; then + # The program links fine without libpthread. But it may actually + # need to link with libpthread in order to create multiple threads. + AC_CHECK_LIB([pthread], [pthread_kill], + [LIBMULTITHREAD=-lpthread LTLIBMULTITHREAD=-lpthread + # On Solaris and HP-UX, most pthread functions exist also in libc. + # Therefore pthread_in_use() needs to actually try to create a + # thread: pthread_create from libc will fail, whereas + # pthread_create will actually create a thread. + case "$host_os" in + solaris* | hpux*) + AC_DEFINE([PTHREAD_IN_USE_DETECTION_HARD], [1], + [Define if the pthread_in_use() detection is hard.]) + esac + ]) + else + # Some library is needed. Try libpthread and libc_r. + AC_CHECK_LIB([pthread], [pthread_kill], + [gl_have_pthread=yes + LIBTHREAD=-lpthread LTLIBTHREAD=-lpthread + LIBMULTITHREAD=-lpthread LTLIBMULTITHREAD=-lpthread]) + if test -z "$gl_have_pthread"; then + # For FreeBSD 4. + AC_CHECK_LIB([c_r], [pthread_kill], + [gl_have_pthread=yes + LIBTHREAD=-lc_r LTLIBTHREAD=-lc_r + LIBMULTITHREAD=-lc_r LTLIBMULTITHREAD=-lc_r]) + fi + fi + if test -n "$gl_have_pthread"; then + gl_threads_api=posix + AC_DEFINE([USE_POSIX_THREADS], [1], + [Define if the POSIX multithreading library can be used.]) + if test -n "$LIBMULTITHREAD" || test -n "$LTLIBMULTITHREAD"; then + if case "$gl_cv_have_weak" in *yes) true;; *) false;; esac; then + AC_DEFINE([USE_POSIX_THREADS_WEAK], [1], + [Define if references to the POSIX multithreading library should be made weak.]) + LIBTHREAD= + LTLIBTHREAD= + fi + fi + fi + fi + fi + if test -z "$gl_have_pthread"; then + if test "$gl_use_threads" = yes || test "$gl_use_threads" = solaris; then + gl_have_solaristhread= + gl_save_LIBS="$LIBS" + LIBS="$LIBS -lthread" + AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[ +#include +#include + ]], + [[thr_self();]])], + [gl_have_solaristhread=yes]) + LIBS="$gl_save_LIBS" + if test -n "$gl_have_solaristhread"; then + gl_threads_api=solaris + LIBTHREAD=-lthread + LTLIBTHREAD=-lthread + LIBMULTITHREAD="$LIBTHREAD" + LTLIBMULTITHREAD="$LTLIBTHREAD" + AC_DEFINE([USE_SOLARIS_THREADS], [1], + [Define if the old Solaris multithreading library can be used.]) + if case "$gl_cv_have_weak" in *yes) true;; *) false;; esac; then + AC_DEFINE([USE_SOLARIS_THREADS_WEAK], [1], + [Define if references to the old Solaris multithreading library should be made weak.]) + LIBTHREAD= + LTLIBTHREAD= + fi + fi + fi + fi + if test -z "$gl_have_pthread"; then + case "$gl_use_threads" in + yes | windows | win32) # The 'win32' is for backward compatibility. + if { case "$host_os" in + mingw*) true;; + *) false;; + esac + }; then + gl_threads_api=windows + AC_DEFINE([USE_WINDOWS_THREADS], [1], + [Define if the native Windows multithreading API can be used.]) + fi + ;; + esac + fi + fi + AC_MSG_CHECKING([for multithread API to use]) + AC_MSG_RESULT([$gl_threads_api]) + AC_SUBST([LIBTHREAD]) + AC_SUBST([LTLIBTHREAD]) + AC_SUBST([LIBMULTITHREAD]) + AC_SUBST([LTLIBMULTITHREAD]) +]) + +AC_DEFUN([gl_THREADLIB], +[ + AC_REQUIRE([gl_THREADLIB_EARLY]) + AC_REQUIRE([gl_THREADLIB_BODY]) +]) + + +dnl gl_DISABLE_THREADS +dnl ------------------ +dnl Sets the gl_THREADLIB default so that threads are not used by default. +dnl The user can still override it at installation time, by using the +dnl configure option '--enable-threads'. + +AC_DEFUN([gl_DISABLE_THREADS], [ + m4_divert_text([INIT_PREPARE], [gl_use_threads_default=no]) +]) + + +dnl Survey of platforms: +dnl +dnl Platform Available Compiler Supports test-lock +dnl flavours option weak result +dnl --------------- --------- --------- -------- --------- +dnl Linux 2.4/glibc posix -lpthread Y OK +dnl +dnl GNU Hurd/glibc posix +dnl +dnl FreeBSD 5.3 posix -lc_r Y +dnl posix -lkse ? Y +dnl posix -lpthread ? Y +dnl posix -lthr Y +dnl +dnl FreeBSD 5.2 posix -lc_r Y +dnl posix -lkse Y +dnl posix -lthr Y +dnl +dnl FreeBSD 4.0,4.10 posix -lc_r Y OK +dnl +dnl NetBSD 1.6 -- +dnl +dnl OpenBSD 3.4 posix -lpthread Y OK +dnl +dnl Mac OS X 10.[123] posix -lpthread Y OK +dnl +dnl Solaris 7,8,9 posix -lpthread Y Sol 7,8: 0.0; Sol 9: OK +dnl solaris -lthread Y Sol 7,8: 0.0; Sol 9: OK +dnl +dnl HP-UX 11 posix -lpthread N (cc) OK +dnl Y (gcc) +dnl +dnl IRIX 6.5 posix -lpthread Y 0.5 +dnl +dnl AIX 4.3,5.1 posix -lpthread N AIX 4: 0.5; AIX 5: OK +dnl +dnl OSF/1 4.0,5.1 posix -pthread (cc) N OK +dnl -lpthread (gcc) Y +dnl +dnl Cygwin posix -lpthread Y OK +dnl +dnl Any of the above pth -lpth 0.0 +dnl +dnl Mingw windows N OK +dnl +dnl BeOS 5 -- +dnl +dnl The test-lock result shows what happens if in test-lock.c EXPLICIT_YIELD is +dnl turned off: +dnl OK if all three tests terminate OK, +dnl 0.5 if the first test terminates OK but the second one loops endlessly, +dnl 0.0 if the first test already loops endlessly. diff --git a/src/Makefile.am b/src/Makefile.am index c020239..2d4800f 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -126,20 +126,20 @@ libgcrypt_la_LIBADD = $(gcrypt_res) \ dumpsexp_SOURCES = dumpsexp.c dumpsexp_CFLAGS = $(arch_gpg_error_cflags) -dumpsexp_LDADD = $(arch_gpg_error_libs) +dumpsexp_LDADD = $(arch_gpg_error_libs) $(LIBTHREAD) mpicalc_SOURCES = mpicalc.c mpicalc_CFLAGS = $(GPG_ERROR_CFLAGS) -mpicalc_LDADD = libgcrypt.la $(GPG_ERROR_LIBS) +mpicalc_LDADD = libgcrypt.la $(GPG_ERROR_LIBS) $(LIBTHREAD) hmac256_SOURCES = hmac256.c hmac256_CFLAGS = -DSTANDALONE $(arch_gpg_error_cflags) -hmac256_LDADD = $(arch_gpg_error_libs) +hmac256_LDADD = $(arch_gpg_error_libs) $(LIBTHREAD) if USE_RANDOM_DAEMON gcryptrnd_SOURCES = gcryptrnd.c gcryptrnd_CFLAGS = $(GPG_ERROR_CFLAGS) $(PTH_CFLAGS) -gcryptrnd_LDADD = libgcrypt.la $(GPG_ERROR_LIBS) $(PTH_LIBS) +gcryptrnd_LDADD = libgcrypt.la $(GPG_ERROR_LIBS) $(PTH_LIBS) $(LIBTHREAD) getrandom_SOURCES = getrandom.c endif USE_RANDOM_DAEMON diff --git a/src/ath.c b/src/ath.c index ca40de5..9085d3e 100644 --- a/src/ath.c +++ b/src/ath.c @@ -26,12 +26,17 @@ #include #include #include -#if USE_POSIX_THREADS_WEAK +#if USE_POSIX_THREADS # include #endif #include "ath.h" +#if USE_POSIX_THREADS_WEAK +# if !USE_POSIX_THREADS +# error USE_POSIX_THREADS_WEAK but no USE_POSIX_THREADS +# endif +#endif /* On an ELF system it is easy to use pthreads using weak references. @@ -101,10 +106,12 @@ ath_init (void) { #if HAVE_W32_SYSTEM thread_model = ath_model_w32; -#else /*!HAVE_W32_SYSTEM*/ +#elif USE_POSIX_THREADS && !USE_POSIX_THREADS_WEAK + thread_model = ath_model_pthreads; +#else /*!USE_POSIX_THREADS*/ /* Assume a single threaded application. */ thread_model = ath_model_none; -#endif /*!HAVE_W32_SYSTEM*/ +#endif /*!USE_POSIX_THREADS*/ } return err; @@ -155,15 +162,16 @@ ath_install (struct ath_ops *ath_ops) configured one. */ if (0) ; -#if USE_POSIX_THREADS_WEAK - else if (thread_model == ath_model_pthreads_weak) +#if USE_POSIX_THREADS + else if (thread_model == ath_model_pthreads + || thread_model == ath_model_pthreads_weak) { if (thread_option == ATH_THREAD_OPTION_PTHREAD) return 0; /* Okay - compatible. */ if (thread_option == ATH_THREAD_OPTION_PTH) return 0; /* Okay - compatible. */ } -#endif /*USE_POSIX_THREADS_WEAK*/ +#endif /*USE_POSIX_THREADS*/ else if (thread_option == ATH_THREAD_OPTION_PTH) { if (thread_model == ath_model_none) @@ -195,7 +203,8 @@ ath_mutex_init (ath_mutex_t *lock) err = 0; break; -#if USE_POSIX_THREADS_WEAK +#if USE_POSIX_THREADS + case ath_model_pthreads: case ath_model_pthreads_weak: { pthread_mutex_t *plck; @@ -213,7 +222,7 @@ ath_mutex_init (ath_mutex_t *lock) } } break; -#endif /*USE_POSIX_THREADS_WEAK*/ +#endif /*USE_POSIX_THREADS*/ #if HAVE_W32_SYSTEM case ath_model_w32: @@ -265,7 +274,8 @@ ath_mutex_destroy (ath_mutex_t *lock) } break; -#if USE_POSIX_THREADS_WEAK +#if USE_POSIX_THREADS + case ath_model_pthreads: case ath_model_pthreads_weak: { pthread_mutex_t *plck = (pthread_mutex_t*) (*lock); @@ -278,7 +288,7 @@ ath_mutex_destroy (ath_mutex_t *lock) } } break; -#endif /*USE_POSIX_THREADS_WEAK*/ +#endif /*USE_POSIX_THREADS*/ #if HAVE_W32_SYSTEM case ath_model_w32: @@ -322,11 +332,12 @@ ath_mutex_lock (ath_mutex_t *lock) err = EDEADLK; break; -#if USE_POSIX_THREADS_WEAK +#if USE_POSIX_THREADS + case ath_model_pthreads: case ath_model_pthreads_weak: err = pthread_mutex_lock ((pthread_mutex_t*)(*lock)); break; -#endif /*USE_POSIX_THREADS_WEAK*/ +#endif /*USE_POSIX_THREADS*/ #if HAVE_W32_SYSTEM case ath_model_w32: @@ -368,11 +379,12 @@ ath_mutex_unlock (ath_mutex_t *lock) err = EPERM; break; -#if USE_POSIX_THREADS_WEAK +#if USE_POSIX_THREADS + case ath_model_pthreads: case ath_model_pthreads_weak: err = pthread_mutex_unlock ((pthread_mutex_t*)(*lock)); break; -#endif /*USE_POSIX_THREADS_WEAK*/ +#endif /*USE_POSIX_THREADS*/ #if HAVE_W32_SYSTEM case ath_model_w32: diff --git a/tests/Makefile.am b/tests/Makefile.am index 6cde99f..9645471 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -58,5 +58,5 @@ EXTRA_DIST = README rsa-16k.key cavs_tests.sh cavs_driver.pl \ pkcs1v2-oaep.h pkcs1v2-pss.h pkcs1v2-v15c.h pkcs1v2-v15s.h \ t-ed25519.inp stopwatch.h hashtest-256g.in -LDADD = $(default_ldadd) +LDADD = $(default_ldadd) $(LIBTHREAD) t_lock_LDADD = $(default_ldadd) $(LIBMULTITHREAD) diff --git a/tests/t-lock.c b/tests/t-lock.c index cae5748..e370f3e 100644 --- a/tests/t-lock.c +++ b/tests/t-lock.c @@ -27,7 +27,7 @@ #include #include #include -#if HAVE_PTHREAD +#if USE_POSIX_THREADS # include #endif @@ -193,7 +193,7 @@ check_nonce_lock (void) CloseHandle (threads[i]); } -#elif HAVE_PTHREAD +#elif USE_POSIX_THREADS pthread_t threads[N_NONCE_THREADS]; int rc, i; @@ -360,7 +360,7 @@ run_test (void) fail ("waiting for revision thread failed: %d", (int)GetLastError ()); CloseHandle (rthread); -#else /*!_WIN32*/ +#elif USE_POSIX_THREADS pthread_t rthread; pthread_t athreads[N_ACCOUNTANTS]; int rc, i; @@ -389,7 +389,7 @@ run_test (void) else show ("revision thread has terminated"); -#endif /*!_WIN32*/ +#endif /*USE_POSIX_THREADS*/ external_lock_test_destroy (__LINE__); } commit 7259af184e6ca0b8e3fffc264fb5e047f25a08b8 Author: Werner Koch Date: Wed Jan 29 09:43:00 2014 +0100 tests: Remove non-portable format specifiers. * tests/basic.c: Replace "%zi" by "%d" and casts. diff --git a/tests/basic.c b/tests/basic.c index bebfa67..86be89d 100644 --- a/tests/basic.c +++ b/tests/basic.c @@ -4067,11 +4067,11 @@ check_digests (void) continue; } if (verbose) - fprintf (stderr, " checking %s [%i] for length %zi\n", + fprintf (stderr, " checking %s [%i] for length %d\n", gcry_md_algo_name (algos[i].md), algos[i].md, !strcmp (algos[i].data, "!")? - 1000000 : strlen(algos[i].data)); + 1000000 : (int)strlen(algos[i].data)); check_one_md (algos[i].md, algos[i].data, strlen (algos[i].data), algos[i].expect); @@ -4492,10 +4492,10 @@ check_hmac (void) } if (verbose) fprintf (stderr, - " checking %s [%i] for %zi byte key and %zi byte data\n", + " checking %s [%i] for %d byte key and %d byte data\n", gcry_md_algo_name (algos[i].md), algos[i].md, - strlen(algos[i].key), strlen(algos[i].data)); + (int)strlen(algos[i].key), (int)strlen(algos[i].data)); check_one_hmac (algos[i].md, algos[i].data, strlen (algos[i].data), algos[i].key, strlen(algos[i].key), @@ -5089,10 +5089,10 @@ check_mac (void) } if (verbose) fprintf (stderr, - " checking %s [%i] for %zi byte key and %zi byte data\n", + " checking %s [%i] for %d byte key and %d byte data\n", gcry_mac_algo_name (algos[i].algo), algos[i].algo, - strlen(algos[i].key), strlen(algos[i].data)); + (int)strlen(algos[i].key), (int)strlen(algos[i].data)); check_one_mac (algos[i].algo, algos[i].data, strlen (algos[i].data), algos[i].key, strlen(algos[i].key), algos[i].iv, commit f9948609a51fa10e440de19e877b1795534eff90 Author: NIIBE Yutaka Date: Wed Jan 29 08:32:46 2014 +0900 Fix RSA Blinding. * cipher/rsa.c (rsa_decrypt): Loop to get multiplicative inverse. Signed-off-by: NIIBE Yutaka (cherry picked from commit 121a90d8931944974054f7d94f63b7f89df87fa5) diff --git a/cipher/rsa.c b/cipher/rsa.c index e595e38..9a8d235 100644 --- a/cipher/rsa.c +++ b/cipher/rsa.c @@ -1023,13 +1023,12 @@ rsa_decrypt (gcry_sexp_t *r_plain, gcry_sexp_t s_data, gcry_sexp_t keyparms) ri = mpi_snew (ctx.nbits); bldata = mpi_snew (ctx.nbits); - _gcry_mpi_randomize (r, ctx.nbits, GCRY_WEAK_RANDOM); - mpi_mod (r, r, sk.n); - if (!mpi_invm (ri, r, sk.n)) + do { - rc = GPG_ERR_INTERNAL; - goto leave; + _gcry_mpi_randomize (r, ctx.nbits, GCRY_WEAK_RANDOM); + mpi_mod (r, r, sk.n); } + while (!mpi_invm (ri, r, sk.n)); /* Do blinding. We calculate: y = (x * r^e) mod n, where r is the random number, e is the public exponent, x is the ----------------------------------------------------------------------- Summary of changes: cipher/rsa.c | 9 +- configure.ac | 33 +++-- m4/Makefile.am | 2 +- m4/lock.m4 | 42 +++++++ m4/threadlib.m4 | 349 +++++++++++++++++++++++++++++++++++++++++++++++++++++ src/Makefile.am | 8 +- src/ath.c | 40 +++--- src/gcrypt.h.in | 4 +- src/global.c | 5 + tests/Makefile.am | 2 +- tests/basic.c | 12 +- tests/t-lock.c | 8 +- 12 files changed, 469 insertions(+), 45 deletions(-) create mode 100644 m4/lock.m4 create mode 100644 m4/threadlib.m4 hooks/post-receive -- The GNU crypto library http://git.gnupg.org From cvs at cvs.gnupg.org Wed Jan 29 12:05:52 2014 From: cvs at cvs.gnupg.org (by Werner Koch) Date: Wed, 29 Jan 2014 12:05:52 +0100 Subject: [git] GCRYPT - branch, LIBGCRYPT-1-6-BRANCH, updated. libgcrypt-1.6.0-26-g0a40d8c Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The GNU crypto library". The branch, LIBGCRYPT-1-6-BRANCH has been updated via 0a40d8c0ebf5c945d87551c76b0df0129ac8e6fc (commit) via 8804b9ae40e8dd81ee46e18581da79cef7a4eaea (commit) from bb558c86a8c1c0fba2e58874a100c121b2fcd033 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 0a40d8c0ebf5c945d87551c76b0df0129ac8e6fc Author: Werner Koch Date: Wed Jan 29 12:04:30 2014 +0100 Post release updates. -- diff --git a/NEWS b/NEWS index 074e9f2..ee4e842 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,7 @@ +Noteworthy changes in version 1.6.2 (unreleased) +------------------------------------------------ + + Noteworthy changes in version 1.6.1 (2014-01-29) ------------------------------------------------ diff --git a/configure.ac b/configure.ac index dfbccb7..0b29c6d 100644 --- a/configure.ac +++ b/configure.ac @@ -30,7 +30,7 @@ min_automake_version="1.10" # for the LT versions. m4_define(mym4_version_major, [1]) m4_define(mym4_version_minor, [6]) -m4_define(mym4_version_micro, [1]) +m4_define(mym4_version_micro, [2]) # Below is m4 magic to extract and compute the revision number, the # decimalized short revision number, a beta version string, and a flag commit 8804b9ae40e8dd81ee46e18581da79cef7a4eaea Author: Werner Koch Date: Wed Jan 29 11:33:33 2014 +0100 Release 1.6.1. * configure.ac: Set LT version to C20/A0/R1. diff --git a/AUTHORS b/AUTHORS index dc933dc..7c3c671 100644 --- a/AUTHORS +++ b/AUTHORS @@ -26,12 +26,12 @@ List of Copyright holders Copyright (C) 1996-2006 Peter Gutmann, Matt Thomlinson and Blake Coverett Copyright (C) 2003 Nikos Mavroyanopoulos Copyright (C) 2006-2007 NTT (Nippon Telegraph and Telephone Corporation) - Copyright (C) 2012-2013 g10 Code GmbH + Copyright (C) 2012-2014 g10 Code GmbH Copyright (C) 2012 Simon Josefsson, Niels M?ller Copyright (c) 2012 Intel Corporation Copyright (C) 2013 Christian Grothoff - Copyright (C) 2013 Jussi Kivilinna - Copyright (C) 2013 Dmitry Eremin-Solenikov + Copyright (C) 2013-2014 Jussi Kivilinna + Copyright (C) 2013-2014 Dmitry Eremin-Solenikov Authors with a FSF copyright assignment diff --git a/NEWS b/NEWS index 9c3df10..074e9f2 100644 --- a/NEWS +++ b/NEWS @@ -1,16 +1,26 @@ -Noteworthy changes in version 1.6.1 (unreleased) +Noteworthy changes in version 1.6.1 (2014-01-29) ------------------------------------------------ - * Fix a 1.6.0 introduced regression in looking up an message digest - by OID. + * Added emulation for broken Whirlpool code prior to 1.6.0. - * Fix build problem on NetBSD. + * Improved performance of KDF functions. - * Add emulation for broken Whirlpool code prior to 1.6.0. + * Improved ECDSA compliance. + + * Fixed locking for Windows and non-ELF Pthread systems (regression + in 1.6.0) + + * Fixed message digest lookup by OID (regression in 1.6.0). + + * Fixed a build problem on NetBSD. + + * Fixed memory leaks in ECC code. + + * Fixed some asm build problems and feature detection bugs. * Interface changes relative to the 1.6.0 release: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - GCRY_MD_FLAG_BUGEMU1 NEW. + GCRY_MD_FLAG_BUGEMU1 NEW (minor API change). Noteworthy changes in version 1.6.0 (2013-12-16) diff --git a/README b/README index 43f9094..25ed18a 100644 --- a/README +++ b/README @@ -3,8 +3,8 @@ Version 1.6 Copyright (C) 1989,1991-2012 Free Software Foundation, Inc. - Copyright (C) 2012-2013 g10 Code GmbH - Copyright (C) 2013 Jussi Kivilinna + Copyright (C) 2012-2014 g10 Code GmbH + Copyright (C) 2013-2014 Jussi Kivilinna Libgcrypt is free software. See the file AUTHORS for full copying notices, and LICENSES for notices about contributions that require diff --git a/compat/compat.c b/compat/compat.c index 5678067..f59a41c 100644 --- a/compat/compat.c +++ b/compat/compat.c @@ -31,8 +31,9 @@ _gcry_compat_identification (void) "\n\n" "This is Libgcrypt " PACKAGE_VERSION " - The GNU Crypto Library\n" "Copyright (C) 2000-2012 Free Software Foundation, Inc.\n" - "Copyright (C) 2012-2013 g10 Code GmbH\n" - "Copyright (C) 2013 Jussi Kivilinna\n" + "Copyright (C) 2012-2014 g10 Code GmbH\n" + "Copyright (C) 2013-2014 Jussi Kivilinna\n" + "(See the source code for a complete list)\n" "\n" "(" BUILD_REVISION " " BUILD_TIMESTAMP ")\n" "\n\n"; diff --git a/configure.ac b/configure.ac index cb1a969..dfbccb7 100644 --- a/configure.ac +++ b/configure.ac @@ -56,7 +56,7 @@ AC_INIT([libgcrypt],[mym4_full_version],[http://bugs.gnupg.org]) # (No interfaces changed: REVISION++) LIBGCRYPT_LT_CURRENT=20 LIBGCRYPT_LT_AGE=0 -LIBGCRYPT_LT_REVISION=0 +LIBGCRYPT_LT_REVISION=1 # If the API is changed in an incompatible way: increment the next counter. ----------------------------------------------------------------------- Summary of changes: AUTHORS | 6 +++--- NEWS | 26 ++++++++++++++++++++------ README | 4 ++-- compat/compat.c | 5 +++-- configure.ac | 4 ++-- 5 files changed, 30 insertions(+), 15 deletions(-) hooks/post-receive -- The GNU crypto library http://git.gnupg.org From cvs at cvs.gnupg.org Wed Jan 29 15:19:11 2014 From: cvs at cvs.gnupg.org (by Werner Koch) Date: Wed, 29 Jan 2014 15:19:11 +0100 Subject: [git] GCRYPT - branch, master, updated. libgcrypt-1.6.0-55-g6e83552 Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The GNU crypto library". The branch, master has been updated via 6e83552dde83a8b4f639071551a20e33a9d46eb9 (commit) from aea96a64fbc58a0b6f9f435e97e93294c6eb1052 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 6e83552dde83a8b4f639071551a20e33a9d46eb9 Author: Werner Koch Date: Wed Jan 29 15:17:37 2014 +0100 Update NEWS to be aligned with 1.6.1. -- diff --git a/NEWS b/NEWS index 5e21eb6..e1bb772 100644 --- a/NEWS +++ b/NEWS @@ -1,14 +1,25 @@ Noteworthy changes in version 1.7.0 (unreleased) ------------------------------------------------ - * Fix a 1.6.0 introduced regression in looking up an message digest - by OID. + * Added emulation for broken Whirlpool code prior to 1.6.0. - * Support curve sec256k1. + * Added support for curve sec256k1. - * Support curves GOST R 34.10-2001 and GOST R 34.10-2012. + * Added support for curves GOST R 34.10-2001 and GOST R 34.10-2012. - * Add emulation from broken Whirlpool code prior to 1.6.0. + * Improved performance of KDF functions. + + * Improved ECDSA compliance. + + * Moved locking out to libgpg-error. + + * Fixed message digest lookup by OID (regression in 1.6.0). + + * Fixed a build problem on NetBSD. + + * Fixed memory leaks in ECC code. + + * Fixed some asm build problems and feature detection bugs. * Interface changes relative to the 1.6.0 release: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ----------------------------------------------------------------------- Summary of changes: NEWS | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) hooks/post-receive -- The GNU crypto library http://git.gnupg.org From cvs at cvs.gnupg.org Wed Jan 29 16:33:43 2014 From: cvs at cvs.gnupg.org (by Werner Koch) Date: Wed, 29 Jan 2014 16:33:43 +0100 Subject: [git] GCRYPT - branch, LIBGCRYPT-1-6-BRANCH, updated. libgcrypt-1.6.1-2-g3216da3 Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The GNU crypto library". The branch, LIBGCRYPT-1-6-BRANCH has been updated via 3216da3ddbc3eeb49171ab179acd9d75ca4d0218 (commit) from 0a40d8c0ebf5c945d87551c76b0df0129ac8e6fc (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 3216da3ddbc3eeb49171ab179acd9d75ca4d0218 Author: Werner Koch Date: Tue Jan 28 17:00:27 2014 +0100 cipher: Take care of ENABLE_NEON_SUPPORT. * cipher/salsa20.c (USE_ARM_NEON_ASM): Define only if ENABLE_NEON_SUPPORT is defined. * cipher/serpent.c (USE_NEON): Ditto. * cipher/sha512.c (USE_ARM_NEON_ASM): Ditto. -- The generic C source files must only include NEON support if that is enabled. The dedicated ASM files are conditionally compiled and thus do not need to use it. GnuPG-bug-id: 1603 Signed-off-by: Werner Koch (cherry picked from commit 52f7c48c901a3de51bd690a218f3de2f71e8d790) Resolved conflicts: * cipher/sha1.c: Remove changes - no asm support in 1.6. diff --git a/cipher/salsa20.c b/cipher/salsa20.c index 72b28b0..d75fe51 100644 --- a/cipher/salsa20.c +++ b/cipher/salsa20.c @@ -49,12 +49,13 @@ /* USE_ARM_NEON_ASM indicates whether to enable ARM NEON assembly code. */ #undef USE_ARM_NEON_ASM -#if defined(HAVE_ARM_ARCH_V6) && defined(__ARMEL__) -# if defined(HAVE_COMPATIBLE_GCC_ARM_PLATFORM_AS) && \ - defined(HAVE_GCC_INLINE_ASM_NEON) +#ifdef ENABLE_NEON_SUPPORT +# if defined(HAVE_ARM_ARCH_V6) && defined(__ARMEL__) \ + && defined(HAVE_COMPATIBLE_GCC_ARM_PLATFORM_AS) \ + && defined(HAVE_GCC_INLINE_ASM_NEON) # define USE_ARM_NEON_ASM 1 # endif -#endif +#endif /*ENABLE_NEON_SUPPORT*/ #define SALSA20_MIN_KEY_SIZE 16 /* Bytes. */ diff --git a/cipher/serpent.c b/cipher/serpent.c index 8e647d4..0be49da 100644 --- a/cipher/serpent.c +++ b/cipher/serpent.c @@ -48,13 +48,13 @@ /* USE_NEON indicates whether to enable ARM NEON assembly code. */ #undef USE_NEON -#if defined(HAVE_ARM_ARCH_V6) && defined(__ARMEL__) -# if defined(HAVE_COMPATIBLE_GCC_ARM_PLATFORM_AS) && \ - defined(HAVE_GCC_INLINE_ASM_NEON) +#ifdef ENABLE_NEON_SUPPORT +# if defined(HAVE_ARM_ARCH_V6) && defined(__ARMEL__) \ + && defined(HAVE_COMPATIBLE_GCC_ARM_PLATFORM_AS) \ + && defined(HAVE_GCC_INLINE_ASM_NEON) # define USE_NEON 1 # endif -#endif - +#endif /*ENABLE_NEON_SUPPORT*/ /* Number of rounds per Serpent encrypt/decrypt operation. */ #define ROUNDS 32 diff --git a/cipher/sha512.c b/cipher/sha512.c index 26ed031..6f729cc 100644 --- a/cipher/sha512.c +++ b/cipher/sha512.c @@ -57,12 +57,13 @@ /* USE_ARM_NEON_ASM indicates whether to enable ARM NEON assembly code. */ #undef USE_ARM_NEON_ASM -#if defined(HAVE_ARM_ARCH_V6) && defined(__ARMEL__) -# if defined(HAVE_COMPATIBLE_GCC_ARM_PLATFORM_AS) && \ - defined(HAVE_GCC_INLINE_ASM_NEON) +#ifdef ENABLE_NEON_SUPPORT +# if defined(HAVE_ARM_ARCH_V6) && defined(__ARMEL__) \ + && defined(HAVE_COMPATIBLE_GCC_ARM_PLATFORM_AS) \ + && defined(HAVE_GCC_INLINE_ASM_NEON) # define USE_ARM_NEON_ASM 1 # endif -#endif +#endif /*ENABLE_NEON_SUPPORT*/ /* USE_SSSE3 indicates whether to compile with Intel SSSE3 code. */ ----------------------------------------------------------------------- Summary of changes: cipher/salsa20.c | 9 +++++---- cipher/serpent.c | 10 +++++----- cipher/sha512.c | 9 +++++---- 3 files changed, 15 insertions(+), 13 deletions(-) hooks/post-receive -- The GNU crypto library http://git.gnupg.org From cvs at cvs.gnupg.org Wed Jan 29 17:51:20 2014 From: cvs at cvs.gnupg.org (by Werner Koch) Date: Wed, 29 Jan 2014 17:51:20 +0100 Subject: [git] GnuPG - branch, master, updated. gnupg-2.1.0beta3-291-g25b4c2a Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The GNU Privacy Guard". The branch, master has been updated via 25b4c2acbd01f9b4c2c364f44c53b73498ed8469 (commit) via 47bb0d7683b0c03a106bf4fbc02e8d813d268a8a (commit) via 362a30d8c2f529cd44687066f9c33cab7b43bedc (commit) from 0ee66a6f66d7389e381fffa5f9eedbc8de9add10 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 25b4c2acbd01f9b4c2c364f44c53b73498ed8469 Author: Werner Koch Date: Wed Jan 29 17:39:22 2014 +0100 include: Remove this directory. * include/cipher.h: Move to ... * g10/cipher.h: here. * agent/gpg-agent.c: Adjust header file name. * include/host2net.h: Move to ... * common/host2net.h: here. Change license to LGPLv3/GPLv2. Adjust notices to reflect that only me worked on that file. * include/types.h: Remove. * common/types.h: Include inttypes.h. Add byte typedef and comments for __riscos__. * common/iobuf.h: Adjust header file name. * include/_regex.h: Remove this unused file. * include/Makefile.am: Remove. * Makefile.am (SUBDIRS): Remove "include". * configure.ac (AC_CONFIG_FILES): Remove include/Makefile. * include/ChangeLog-2011: Move to ... * common/ChangeLog-2011.include: here. * common/Makefile.am (EXTRA_DIST): Add file. * include/zlib-riscos.h: Move this repo only file to ... * g10/zlib-riscos.h: here. * include/: Remove. -- include/ was a leftover from GnuPG 1.x times. Signed-off-by: Werner Koch diff --git a/Makefile.am b/Makefile.am index cf84134..3b79226 100644 --- a/Makefile.am +++ b/Makefile.am @@ -89,7 +89,7 @@ else tests = endif -SUBDIRS = m4 gl include common ${kbx} \ +SUBDIRS = m4 gl common ${kbx} \ ${gpg} ${keyserver} ${sm} ${agent} ${scd} ${g13} ${dirmngr} \ ${tools} po ${doc} ${tests} diff --git a/agent/gpg-agent.c b/agent/gpg-agent.c index 1e60717..9810983 100644 --- a/agent/gpg-agent.c +++ b/agent/gpg-agent.c @@ -51,7 +51,7 @@ #include "gc-opt-flags.h" #include "exechelp.h" #include "asshelp.h" -#include "../include/cipher.h" /* for PUBKEY_ALGO_ECDSA, PUBKEY_ALGO_ECDH */ +#include "../g10/cipher.h" /* for PUBKEY_ALGO_ECDSA, PUBKEY_ALGO_ECDH */ #include "../common/init.h" diff --git a/include/ChangeLog-2011 b/common/ChangeLog-2011.include similarity index 98% rename from include/ChangeLog-2011 rename to common/ChangeLog-2011.include index c4b4487..b5a9a5e 100644 --- a/include/ChangeLog-2011 +++ b/common/ChangeLog-2011.include @@ -1,3 +1,6 @@ +# This is the ChangeLog-2011 from the former ../include directory. It +# was moved to here after the removal of the directory on 2014-01-29. + 2011-12-01 Werner Koch NB: ChangeLog files are no longer manually maintained. Starting diff --git a/common/Makefile.am b/common/Makefile.am index 554918b..a777a34 100644 --- a/common/Makefile.am +++ b/common/Makefile.am @@ -20,7 +20,7 @@ EXTRA_DIST = mkstrtable.awk exaudit.awk exstatus.awk ChangeLog-2011 \ audit-events.h status-codes.h README.jnlib ChangeLog.jnlib \ - w32info-rc.h.in gnupg.ico + ChangeLog-2011.include w32info-rc.h.in gnupg.ico noinst_LIBRARIES = libcommon.a libcommonpth.a libgpgrl.a if !HAVE_W32CE_SYSTEM @@ -41,7 +41,7 @@ include $(top_srcdir)/am/cmacros.am jnlib_sources = \ libjnlib-config.h \ - types.h dynload.h w32help.h \ + types.h host2net.h dynload.h w32help.h \ stringhelp.c stringhelp.h \ strlist.c strlist.h \ utf8conv.c utf8conv.h \ diff --git a/include/host2net.h b/common/host2net.h similarity index 56% rename from include/host2net.h rename to common/host2net.h index 50f4815..dd20e36 100644 --- a/include/host2net.h +++ b/common/host2net.h @@ -1,14 +1,24 @@ -/* host2net.h - Some macros - * Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc. +/* host2net.h - Endian conversion macros + * Copyright (C) 1998, 2014 Werner Koch * * 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. + * This file is free software; you can redistribute it and/or modify + * it under the terms of either * - * GnuPG is distributed in the hope that it will be useful, + * - 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. + * + * or + * + * - the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * or both in parallel, as here. + * + * This file 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. @@ -17,8 +27,8 @@ * along with this program; if not, see . */ -#ifndef G10_HOST2NET_H -#define G10_HOST2NET_H +#ifndef GNUPG_COMMON_HOST2NET_H +#define GNUPG_COMMON_HOST2NET_H #include "types.h" @@ -39,4 +49,4 @@ #define u32tobuf( p, a) ulongtobuf( (p), (a) ) -#endif /*G10_HOST2NET_H*/ +#endif /*GNUPG_COMMON_HOST2NET_H*/ diff --git a/common/iobuf.h b/common/iobuf.h index 048524e..d3f5520 100644 --- a/common/iobuf.h +++ b/common/iobuf.h @@ -31,7 +31,7 @@ #ifndef GNUPG_COMMON_IOBUF_H #define GNUPG_COMMON_IOBUF_H -#include "../include/types.h" /* fixme: should be moved elsewhere. */ +#include "../common/types.h" #include "../common/sysutils.h" #include "../common/estream.h" diff --git a/common/types.h b/common/types.h index 437c304..97cedc2 100644 --- a/common/types.h +++ b/common/types.h @@ -31,6 +31,10 @@ #ifndef LIBJNLIB_TYPES_H #define LIBJNLIB_TYPES_H +#ifdef HAVE_INTTYPES_H +# include +#endif + /* The AC_CHECK_SIZEOF() in configure fails for some machines. * we provide some fallback values here */ #if !SIZEOF_UNSIGNED_SHORT @@ -50,15 +54,28 @@ #include +/* We use byte as an abbreviation for unsigned char. On some + platforms this needs special treatment: + + - RISC OS: + Norcroft C treats char = unsigned char as legal assignment + but char* = unsigned char* as illegal assignment + and the same applies to the signed variants as well. Thus we use + char which is anyway unsigned. + + - Windows: + Windows typedefs byte in the RPC headers but we need to avoid a + warning about a double definition. + */ #ifndef HAVE_BYTE_TYPEDEF # undef byte /* There might be a macro with this name. */ -/* Windows typedefs byte in the rpc headers. Avoid warning about - double definition. */ -#if !(defined(_WIN32) && defined(cbNDRContext)) - typedef unsigned char byte; -#endif +# ifdef __riscos__ + typedef char byte; +# elif !(defined(_WIN32) && defined(cbNDRContext)) + typedef unsigned char byte; +# endif # define HAVE_BYTE_TYPEDEF -#endif +#endif /*!HAVE_BYTE_TYPEDEF*/ #ifndef HAVE_USHORT_TYPEDEF # undef ushort /* There might be a macro with this name. */ @@ -106,6 +123,4 @@ # define GNUPG_GCC_A_SENTINEL(a) #endif - - #endif /*LIBJNLIB_TYPES_H*/ diff --git a/configure.ac b/configure.ac index c31cc33..f4b2d38 100644 --- a/configure.ac +++ b/configure.ac @@ -1710,7 +1710,6 @@ AC_CONFIG_FILES([ m4/Makefile Makefile po/Makefile.in gl/Makefile -include/Makefile common/Makefile common/w32info-rc.h kbx/Makefile diff --git a/g10/Makefile.am b/g10/Makefile.am index abf41c3..3e81ae4 100644 --- a/g10/Makefile.am +++ b/g10/Makefile.am @@ -48,6 +48,7 @@ endif common_source = \ gpg.h \ + cipher.h \ build-packet.c \ compress.c \ $(bzip2_source) \ diff --git a/include/cipher.h b/g10/cipher.h similarity index 98% rename from include/cipher.h rename to g10/cipher.h index 557ab70..7e784d2 100644 --- a/include/cipher.h +++ b/g10/cipher.h @@ -51,6 +51,7 @@ #define PUBKEY_ALGO_ECDH 18 #define PUBKEY_ALGO_ECDSA 19 #define PUBKEY_ALGO_ELGAMAL /* 20 */ GCRY_PK_ELG /* Elgamal encr+sign */ +#define PUBKEY_ALGO_EDDSA 105 /* Experimental! */ #define PUBKEY_USAGE_SIG GCRY_PK_USAGE_SIGN /* Good for signatures. */ #define PUBKEY_USAGE_ENC GCRY_PK_USAGE_ENCR /* Good for encryption. */ diff --git a/include/zlib-riscos.h b/g10/zlib-riscos.h similarity index 100% rename from include/zlib-riscos.h rename to g10/zlib-riscos.h diff --git a/include/Makefile.am b/include/Makefile.am deleted file mode 100644 index 4d733ba..0000000 --- a/include/Makefile.am +++ /dev/null @@ -1 +0,0 @@ -EXTRA_DIST = cipher.h types.h host2net.h _regex.h ChangeLog-2011 diff --git a/include/_regex.h b/include/_regex.h deleted file mode 100644 index 3d663d6..0000000 --- a/include/_regex.h +++ /dev/null @@ -1,574 +0,0 @@ -/* Definitions for data structures and routines for the regular - expression library. - Copyright (C) 1985,1989-93,1995-98,2000,2001,2002 - Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - MA 02110-1301, USA. */ - -#ifndef _REGEX_H -#define _REGEX_H 1 - -/* Allow the use in C++ code. */ -#ifdef __cplusplus -extern "C" { -#endif - -/* POSIX says that must be included (by the caller) before - . */ - -#if !defined _POSIX_C_SOURCE && !defined _POSIX_SOURCE && defined VMS -/* VMS doesn't have 'size_t' in , even though POSIX says it - should be there. */ -# include -#endif - -/* The following two types have to be signed and unsigned integer type - wide enough to hold a value of a pointer. For most ANSI compilers - ptrdiff_t and size_t should be likely OK. Still size of these two - types is 2 for Microsoft C. Ugh... */ -typedef long int s_reg_t; -typedef unsigned long int active_reg_t; - -/* The following bits are used to determine the regexp syntax we - recognize. The set/not-set meanings are chosen so that Emacs syntax - remains the value 0. The bits are given in alphabetical order, and - the definitions shifted by one from the previous bit; thus, when we - add or remove a bit, only one other definition need change. */ -typedef unsigned long int reg_syntax_t; - -/* If this bit is not set, then \ inside a bracket expression is literal. - If set, then such a \ quotes the following character. */ -#define RE_BACKSLASH_ESCAPE_IN_LISTS ((unsigned long int) 1) - -/* If this bit is not set, then + and ? are operators, and \+ and \? are - literals. - If set, then \+ and \? are operators and + and ? are literals. */ -#define RE_BK_PLUS_QM (RE_BACKSLASH_ESCAPE_IN_LISTS << 1) - -/* If this bit is set, then character classes are supported. They are: - [:alpha:], [:upper:], [:lower:], [:digit:], [:alnum:], [:xdigit:], - [:space:], [:print:], [:punct:], [:graph:], and [:cntrl:]. - If not set, then character classes are not supported. */ -#define RE_CHAR_CLASSES (RE_BK_PLUS_QM << 1) - -/* If this bit is set, then ^ and $ are always anchors (outside bracket - expressions, of course). - If this bit is not set, then it depends: - ^ is an anchor if it is at the beginning of a regular - expression or after an open-group or an alternation operator; - $ is an anchor if it is at the end of a regular expression, or - before a close-group or an alternation operator. - - This bit could be (re)combined with RE_CONTEXT_INDEP_OPS, because - POSIX draft 11.2 says that * etc. in leading positions is undefined. - We already implemented a previous draft which made those constructs - invalid, though, so we haven't changed the code back. */ -#define RE_CONTEXT_INDEP_ANCHORS (RE_CHAR_CLASSES << 1) - -/* If this bit is set, then special characters are always special - regardless of where they are in the pattern. - If this bit is not set, then special characters are special only in - some contexts; otherwise they are ordinary. Specifically, - * + ? and intervals are only special when not after the beginning, - open-group, or alternation operator. */ -#define RE_CONTEXT_INDEP_OPS (RE_CONTEXT_INDEP_ANCHORS << 1) - -/* If this bit is set, then *, +, ?, and { cannot be first in an re or - immediately after an alternation or begin-group operator. */ -#define RE_CONTEXT_INVALID_OPS (RE_CONTEXT_INDEP_OPS << 1) - -/* If this bit is set, then . matches newline. - If not set, then it doesn't. */ -#define RE_DOT_NEWLINE (RE_CONTEXT_INVALID_OPS << 1) - -/* If this bit is set, then . doesn't match NUL. - If not set, then it does. */ -#define RE_DOT_NOT_NULL (RE_DOT_NEWLINE << 1) - -/* If this bit is set, nonmatching lists [^...] do not match newline. - If not set, they do. */ -#define RE_HAT_LISTS_NOT_NEWLINE (RE_DOT_NOT_NULL << 1) - -/* If this bit is set, either \{...\} or {...} defines an - interval, depending on RE_NO_BK_BRACES. - If not set, \{, \}, {, and } are literals. */ -#define RE_INTERVALS (RE_HAT_LISTS_NOT_NEWLINE << 1) - -/* If this bit is set, +, ? and | aren't recognized as operators. - If not set, they are. */ -#define RE_LIMITED_OPS (RE_INTERVALS << 1) - -/* If this bit is set, newline is an alternation operator. - If not set, newline is literal. */ -#define RE_NEWLINE_ALT (RE_LIMITED_OPS << 1) - -/* If this bit is set, then '{...}' defines an interval, and \{ and \} - are literals. - If not set, then '\{...\}' defines an interval. */ -#define RE_NO_BK_BRACES (RE_NEWLINE_ALT << 1) - -/* If this bit is set, (...) defines a group, and \( and \) are literals. - If not set, \(...\) defines a group, and ( and ) are literals. */ -#define RE_NO_BK_PARENS (RE_NO_BK_BRACES << 1) - -/* If this bit is set, then \ matches . - If not set, then \ is a back-reference. */ -#define RE_NO_BK_REFS (RE_NO_BK_PARENS << 1) - -/* If this bit is set, then | is an alternation operator, and \| is literal. - If not set, then \| is an alternation operator, and | is literal. */ -#define RE_NO_BK_VBAR (RE_NO_BK_REFS << 1) - -/* If this bit is set, then an ending range point collating higher - than the starting range point, as in [z-a], is invalid. - If not set, then when ending range point collates higher than the - starting range point, the range is ignored. */ -#define RE_NO_EMPTY_RANGES (RE_NO_BK_VBAR << 1) - -/* If this bit is set, then an unmatched ) is ordinary. - If not set, then an unmatched ) is invalid. */ -#define RE_UNMATCHED_RIGHT_PAREN_ORD (RE_NO_EMPTY_RANGES << 1) - -/* If this bit is set, succeed as soon as we match the whole pattern, - without further backtracking. */ -#define RE_NO_POSIX_BACKTRACKING (RE_UNMATCHED_RIGHT_PAREN_ORD << 1) - -/* If this bit is set, do not process the GNU regex operators. - If not set, then the GNU regex operators are recognized. */ -#define RE_NO_GNU_OPS (RE_NO_POSIX_BACKTRACKING << 1) - -/* If this bit is set, turn on internal regex debugging. - If not set, and debugging was on, turn it off. - This only works if regex.c is compiled -DDEBUG. - We define this bit always, so that all that's needed to turn on - debugging is to recompile regex.c; the calling code can always have - this bit set, and it won't affect anything in the normal case. */ -#define RE_DEBUG (RE_NO_GNU_OPS << 1) - -/* If this bit is set, a syntactically invalid interval is treated as - a string of ordinary characters. For example, the ERE 'a{1' is - treated as 'a\{1'. */ -#define RE_INVALID_INTERVAL_ORD (RE_DEBUG << 1) - -/* If this bit is set, then ignore case when matching. - If not set, then case is significant. */ -#define RE_ICASE (RE_INVALID_INTERVAL_ORD << 1) - -/* This global variable defines the particular regexp syntax to use (for - some interfaces). When a regexp is compiled, the syntax used is - stored in the pattern buffer, so changing this does not affect - already-compiled regexps. */ -extern reg_syntax_t re_syntax_options; - -/* Define combinations of the above bits for the standard possibilities. - (The [[[ comments delimit what gets put into the Texinfo file, so - don't delete them!) */ -/* [[[begin syntaxes]]] */ -#define RE_SYNTAX_EMACS 0 - -#define RE_SYNTAX_AWK \ - (RE_BACKSLASH_ESCAPE_IN_LISTS | RE_DOT_NOT_NULL \ - | RE_NO_BK_PARENS | RE_NO_BK_REFS \ - | RE_NO_BK_VBAR | RE_NO_EMPTY_RANGES \ - | RE_DOT_NEWLINE | RE_CONTEXT_INDEP_ANCHORS \ - | RE_UNMATCHED_RIGHT_PAREN_ORD | RE_NO_GNU_OPS) - -#define RE_SYNTAX_GNU_AWK \ - ((RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS | RE_DEBUG) \ - & ~(RE_DOT_NOT_NULL | RE_INTERVALS | RE_CONTEXT_INDEP_OPS \ - | RE_CONTEXT_INVALID_OPS )) - -#define RE_SYNTAX_POSIX_AWK \ - (RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS \ - | RE_INTERVALS | RE_NO_GNU_OPS) - -#define RE_SYNTAX_GREP \ - (RE_BK_PLUS_QM | RE_CHAR_CLASSES \ - | RE_HAT_LISTS_NOT_NEWLINE | RE_INTERVALS \ - | RE_NEWLINE_ALT) - -#define RE_SYNTAX_EGREP \ - (RE_CHAR_CLASSES | RE_CONTEXT_INDEP_ANCHORS \ - | RE_CONTEXT_INDEP_OPS | RE_HAT_LISTS_NOT_NEWLINE \ - | RE_NEWLINE_ALT | RE_NO_BK_PARENS \ - | RE_NO_BK_VBAR) - -#define RE_SYNTAX_POSIX_EGREP \ - (RE_SYNTAX_EGREP | RE_INTERVALS | RE_NO_BK_BRACES \ - | RE_INVALID_INTERVAL_ORD) - -/* P1003.2/D11.2, section 4.20.7.1, lines 5078ff. */ -#define RE_SYNTAX_ED RE_SYNTAX_POSIX_BASIC - -#define RE_SYNTAX_SED RE_SYNTAX_POSIX_BASIC - -/* Syntax bits common to both basic and extended POSIX regex syntax. */ -#define _RE_SYNTAX_POSIX_COMMON \ - (RE_CHAR_CLASSES | RE_DOT_NEWLINE | RE_DOT_NOT_NULL \ - | RE_INTERVALS | RE_NO_EMPTY_RANGES) - -#define RE_SYNTAX_POSIX_BASIC \ - (_RE_SYNTAX_POSIX_COMMON | RE_BK_PLUS_QM) - -/* Differs from ..._POSIX_BASIC only in that RE_BK_PLUS_QM becomes - RE_LIMITED_OPS, i.e., \? \+ \| are not recognized. Actually, this - isn't minimal, since other operators, such as \`, aren't disabled. */ -#define RE_SYNTAX_POSIX_MINIMAL_BASIC \ - (_RE_SYNTAX_POSIX_COMMON | RE_LIMITED_OPS) - -#define RE_SYNTAX_POSIX_EXTENDED \ - (_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \ - | RE_CONTEXT_INDEP_OPS | RE_NO_BK_BRACES \ - | RE_NO_BK_PARENS | RE_NO_BK_VBAR \ - | RE_CONTEXT_INVALID_OPS | RE_UNMATCHED_RIGHT_PAREN_ORD) - -/* Differs from ..._POSIX_EXTENDED in that RE_CONTEXT_INDEP_OPS is - removed and RE_NO_BK_REFS is added. */ -#define RE_SYNTAX_POSIX_MINIMAL_EXTENDED \ - (_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \ - | RE_CONTEXT_INVALID_OPS | RE_NO_BK_BRACES \ - | RE_NO_BK_PARENS | RE_NO_BK_REFS \ - | RE_NO_BK_VBAR | RE_UNMATCHED_RIGHT_PAREN_ORD) -/* [[[end syntaxes]]] */ - -/* Maximum number of duplicates an interval can allow. Some systems - (erroneously) define this in other header files, but we want our - value, so remove any previous define. */ -#ifdef RE_DUP_MAX -# undef RE_DUP_MAX -#endif -/* If sizeof(int) == 2, then ((1 << 15) - 1) overflows. */ -#define RE_DUP_MAX (0x7fff) - - -/* POSIX 'cflags' bits (i.e., information for 'regcomp'). */ - -/* If this bit is set, then use extended regular expression syntax. - If not set, then use basic regular expression syntax. */ -#define REG_EXTENDED 1 - -/* If this bit is set, then ignore case when matching. - If not set, then case is significant. */ -#define REG_ICASE (REG_EXTENDED << 1) - -/* If this bit is set, then anchors do not match at newline - characters in the string. - If not set, then anchors do match at newlines. */ -#define REG_NEWLINE (REG_ICASE << 1) - -/* If this bit is set, then report only success or fail in regexec. - If not set, then returns differ between not matching and errors. */ -#define REG_NOSUB (REG_NEWLINE << 1) - - -/* POSIX 'eflags' bits (i.e., information for regexec). */ - -/* If this bit is set, then the beginning-of-line operator doesn't match - the beginning of the string (presumably because it's not the - beginning of a line). - If not set, then the beginning-of-line operator does match the - beginning of the string. */ -#define REG_NOTBOL 1 - -/* Like REG_NOTBOL, except for the end-of-line. */ -#define REG_NOTEOL (1 << 1) - - -/* If any error codes are removed, changed, or added, update the - 're_error_msg' table in regex.c. */ -typedef enum -{ -#ifdef _XOPEN_SOURCE - REG_ENOSYS = -1, /* This will never happen for this implementation. */ -#endif - - REG_NOERROR = 0, /* Success. */ - REG_NOMATCH, /* Didn't find a match (for regexec). */ - - /* POSIX regcomp return error codes. (In the order listed in the - standard.) */ - REG_BADPAT, /* Invalid pattern. */ - REG_ECOLLATE, /* Not implemented. */ - REG_ECTYPE, /* Invalid character class name. */ - REG_EESCAPE, /* Trailing backslash. */ - REG_ESUBREG, /* Invalid back reference. */ - REG_EBRACK, /* Unmatched left bracket. */ - REG_EPAREN, /* Parenthesis imbalance. */ - REG_EBRACE, /* Unmatched \{. */ - REG_BADBR, /* Invalid contents of \{\}. */ - REG_ERANGE, /* Invalid range end. */ - REG_ESPACE, /* Ran out of memory. */ - REG_BADRPT, /* No preceding re for repetition op. */ - - /* Error codes we've added. */ - REG_EEND, /* Premature end. */ - REG_ESIZE, /* Compiled pattern bigger than 2^16 bytes. */ - REG_ERPAREN /* Unmatched ) or \); not returned from regcomp. */ -} reg_errcode_t; - -/* This data structure represents a compiled pattern. Before calling - the pattern compiler, the fields 'buffer', 'allocated', 'fastmap', - 'translate', and 'no_sub' can be set. After the pattern has been - compiled, the 're_nsub' field is available. All other fields are - private to the regex routines. */ - -#ifndef RE_TRANSLATE_TYPE -# define RE_TRANSLATE_TYPE char * -#endif - -struct re_pattern_buffer -{ -/* [[[begin pattern_buffer]]] */ - /* Space that holds the compiled pattern. It is declared as - 'unsigned char *' because its elements are - sometimes used as array indexes. */ - unsigned char *buffer; - - /* Number of bytes to which 'buffer' points. */ - unsigned long int allocated; - - /* Number of bytes actually used in 'buffer'. */ - unsigned long int used; - - /* Syntax setting with which the pattern was compiled. */ - reg_syntax_t syntax; - - /* Pointer to a fastmap, if any, otherwise zero. re_search uses - the fastmap, if there is one, to skip over impossible - starting points for matches. */ - char *fastmap; - - /* Either a translate table to apply to all characters before - comparing them, or zero for no translation. The translation - is applied to a pattern when it is compiled and to a string - when it is matched. */ - RE_TRANSLATE_TYPE translate; - - /* Number of subexpressions found by the compiler. */ - size_t re_nsub; - - /* Zero if this pattern cannot match the empty string, one else. - Well, in truth it's used only in 're_search_2', to see - whether or not we should use the fastmap, so we don't set - this absolutely perfectly; see 're_compile_fastmap' (the - 'duplicate' case). */ - unsigned can_be_null : 1; - - /* If REGS_UNALLOCATED, allocate space in the 'regs' structure - for 'max (RE_NREGS, re_nsub + 1)' groups. - If REGS_REALLOCATE, reallocate space if necessary. - If REGS_FIXED, use what's there. */ -#define REGS_UNALLOCATED 0 -#define REGS_REALLOCATE 1 -#define REGS_FIXED 2 - unsigned regs_allocated : 2; - - /* Set to zero when 'regex_compile' compiles a pattern; set to one - by 're_compile_fastmap' if it updates the fastmap. */ - unsigned fastmap_accurate : 1; - - /* If set, 're_match_2' does not return information about - subexpressions. */ - unsigned no_sub : 1; - - /* If set, a beginning-of-line anchor doesn't match at the - beginning of the string. */ - unsigned not_bol : 1; - - /* Similarly for an end-of-line anchor. */ - unsigned not_eol : 1; - - /* If true, an anchor at a newline matches. */ - unsigned newline_anchor : 1; - -/* [[[end pattern_buffer]]] */ -}; - -typedef struct re_pattern_buffer regex_t; - -/* Type for byte offsets within the string. POSIX mandates this. */ -typedef int regoff_t; - - -/* This is the structure we store register match data in. See - regex.texinfo for a full description of what registers match. */ -struct re_registers -{ - unsigned num_regs; - regoff_t *start; - regoff_t *end; -}; - - -/* If 'regs_allocated' is REGS_UNALLOCATED in the pattern buffer, - 're_match_2' returns information about at least this many registers - the first time a 'regs' structure is passed. */ -#ifndef RE_NREGS -# define RE_NREGS 30 -#endif - - -/* POSIX specification for registers. Aside from the different names than - 're_registers', POSIX uses an array of structures, instead of a - structure of arrays. */ -typedef struct -{ - regoff_t rm_so; /* Byte offset from string's start to substring's start. */ - regoff_t rm_eo; /* Byte offset from string's start to substring's end. */ -} regmatch_t; - -/* Declarations for routines. */ - -/* To avoid duplicating every routine declaration -- once with a - prototype (if we are ANSI), and once without (if we aren't) -- we - use the following macro to declare argument types. This - unfortunately clutters up the declarations a bit, but I think it's - worth it. */ - -#if __STDC__ - -# define _RE_ARGS(args) args - -#else /* not __STDC__ */ - -# define _RE_ARGS(args) () - -#endif /* not __STDC__ */ - -/* Sets the current default syntax to SYNTAX, and return the old syntax. - You can also simply assign to the 're_syntax_options' variable. */ -extern reg_syntax_t re_set_syntax _RE_ARGS ((reg_syntax_t syntax)); - -/* Compile the regular expression PATTERN, with length LENGTH - and syntax given by the global 're_syntax_options', into the buffer - BUFFER. Return NULL if successful, and an error string if not. */ -extern const char *re_compile_pattern - _RE_ARGS ((const char *pattern, size_t length, - struct re_pattern_buffer *buffer)); - - -/* Compile a fastmap for the compiled pattern in BUFFER; used to - accelerate searches. Return 0 if successful and -2 if was an - internal error. */ -extern int re_compile_fastmap _RE_ARGS ((struct re_pattern_buffer *buffer)); - - -/* Search in the string STRING (with length LENGTH) for the pattern - compiled into BUFFER. Start searching at position START, for RANGE - characters. Return the starting position of the match, -1 for no - match, or -2 for an internal error. Also return register - information in REGS (if REGS and BUFFER->no_sub are nonzero). */ -extern int re_search - _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string, - int length, int start, int range, struct re_registers *regs)); - - -/* Like 're_search', but search in the concatenation of STRING1 and - STRING2. Also, stop searching at index START + STOP. */ -extern int re_search_2 - _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string1, - int length1, const char *string2, int length2, - int start, int range, struct re_registers *regs, int stop)); - - -/* Like 're_search', but return how many characters in STRING the regexp - in BUFFER matched, starting at position START. */ -extern int re_match - _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string, - int length, int start, struct re_registers *regs)); - - -/* Relates to 're_match' as 're_search_2' relates to 're_search'. */ -extern int re_match_2 - _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string1, - int length1, const char *string2, int length2, - int start, struct re_registers *regs, int stop)); - - -/* Set REGS to hold NUM_REGS registers, storing them in STARTS and - ENDS. Subsequent matches using BUFFER and REGS will use this memory - for recording register information. STARTS and ENDS must be - allocated with malloc, and must each be at least `NUM_REGS * sizeof - (regoff_t)' bytes long. - - If NUM_REGS == 0, then subsequent matches should allocate their own - register data. - - Unless this function is called, the first search or match using - PATTERN_BUFFER will allocate its own register data, without - freeing the old data. */ -extern void re_set_registers - _RE_ARGS ((struct re_pattern_buffer *buffer, struct re_registers *regs, - unsigned num_regs, regoff_t *starts, regoff_t *ends)); - -#if defined _REGEX_RE_COMP || defined _LIBC -# ifndef _CRAY -/* 4.2 bsd compatibility. */ -extern char *re_comp _RE_ARGS ((const char *)); -extern int re_exec _RE_ARGS ((const char *)); -# endif -#endif - -/* GCC 2.95 and later have "__restrict"; C99 compilers have - "restrict", and "configure" may have defined "restrict". */ -#ifndef __restrict -# if ! (2 < __GNUC__ || (2 == __GNUC__ && 95 <= __GNUC_MINOR__)) -# if defined restrict || 199901L <= __STDC_VERSION__ -# define __restrict restrict -# else -# define __restrict -# endif -# endif -#endif -/* gcc 3.1 and up support the [restrict] syntax. */ -#ifndef __restrict_arr -# if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) -# define __restrict_arr __restrict -# else -# define __restrict_arr -# endif -#endif - -/* POSIX compatibility. */ -extern int regcomp _RE_ARGS ((regex_t *__restrict __preg, - const char *__restrict __pattern, - int __cflags)); - -extern int regexec _RE_ARGS ((const regex_t *__restrict __preg, - const char *__restrict __string, size_t __nmatch, - regmatch_t __pmatch[__restrict_arr], - int __eflags)); - -extern size_t regerror _RE_ARGS ((int __errcode, const regex_t *__preg, - char *__errbuf, size_t __errbuf_size)); - -extern void regfree _RE_ARGS ((regex_t *__preg)); - - -#ifdef __cplusplus -} -#endif /* C++ */ - -#endif /* regex.h */ - -/* -Local variables: -make-backup-files: t -version-control: t -trim-versions-without-asking: nil -End: -*/ diff --git a/include/types.h b/include/types.h deleted file mode 100644 index f3657e1..0000000 --- a/include/types.h +++ /dev/null @@ -1,105 +0,0 @@ -/* types.h - some common typedefs - * Copyright (C) 1998, 1999, 2000, 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 . - */ - -#ifndef G10_TYPES_H -#define G10_TYPES_H - -#ifdef HAVE_INTTYPES_H -# include -#endif - -/* The AC_CHECK_SIZEOF() in configure fails for some machines. - * we provide some fallback values here */ -#if !SIZEOF_UNSIGNED_SHORT -#undef SIZEOF_UNSIGNED_SHORT -#define SIZEOF_UNSIGNED_SHORT 2 -#endif -#if !SIZEOF_UNSIGNED_INT -#undef SIZEOF_UNSIGNED_INT -#define SIZEOF_UNSIGNED_INT 4 -#endif -#if !SIZEOF_UNSIGNED_LONG -#undef SIZEOF_UNSIGNED_LONG -#define SIZEOF_UNSIGNED_LONG 4 -#endif - - -#include - - -#ifndef HAVE_BYTE_TYPEDEF -#undef byte /* maybe there is a macro with this name */ -#ifndef __riscos__ -typedef unsigned char byte; -#else -/* Norcroft treats char = unsigned char as legal assignment - but char* = unsigned char* as illegal assignment - and the same applies to the signed variants as well */ -typedef char byte; -#endif -#define HAVE_BYTE_TYPEDEF -#endif - -#ifndef HAVE_USHORT_TYPEDEF -#undef ushort /* maybe there is a macro with this name */ -typedef unsigned short ushort; -#define HAVE_USHORT_TYPEDEF -#endif - -#ifndef HAVE_ULONG_TYPEDEF -#undef ulong /* maybe there is a macro with this name */ -typedef unsigned long ulong; -#define HAVE_ULONG_TYPEDEF -#endif - -#ifndef HAVE_U16_TYPEDEF -#undef u16 /* maybe there is a macro with this name */ -#if SIZEOF_UNSIGNED_INT == 2 -typedef unsigned int u16; -#elif SIZEOF_UNSIGNED_SHORT == 2 -typedef unsigned short u16; -#else -#error no typedef for u16 -#endif -#define HAVE_U16_TYPEDEF -#endif - -#ifndef HAVE_U32_TYPEDEF -#undef u32 /* maybe there is a macro with this name */ -#if SIZEOF_UNSIGNED_INT == 4 -typedef unsigned int u32; -#elif SIZEOF_UNSIGNED_LONG == 4 -typedef unsigned long u32; -#else -#error no typedef for u32 -#endif -#define HAVE_U32_TYPEDEF -#endif - - -typedef union { - int a; - short b; - char c[1]; - long d; - float f; - double g; -} PROPERLY_ALIGNED_TYPE; - -#endif /*G10_TYPES_H*/ commit 47bb0d7683b0c03a106bf4fbc02e8d813d268a8a Author: Werner Koch Date: Wed Jan 29 15:19:20 2014 +0100 gpg: Add another card vendor id. -- diff --git a/g10/card-util.c b/g10/card-util.c index add8eed..c043b3e 100644 --- a/g10/card-util.c +++ b/g10/card-util.c @@ -207,6 +207,7 @@ get_manufacturer (unsigned int no) case 0x0004: return "Wewid"; case 0x0005: return "ZeitControl"; case 0x0006: return "Yubico"; + case 0x0007: return "OpenKMS"; case 0x002A: return "Magrathea"; commit 362a30d8c2f529cd44687066f9c33cab7b43bedc Author: Werner Koch Date: Thu Jan 9 19:14:09 2014 +0100 Remove unused u64 type definitions. * configure.ac: Remove check for uint64 and UINT64_C. * include/types.h: Remove u64 stuff. * common/types.h: Ditto. -- There have been relicts from GnuPG-1. Signed-off-by: Werner Koch diff --git a/common/types.h b/common/types.h index 631cd82..437c304 100644 --- a/common/types.h +++ b/common/types.h @@ -96,20 +96,6 @@ # define HAVE_U32_TYPEDEF #endif -#ifndef HAVE_U64_TYPEDEF -# undef u64 /* There might be a macro with this name. */ -# if SIZEOF_UNSIGNED_INT == 8 - typedef unsigned int u64; -# define HAVE_U64_TYPEDEF -# elif SIZEOF_UNSIGNED_LONG == 8 - typedef unsigned long u64; -# define HAVE_U64_TYPEDEF -# elif __GNUC__ >= 2 || defined(__SUNPRO_C) - typedef unsigned long long u64; -# define HAVE_U64_TYPEDEF -# endif -#endif - /* Some GCC attributes. Note that we use also define some in mischelp.h, but this header and types.h are not always included. diff --git a/configure.ac b/configure.ac index 45481cc..c31cc33 100644 --- a/configure.ac +++ b/configure.ac @@ -797,6 +797,7 @@ AC_SUBST(LIBUSB_LIBS) # # Check wether it is necessary to link against libdl. +# (For example to load libpcsclite) # gnupg_dlopen_save_libs="$LIBS" LIBS="" @@ -1140,7 +1141,7 @@ fi # We use HAVE_LANGINFO_CODESET in a couple of places. AM_LANGINFO_CODESET -# Checks required for our use locales +# Checks required for our use of locales gt_LC_MESSAGES @@ -1216,16 +1217,6 @@ AC_CHECK_SIZEOF(time_t,,[[ GNUPG_TIME_T_UNSIGNED -# 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 diff --git a/include/types.h b/include/types.h index e13b11a..f3657e1 100644 --- a/include/types.h +++ b/include/types.h @@ -21,8 +21,7 @@ #define G10_TYPES_H #ifdef HAVE_INTTYPES_H -/* For uint64_t */ -#include +# include #endif /* The AC_CHECK_SIZEOF() in configure fails for some machines. @@ -93,40 +92,12 @@ typedef unsigned long u32; #define HAVE_U32_TYPEDEF #endif -/**************** - * Warning: Some systems segfault when this u64 typedef and - * the dummy code in cipher/md.c is not available. Examples are - * Solaris and IRIX. - */ -#ifndef HAVE_U64_TYPEDEF -#undef u64 /* maybe there is a macro with this name */ -#if SIZEOF_UINT64_T == 8 -typedef uint64_t u64; -#define U64_C(c) (UINT64_C(c)) -#define HAVE_U64_TYPEDEF -#elif SIZEOF_UNSIGNED_INT == 8 -typedef unsigned int u64; -#define U64_C(c) (c ## U) -#define HAVE_U64_TYPEDEF -#elif SIZEOF_UNSIGNED_LONG == 8 -typedef unsigned long u64; -#define U64_C(c) (c ## UL) -#define HAVE_U64_TYPEDEF -#elif SIZEOF_UNSIGNED_LONG_LONG == 8 -typedef unsigned long long u64; -#define U64_C(c) (c ## ULL) -#define HAVE_U64_TYPEDEF -#endif -#endif typedef union { int a; short b; char c[1]; long d; -#ifdef HAVE_U64_TYPEDEF - u64 e; -#endif float f; double g; } PROPERLY_ALIGNED_TYPE; ----------------------------------------------------------------------- Summary of changes: Makefile.am | 2 +- agent/gpg-agent.c | 2 +- .../ChangeLog-2011.include | 3 + common/Makefile.am | 4 +- {include => common}/host2net.h | 30 +- common/iobuf.h | 2 +- common/types.h | 45 +- configure.ac | 14 +- g10/Makefile.am | 1 + g10/card-util.c | 1 + {include => g10}/cipher.h | 1 + {include => g10}/zlib-riscos.h | 0 include/Makefile.am | 1 - include/_regex.h | 574 -------------------- include/types.h | 134 ----- 15 files changed, 56 insertions(+), 758 deletions(-) rename include/ChangeLog-2011 => common/ChangeLog-2011.include (98%) rename {include => common}/host2net.h (56%) rename {include => g10}/cipher.h (98%) rename {include => g10}/zlib-riscos.h (100%) delete mode 100644 include/Makefile.am delete mode 100644 include/_regex.h delete mode 100644 include/types.h hooks/post-receive -- The GNU Privacy Guard http://git.gnupg.org From cvs at cvs.gnupg.org Wed Jan 29 20:40:33 2014 From: cvs at cvs.gnupg.org (by Werner Koch) Date: Wed, 29 Jan 2014 20:40:33 +0100 Subject: [git] GnuPG - branch, master, updated. gnupg-2.1.0beta3-292-gea8a168 Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The GNU Privacy Guard". The branch, master has been updated via ea8a1685f75d27f5277d42ea7390ad5aeaf51b1f (commit) from 25b4c2acbd01f9b4c2c364f44c53b73498ed8469 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit ea8a1685f75d27f5277d42ea7390ad5aeaf51b1f Author: Werner Koch Date: Wed Jan 29 20:35:05 2014 +0100 gpg: Remove cipher.h and put algo ids into a common file. * common/openpgpdefs.h (cipher_algo_t, pubkey_algo_t, digest_algo_t) (compress_algo_t): New. * agent/gpg-agent.c: Remove ../g10/cipher.h. Add openpgpdefs.h. * g10/cipher.h (DEK): Move to ... * g10/dek.h: new file. * g10/cipher.h (is_RSA, is_ELGAMAL, is_DSA) (PUBKEY_MAX_NPKEY, PUBKEY_MAX_NSKEY, PUBKEY_MAX_NSIG, PUBKEY_MAX_NENC) (PUBKEY_USAGE_SIG, PUBKEY_USAGE_ENC, PUBKEY_USAGE_CERT) (PUBKEY_USAGE_AUTH, PUBKEY_USAGE_NONE): Move to * g10/packet.h: here. * g10/cipher.h: Remove. Remove from all files. * g10/filter.h, g10/packet.h: Include dek.h. * g10/Makefile.am (common_source): Remove cipher.h. Add dek.h. Signed-off-by: Werner Koch diff --git a/agent/gpg-agent.c b/agent/gpg-agent.c index 9810983..34f8ef3 100644 --- a/agent/gpg-agent.c +++ b/agent/gpg-agent.c @@ -51,7 +51,7 @@ #include "gc-opt-flags.h" #include "exechelp.h" #include "asshelp.h" -#include "../g10/cipher.h" /* for PUBKEY_ALGO_ECDSA, PUBKEY_ALGO_ECDH */ +#include "openpgpdefs.h" /* for PUBKEY_ALGO_ECDSA, PUBKEY_ALGO_ECDH */ #include "../common/init.h" diff --git a/common/openpgpdefs.h b/common/openpgpdefs.h index c2fa617..0a58442 100644 --- a/common/openpgpdefs.h +++ b/common/openpgpdefs.h @@ -1,6 +1,7 @@ /* openpgpdefs.h - Constants from the OpenPGP standard (rfc2440) * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, * 2006 Free Software Foundation, Inc. + * Copyright (C) 2014 Werner Koch * * This file is free software; you can redistribute it and/or modify * it under the terms of either @@ -92,4 +93,65 @@ typedef enum sigsubpkttype_t; +typedef enum + { + CIPHER_ALGO_NONE = 0, + CIPHER_ALGO_IDEA = 1, + CIPHER_ALGO_3DES = 2, + CIPHER_ALGO_CAST5 = 3, + CIPHER_ALGO_BLOWFISH = 4, /* 128 bit */ + /* 5 & 6 are reserved */ + CIPHER_ALGO_AES = 7, + CIPHER_ALGO_AES192 = 8, + CIPHER_ALGO_AES256 = 9, + CIPHER_ALGO_TWOFISH = 10, /* 256 bit */ + CIPHER_ALGO_CAMELLIA128 = 11, + CIPHER_ALGO_CAMELLIA192 = 12, + CIPHER_ALGO_CAMELLIA256 = 13, + + CIPHER_ALGO_DUMMY = 110 /* No encryption at all (private). */ + } +cipher_algo_t; + + +typedef enum + { + PUBKEY_ALGO_RSA = 1, + PUBKEY_ALGO_RSA_E = 2, /* RSA encrypt only (legacy). */ + PUBKEY_ALGO_RSA_S = 3, /* RSA sign only (legacy). */ + PUBKEY_ALGO_ELGAMAL_E = 16, /* Elgamal encrypt only. */ + PUBKEY_ALGO_DSA = 17, + PUBKEY_ALGO_ECDH = 18, /* RFC-6637 */ + PUBKEY_ALGO_ECDSA = 19, /* RFC-6637 */ + PUBKEY_ALGO_ELGAMAL = 20, /* Elgamal encrypt+sign (legacy). */ + + PUBKEY_ALGO_EDDSA = 105 /* EdDSA (cf. Ed25519) (experimental). */ + } +pubkey_algo_t; + + +typedef enum + { + DIGEST_ALGO_MD5 = 1, + DIGEST_ALGO_SHA1 = 2, + DIGEST_ALGO_RMD160 = 3, + /* 4, 5, 6, and 7 are reserved. */ + DIGEST_ALGO_SHA256 = 8, + DIGEST_ALGO_SHA384 = 9, + DIGEST_ALGO_SHA512 = 10, + DIGEST_ALGO_SHA224 = 11 + } +digest_algo_t; + + +typedef enum + { + COMPRESS_ALGO_NONE = 0, + COMPRESS_ALGO_ZIP = 1, + COMPRESS_ALGO_ZLIB = 2, + COMPRESS_ALGO_BZIP2 = 3 + } +compress_algo_t; + + #endif /*GNUPG_COMMON_OPENPGPDEFS_H*/ diff --git a/g10/Makefile.am b/g10/Makefile.am index 3e81ae4..415822a 100644 --- a/g10/Makefile.am +++ b/g10/Makefile.am @@ -48,7 +48,7 @@ endif common_source = \ gpg.h \ - cipher.h \ + dek.h \ build-packet.c \ compress.c \ $(bzip2_source) \ diff --git a/g10/build-packet.c b/g10/build-packet.c index b4514ae..f31ca88 100644 --- a/g10/build-packet.c +++ b/g10/build-packet.c @@ -30,7 +30,6 @@ #include "packet.h" #include "status.h" #include "iobuf.h" -#include "cipher.h" #include "i18n.h" #include "options.h" diff --git a/g10/cipher.h b/g10/cipher.h deleted file mode 100644 index 7e784d2..0000000 --- a/g10/cipher.h +++ /dev/null @@ -1,108 +0,0 @@ -/* cipher.h - Definitions for OpenPGP - * Copyright (C) 1998, 1999, 2000, 2001, 2006, - * 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 . - */ -#ifndef G10_CIPHER_H -#define G10_CIPHER_H - -#include - -/* Constants for OpenPGP. */ - -#define CIPHER_ALGO_NONE /* 0 */ GCRY_CIPHER_NONE -#define CIPHER_ALGO_IDEA /* 1 */ GCRY_CIPHER_IDEA -#define CIPHER_ALGO_3DES /* 2 */ GCRY_CIPHER_3DES -#define CIPHER_ALGO_CAST5 /* 3 */ GCRY_CIPHER_CAST5 -#define CIPHER_ALGO_BLOWFISH /* 4 */ GCRY_CIPHER_BLOWFISH /* 128 bit */ -/* 5 & 6 are reserved */ -#define CIPHER_ALGO_AES /* 7 */ GCRY_CIPHER_AES -#define CIPHER_ALGO_AES192 /* 8 */ GCRY_CIPHER_AES192 -#define CIPHER_ALGO_AES256 /* 9 */ GCRY_CIPHER_AES256 -#define CIPHER_ALGO_RIJNDAEL CIPHER_ALGO_AES -#define CIPHER_ALGO_RIJNDAEL192 CIPHER_ALGO_AES192 -#define CIPHER_ALGO_RIJNDAEL256 CIPHER_ALGO_AES256 -#define CIPHER_ALGO_TWOFISH /* 10 */ GCRY_CIPHER_TWOFISH /* 256 bit */ -/* Note: Camellia ids don't match those used by libgcrypt. */ -#define CIPHER_ALGO_CAMELLIA128 11 -#define CIPHER_ALGO_CAMELLIA192 12 -#define CIPHER_ALGO_CAMELLIA256 13 -#define CIPHER_ALGO_DUMMY 110 /* No encryption at all. */ - -#define PUBKEY_ALGO_RSA /* 1 */ GCRY_PK_RSA -#define PUBKEY_ALGO_RSA_E /* 2 */ GCRY_PK_RSA_E /* RSA encrypt only. */ -#define PUBKEY_ALGO_RSA_S /* 3 */ GCRY_PK_RSA_S /* RSA sign only. */ -#define PUBKEY_ALGO_ELGAMAL_E /* 16 */ GCRY_PK_ELG_E /* Elgamal encr only */ -#define PUBKEY_ALGO_DSA /* 17 */ GCRY_PK_DSA -#define PUBKEY_ALGO_ECDH 18 -#define PUBKEY_ALGO_ECDSA 19 -#define PUBKEY_ALGO_ELGAMAL /* 20 */ GCRY_PK_ELG /* Elgamal encr+sign */ -#define PUBKEY_ALGO_EDDSA 105 /* Experimental! */ - -#define PUBKEY_USAGE_SIG GCRY_PK_USAGE_SIGN /* Good for signatures. */ -#define PUBKEY_USAGE_ENC GCRY_PK_USAGE_ENCR /* Good for encryption. */ -#define PUBKEY_USAGE_CERT GCRY_PK_USAGE_CERT /* Also good to certify keys.*/ -#define PUBKEY_USAGE_AUTH GCRY_PK_USAGE_AUTH /* Good for authentication. */ -#define PUBKEY_USAGE_UNKNOWN GCRY_PK_USAGE_UNKN /* Unknown usage flag. */ -#define PUBKEY_USAGE_NONE 256 /* No usage given. */ -#if (GCRY_PK_USAGE_SIGN | GCRY_PK_USAGE_ENCR | GCRY_PK_USAGE_CERT \ - | GCRY_PK_USAGE_AUTH | GCRY_PK_USAGE_UNKN) >= 256 -# error Please choose another value for PUBKEY_USAGE_NONE -#endif - -#define DIGEST_ALGO_MD5 /* 1 */ GCRY_MD_MD5 -#define DIGEST_ALGO_SHA1 /* 2 */ GCRY_MD_SHA1 -#define DIGEST_ALGO_RMD160 /* 3 */ GCRY_MD_RMD160 -/* 4, 5, 6, and 7 are reserved */ -#define DIGEST_ALGO_SHA256 /* 8 */ GCRY_MD_SHA256 -#define DIGEST_ALGO_SHA384 /* 9 */ GCRY_MD_SHA384 -#define DIGEST_ALGO_SHA512 /* 10 */ GCRY_MD_SHA512 -/* SHA224 is only available in libgcrypt 1.4.0; thus we - can't use the GCRY macro here. */ -#define DIGEST_ALGO_SHA224 /* 11 */ 11 /* GCRY_MD_SHA224 */ - -#define COMPRESS_ALGO_NONE 0 -#define COMPRESS_ALGO_ZIP 1 -#define COMPRESS_ALGO_ZLIB 2 -#define COMPRESS_ALGO_BZIP2 3 - -#define is_RSA(a) ((a)==PUBKEY_ALGO_RSA || (a)==PUBKEY_ALGO_RSA_E \ - || (a)==PUBKEY_ALGO_RSA_S ) -#define is_ELGAMAL(a) ((a)==PUBKEY_ALGO_ELGAMAL_E) -#define is_DSA(a) ((a)==PUBKEY_ALGO_DSA) - -/* The data encryption key object. */ -typedef struct -{ - int algo; - int keylen; - int algo_info_printed; - int use_mdc; - int symmetric; - byte key[32]; /* This is the largest used keylen (256 bit). */ - char s2k_cacheid[1+16+1]; -} DEK; - - - -/* Constants to allocate static MPI arrays. */ -#define PUBKEY_MAX_NPKEY 5 -#define PUBKEY_MAX_NSKEY 7 -#define PUBKEY_MAX_NSIG 2 -#define PUBKEY_MAX_NENC 2 - -#endif /*G10_CIPHER_H*/ diff --git a/g10/cpr.c b/g10/cpr.c index 988d211..8d2262e 100644 --- a/g10/cpr.c +++ b/g10/cpr.c @@ -35,7 +35,6 @@ #include "options.h" #include "main.h" #include "i18n.h" -#include "cipher.h" /* for progress functions */ #define CONTROL_D ('D' - 'A' + 1) diff --git a/g10/decrypt-data.c b/g10/decrypt-data.c index 4ad47cb..22a6aef 100644 --- a/g10/decrypt-data.c +++ b/g10/decrypt-data.c @@ -27,7 +27,6 @@ #include "gpg.h" #include "util.h" #include "packet.h" -#include "cipher.h" #include "options.h" #include "i18n.h" #include "status.h" diff --git a/g10/dek.h b/g10/dek.h new file mode 100644 index 0000000..31ebbb6 --- /dev/null +++ b/g10/dek.h @@ -0,0 +1,35 @@ +/* dek.h - The data encryption key structure. + * Copyright (C) 2014 Werner Koch + * + * 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_DEK_H +#define G10_DEK_H + + +typedef struct +{ + int algo; + int keylen; + int algo_info_printed; + int use_mdc; + int symmetric; + byte key[32]; /* This is the largest used keylen (256 bit). */ + char s2k_cacheid[1+16+1]; +} DEK; + + +#endif /*G10_DEK_H*/ diff --git a/g10/filter.h b/g10/filter.h index 18a9170..40c5134 100644 --- a/g10/filter.h +++ b/g10/filter.h @@ -21,7 +21,7 @@ #define G10_FILTER_H #include "types.h" -#include "cipher.h" +#include "dek.h" typedef struct { gcry_md_hd_t md; /* catch all */ diff --git a/g10/free-packet.c b/g10/free-packet.c index 5963221..99e7404 100644 --- a/g10/free-packet.c +++ b/g10/free-packet.c @@ -28,7 +28,6 @@ #include "util.h" #include "packet.h" #include "../common/iobuf.h" -#include "cipher.h" #include "options.h" diff --git a/g10/gpg.c b/g10/gpg.c index 085f2e0..a770d74 100644 --- a/g10/gpg.c +++ b/g10/gpg.c @@ -45,7 +45,6 @@ #include "options.h" #include "keydb.h" #include "trustdb.h" -#include "cipher.h" #include "filter.h" #include "ttyio.h" #include "i18n.h" diff --git a/g10/gpg.h b/g10/gpg.h index 693f2cc..3251dd0 100644 --- a/g10/gpg.h +++ b/g10/gpg.h @@ -41,6 +41,15 @@ #define MAX_FINGERPRINT_LEN 20 + +/* + Macros formerly in cipher.h + */ + + + + + /* Forward declarations. */ diff --git a/g10/gpgv.c b/g10/gpgv.c index c11d9d3..debde9d 100644 --- a/g10/gpgv.c +++ b/g10/gpgv.c @@ -42,7 +42,6 @@ #include "options.h" #include "keydb.h" #include "trustdb.h" -#include "cipher.h" #include "filter.h" #include "ttyio.h" #include "i18n.h" diff --git a/g10/keydb.h b/g10/keydb.h index 39e7826..449d22e 100644 --- a/g10/keydb.h +++ b/g10/keydb.h @@ -26,7 +26,6 @@ #include "types.h" #include "util.h" #include "packet.h" -#include "cipher.h" /* What qualifies as a certification (rather than a signature?) */ #define IS_CERT(s) (IS_KEY_SIG(s) || IS_UID_SIG(s) || IS_SUBKEY_SIG(s) \ diff --git a/g10/keygen.c b/g10/keygen.c index 7582b0b..bbd02c5 100644 --- a/g10/keygen.c +++ b/g10/keygen.c @@ -33,7 +33,6 @@ #include "util.h" #include "main.h" #include "packet.h" -#include "cipher.h" #include "ttyio.h" #include "options.h" #include "keydb.h" diff --git a/g10/main.h b/g10/main.h index 1b619e0..4d3ab1b 100644 --- a/g10/main.h +++ b/g10/main.h @@ -22,7 +22,6 @@ #include "types.h" #include "iobuf.h" -#include "cipher.h" #include "keydb.h" #include "util.h" @@ -43,6 +42,9 @@ #define S2K_DIGEST_ALGO (opt.s2k_digest_algo?opt.s2k_digest_algo:DEFAULT_S2K_DIGEST_ALGO) + +/* Various data objects. */ + typedef struct { int header_okay; @@ -52,6 +54,7 @@ typedef struct cipher_filter_context_t cfx; } encrypt_filter_context_t; + struct groupitem { char *name; @@ -59,6 +62,7 @@ struct groupitem struct groupitem *next; }; + /*-- gpg.c --*/ extern int g10_errors_seen; diff --git a/g10/mainproc.c b/g10/mainproc.c index 18fe7e7..d8606cd 100644 --- a/g10/mainproc.c +++ b/g10/mainproc.c @@ -31,7 +31,6 @@ #include "packet.h" #include "iobuf.h" #include "options.h" -#include "cipher.h" #include "keydb.h" #include "filter.h" #include "main.h" diff --git a/g10/options.h b/g10/options.h index f9878bd..4a7eca2 100644 --- a/g10/options.h +++ b/g10/options.h @@ -302,7 +302,7 @@ EXTERN_UNLESS_MAIN_MODULE int memory_debug_mode; EXTERN_UNLESS_MAIN_MODULE int memory_stat_debug_mode; - +/* Compatibility flags. */ #define GNUPG (opt.compliance==CO_GNUPG) #define RFC1991 (opt.compliance==CO_RFC1991 || opt.compliance==CO_PGP2) #define RFC2440 (opt.compliance==CO_RFC2440) @@ -364,4 +364,5 @@ EXTERN_UNLESS_MAIN_MODULE int memory_stat_debug_mode; #define KEYSERVER_HONOR_KEYSERVER_URL (1<<4) #define KEYSERVER_HONOR_PKA_RECORD (1<<5) + #endif /*G10_OPTIONS_H*/ diff --git a/g10/packet.h b/g10/packet.h index b3956ef..b1b82d7 100644 --- a/g10/packet.h +++ b/g10/packet.h @@ -24,7 +24,7 @@ #include "types.h" #include "../common/iobuf.h" #include "../common/strlist.h" -#include "cipher.h" +#include "dek.h" #include "filter.h" #include "../common/openpgpdefs.h" #include "../common/userids.h" @@ -32,6 +32,31 @@ #define DEBUG_PARSE_PACKET 1 +/* Constants to allocate static MPI arrays. */ +#define PUBKEY_MAX_NPKEY 5 +#define PUBKEY_MAX_NSKEY 7 +#define PUBKEY_MAX_NSIG 2 +#define PUBKEY_MAX_NENC 2 + +/* Usage flags */ +#define PUBKEY_USAGE_SIG GCRY_PK_USAGE_SIGN /* Good for signatures. */ +#define PUBKEY_USAGE_ENC GCRY_PK_USAGE_ENCR /* Good for encryption. */ +#define PUBKEY_USAGE_CERT GCRY_PK_USAGE_CERT /* Also good to certify keys.*/ +#define PUBKEY_USAGE_AUTH GCRY_PK_USAGE_AUTH /* Good for authentication. */ +#define PUBKEY_USAGE_UNKNOWN GCRY_PK_USAGE_UNKN /* Unknown usage flag. */ +#define PUBKEY_USAGE_NONE 256 /* No usage given. */ +#if (GCRY_PK_USAGE_SIGN | GCRY_PK_USAGE_ENCR | GCRY_PK_USAGE_CERT \ + | GCRY_PK_USAGE_AUTH | GCRY_PK_USAGE_UNKN) >= 256 +# error Please choose another value for PUBKEY_USAGE_NONE +#endif + +/* Helper macros. */ +#define is_RSA(a) ((a)==PUBKEY_ALGO_RSA || (a)==PUBKEY_ALGO_RSA_E \ + || (a)==PUBKEY_ALGO_RSA_S ) +#define is_ELGAMAL(a) ((a)==PUBKEY_ALGO_ELGAMAL_E) +#define is_DSA(a) ((a)==PUBKEY_ALGO_DSA) + +/* A pointer to the packet object. */ typedef struct packet_struct PACKET; /* PKT_GPG_CONTROL types */ diff --git a/g10/parse-packet.c b/g10/parse-packet.c index f4390c3..32fbbd6 100644 --- a/g10/parse-packet.c +++ b/g10/parse-packet.c @@ -28,7 +28,6 @@ #include "util.h" #include "packet.h" #include "iobuf.h" -#include "cipher.h" #include "filter.h" #include "photoid.h" #include "options.h" diff --git a/g10/passphrase.c b/g10/passphrase.c index f83e668..bd0f0ff 100644 --- a/g10/passphrase.c +++ b/g10/passphrase.c @@ -37,7 +37,6 @@ #include "util.h" #include "options.h" #include "ttyio.h" -#include "cipher.h" #include "keydb.h" #include "main.h" #include "i18n.h" diff --git a/g10/pubkey-enc.c b/g10/pubkey-enc.c index 1e72557..ab18ed7 100644 --- a/g10/pubkey-enc.c +++ b/g10/pubkey-enc.c @@ -29,7 +29,6 @@ #include "packet.h" #include "keydb.h" #include "trustdb.h" -#include "cipher.h" #include "status.h" #include "options.h" #include "main.h" diff --git a/g10/seskey.c b/g10/seskey.c index e7f4997..7d04292 100644 --- a/g10/seskey.c +++ b/g10/seskey.c @@ -26,7 +26,6 @@ #include "gpg.h" #include "util.h" -#include "cipher.h" #include "options.h" #include "main.h" #include "i18n.h" diff --git a/g10/sig-check.c b/g10/sig-check.c index 134bcfa..a307533 100644 --- a/g10/sig-check.c +++ b/g10/sig-check.c @@ -28,7 +28,6 @@ #include "util.h" #include "packet.h" #include "keydb.h" -#include "cipher.h" #include "main.h" #include "status.h" #include "i18n.h" diff --git a/g10/skclist.c b/g10/skclist.c index 5a3ea95..53d6f77 100644 --- a/g10/skclist.c +++ b/g10/skclist.c @@ -32,7 +32,6 @@ #include "keydb.h" #include "util.h" #include "i18n.h" -#include "cipher.h" /* Return true if Libgcrypt's RNG is in faked mode. */ ----------------------------------------------------------------------- Summary of changes: agent/gpg-agent.c | 2 +- common/openpgpdefs.h | 62 +++++++++++++++++++++++++++ g10/Makefile.am | 2 +- g10/build-packet.c | 1 - g10/cipher.h | 108 ------------------------------------------------ g10/cpr.c | 1 - g10/decrypt-data.c | 1 - scd/atr.h => g10/dek.h | 22 ++++++---- g10/filter.h | 2 +- g10/free-packet.c | 1 - g10/gpg.c | 1 - g10/gpg.h | 9 ++++ g10/gpgv.c | 1 - g10/keydb.h | 1 - g10/keygen.c | 1 - g10/main.h | 6 ++- g10/mainproc.c | 1 - g10/options.h | 3 +- g10/packet.h | 27 +++++++++++- g10/parse-packet.c | 1 - g10/passphrase.c | 1 - g10/pubkey-enc.c | 1 - g10/seskey.c | 1 - g10/sig-check.c | 1 - g10/skclist.c | 1 - 25 files changed, 122 insertions(+), 136 deletions(-) delete mode 100644 g10/cipher.h copy scd/atr.h => g10/dek.h (66%) hooks/post-receive -- The GNU Privacy Guard http://git.gnupg.org From cvs at cvs.gnupg.org Thu Jan 30 18:50:19 2014 From: cvs at cvs.gnupg.org (by Werner Koch) Date: Thu, 30 Jan 2014 18:50:19 +0100 Subject: [git] GnuPG - branch, master, updated. gnupg-2.1.0beta3-293-gb7f8dec Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The GNU Privacy Guard". The branch, master has been updated via b7f8dec6325f1c80640f878ed3080bbc194fbc78 (commit) from ea8a1685f75d27f5277d42ea7390ad5aeaf51b1f (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit b7f8dec6325f1c80640f878ed3080bbc194fbc78 Author: Werner Koch Date: Thu Jan 30 18:48:37 2014 +0100 gpg: Use only OpenPGP public key algo ids and add the EdDSA algo id. * common/sexputil.c (get_pk_algo_from_canon_sexp): Change to return a string. * g10/keygen.c (check_keygrip): Adjust for change. * sm/certreqgen-ui.c (check_keygrip): Likewise. * agent/pksign.c (do_encode_dsa): Remove bogus map_pk_openpgp_to_gcry. * g10/misc.c (map_pk_openpgp_to_gcry): Remove. (openpgp_pk_test_algo): Change to a wrapper for openpgp_pk_test_algo2. (openpgp_pk_test_algo2): Rewrite. (openpgp_pk_algo_usage, pubkey_nbits): Add support for EdDSA. (openpgp_pk_algo_name): Rewrite to remove need for gcry calls. (pubkey_get_npkey, pubkey_get_nskey): Ditto. (pubkey_get_nsig, pubkey_get_nenc): Ditto. * g10/keygen.c(do_create_from_keygrip): Support EdDSA. (common_gen, gen_ecc, ask_keysize, generate_keypair): Ditto. * g10/build-packet.c (do_key): Ditto. * g10/export.c (transfer_format_to_openpgp): Ditto. * g10/getkey.c (cache_public_key): Ditto. * g10/import.c (transfer_secret_keys): Ditto. * g10/keylist.c (list_keyblock_print, list_keyblock_colon): Ditto. * g10/mainproc.c (proc_pubkey_enc): Ditto. * g10/parse-packet.c (parse_key): Ditto, * g10/sign.c (hash_for, sign_file, make_keysig_packet): Ditto. * g10/keyserver.c (print_keyrec): Use openpgp_pk_algo_name. * g10/pkglue.c (pk_verify, pk_encrypt, pk_check_secret_key): Use only OpenPGP algo ids and support EdDSA. * g10/pubkey-enc.c (get_it): Use only OpenPGP algo ids. * g10/seskey.c (encode_md_value): Ditto. -- This patch separates Libgcrypt and OpenPGP public key algorithms ids and in most cases completely removes the Libgcrypt ones. This is useful because for Libgcrypt we specify the algorithm in the S-expressions and the public key ids are not anymore needed. This patch also adds some support for PUBKEY_ALGO_EDDSA which will eventually be used instead of merging EdDSA with ECDSA. As of now an experimental algorithm id is used but the plan is to write an I-D so that we can get a new id from the IETF. Note that EdDSA (Ed25519) does not yet work and that more changes are required. The ECC support is still broken right now. Needs to be fixed. Signed-off-by: Werner Koch diff --git a/agent/pksign.c b/agent/pksign.c index b2ee28f..4d0a240 100644 --- a/agent/pksign.c +++ b/agent/pksign.c @@ -151,18 +151,15 @@ do_encode_eddsa (const byte *md, size_t mdlen, gcry_sexp_t *r_hash) /* Encode a message digest for use with an DSA algorithm. */ static gpg_error_t -do_encode_dsa (const byte *md, size_t mdlen, int dsaalgo, gcry_sexp_t pkey, +do_encode_dsa (const byte *md, size_t mdlen, int pkalgo, gcry_sexp_t pkey, gcry_sexp_t *r_hash) { gpg_error_t err; gcry_sexp_t hash; unsigned int qbits; - int pkalgo; *r_hash = NULL; - pkalgo = map_pk_openpgp_to_gcry (dsaalgo); - if (pkalgo == GCRY_PK_ECDSA) qbits = gcry_pk_get_nbits (pkey); else if (pkalgo == GCRY_PK_DSA) diff --git a/common/sexputil.c b/common/sexputil.c index e18756a..f15b94c 100644 --- a/common/sexputil.c +++ b/common/sexputil.c @@ -512,17 +512,18 @@ get_rsa_pk_from_canon_sexp (const unsigned char *keydata, size_t keydatalen, /* Return the algo of a public RSA expressed as an canonical encoded - S-expression. On error the algo is set to 0. */ + S-expression. The return value is a statically allocated + string. On error that string is set to NULL. */ gpg_error_t get_pk_algo_from_canon_sexp (const unsigned char *keydata, size_t keydatalen, - int *r_algo) + const char **r_algo) { gpg_error_t err; const unsigned char *buf, *tok; size_t buflen, toklen; int depth; - *r_algo = 0; + *r_algo = NULL; buf = keydata; buflen = keydatalen; @@ -541,15 +542,17 @@ get_pk_algo_from_canon_sexp (const unsigned char *keydata, size_t keydatalen, return gpg_error (GPG_ERR_BAD_PUBKEY); if (toklen == 3 && !memcmp ("rsa", tok, toklen)) - *r_algo = GCRY_PK_RSA; + *r_algo = "rsa"; else if (toklen == 3 && !memcmp ("dsa", tok, toklen)) - *r_algo = GCRY_PK_DSA; + *r_algo = "dsa"; else if (toklen == 3 && !memcmp ("elg", tok, toklen)) - *r_algo = GCRY_PK_ELG; + *r_algo = "elg"; else if (toklen == 5 && !memcmp ("ecdsa", tok, toklen)) - *r_algo = GCRY_PK_ECDSA; + *r_algo = "ecdsa"; + else if (toklen == 5 && !memcmp ("eddsa", tok, toklen)) + *r_algo = "eddsa"; else - return gpg_error (GPG_ERR_PUBKEY_ALGO); + return gpg_error (GPG_ERR_PUBKEY_ALGO); return 0; } diff --git a/common/util.h b/common/util.h index f938888..c4acb0b 100644 --- a/common/util.h +++ b/common/util.h @@ -193,7 +193,7 @@ gpg_error_t get_rsa_pk_from_canon_sexp (const unsigned char *keydata, size_t *r_elen); gpg_error_t get_pk_algo_from_canon_sexp (const unsigned char *keydata, size_t keydatalen, - int *r_algo); + const char **r_algo); /*-- convert.c --*/ int hex2bin (const char *string, void *buffer, size_t length); diff --git a/g10/build-packet.c b/g10/build-packet.c index f31ca88..7464979 100644 --- a/g10/build-packet.c +++ b/g10/build-packet.c @@ -329,8 +329,9 @@ do_key (iobuf_t out, int ctb, PKT_public_key *pk) for (i=0; i < npkey; i++ ) { - if ((pk->pubkey_algo == PUBKEY_ALGO_ECDSA && (i == 0)) - || ((pk->pubkey_algo == PUBKEY_ALGO_ECDH) && (i == 0 || i == 2))) + if ( (pk->pubkey_algo == PUBKEY_ALGO_ECDSA && (i == 0)) + || (pk->pubkey_algo == PUBKEY_ALGO_EDDSA && (i == 0)) + || (pk->pubkey_algo == PUBKEY_ALGO_ECDH && (i == 0 || i == 2))) err = gpg_mpi_write_nohdr (a, pk->pkey[i]); else err = gpg_mpi_write (a, pk->pkey[i]); diff --git a/g10/export.c b/g10/export.c index 01bdd5e..a7d1cf8 100644 --- a/g10/export.c +++ b/g10/export.c @@ -561,7 +561,9 @@ transfer_format_to_openpgp (gcry_sexp_t s_pgp, PKT_public_key *pk) /* We need to change the received parameters for ECC algorithms. The transfer format has all parameters but OpenPGP defines that only the OID of the curve is to be used. */ - if (pubkey_algo == PUBKEY_ALGO_ECDSA || pubkey_algo == PUBKEY_ALGO_ECDH) + if (pubkey_algo == PUBKEY_ALGO_ECDSA + || pubkey_algo == PUBKEY_ALGO_EDDSA + || pubkey_algo == PUBKEY_ALGO_ECDH) { gcry_sexp_t s_pubkey; const char *curvename, *curveoidstr; diff --git a/g10/getkey.c b/g10/getkey.c index 4453a92..9cad71b 100644 --- a/g10/getkey.c +++ b/g10/getkey.c @@ -140,6 +140,7 @@ cache_public_key (PKT_public_key * pk) if (is_ELGAMAL (pk->pubkey_algo) || pk->pubkey_algo == PUBKEY_ALGO_DSA || pk->pubkey_algo == PUBKEY_ALGO_ECDSA + || pk->pubkey_algo == PUBKEY_ALGO_EDDSA || pk->pubkey_algo == PUBKEY_ALGO_ECDH || is_RSA (pk->pubkey_algo)) { diff --git a/g10/import.c b/g10/import.c index 3846c21..7ba7303 100644 --- a/g10/import.c +++ b/g10/import.c @@ -1260,6 +1260,7 @@ transfer_secret_keys (ctrl_t ctrl, struct stats_s *stats, kbnode_t sec_keyblock) init_membuf (&mbuf, 50); put_membuf_str (&mbuf, "(skey"); if (pk->pubkey_algo == PUBKEY_ALGO_ECDSA + || pk->pubkey_algo == PUBKEY_ALGO_EDDSA || pk->pubkey_algo == PUBKEY_ALGO_ECDH) { /* We need special treatment for ECC algorithms. OpenPGP @@ -1274,7 +1275,7 @@ transfer_secret_keys (ctrl_t ctrl, struct stats_s *stats, kbnode_t sec_keyblock) err = gpg_error_from_syserror (); else { - gcry_sexp_t cparam = gcry_pk_get_param (GCRY_PK_ECDSA, curve); + gcry_sexp_t cparam = gcry_pk_get_param (GCRY_PK_ECC, curve); xfree (curve); if (!cparam) diff --git a/g10/keygen.c b/g10/keygen.c index bbd02c5..50919fd 100644 --- a/g10/keygen.c +++ b/g10/keygen.c @@ -1235,6 +1235,7 @@ do_create_from_keygrip (ctrl_t ctrl, int algo, const char *hexkeygrip, case PUBKEY_ALGO_ELGAMAL_E: algoelem = "pgy"; break; case PUBKEY_ALGO_ECDH: case PUBKEY_ALGO_ECDSA: algoelem = ""; break; + case PUBKEY_ALGO_EDDSA: algoelem = ""; break; default: return gpg_error (GPG_ERR_INTERNAL); } @@ -1268,7 +1269,9 @@ do_create_from_keygrip (ctrl_t ctrl, int algo, const char *hexkeygrip, pk->expiredate = pk->timestamp + expireval; pk->pubkey_algo = algo; - if (algo == PUBKEY_ALGO_ECDSA || algo == PUBKEY_ALGO_ECDH) + if (algo == PUBKEY_ALGO_ECDSA + || algo == PUBKEY_ALGO_EDDSA + || algo == PUBKEY_ALGO_ECDH ) err = ecckey_from_sexp (pk->pkey, s_key, algo); else err = key_from_sexp (pk->pkey, s_key, "public-key", algoelem); @@ -1330,7 +1333,9 @@ common_gen (const char *keyparms, int algo, const char *algoelem, pk->expiredate = pk->timestamp + expireval; pk->pubkey_algo = algo; - if (algo == PUBKEY_ALGO_ECDSA || algo == PUBKEY_ALGO_ECDH) + if (algo == PUBKEY_ALGO_ECDSA + || algo == PUBKEY_ALGO_EDDSA + || algo == PUBKEY_ALGO_ECDH ) err = ecckey_from_sexp (pk->pkey, s_key, algo); else err = key_from_sexp (pk->pkey, s_key, "public-key", algoelem); @@ -1508,7 +1513,9 @@ gen_ecc (int algo, const char *curve, kbnode_t pub_root, gpg_error_t err; char *keyparms; - assert (algo == PUBKEY_ALGO_ECDSA || algo == PUBKEY_ALGO_ECDH); + assert (algo == PUBKEY_ALGO_ECDSA + || algo == PUBKEY_ALGO_EDDSA + || algo == PUBKEY_ALGO_ECDH); if (!curve || !*curve) return gpg_error (GPG_ERR_UNKNOWN_CURVE); @@ -1735,7 +1742,7 @@ check_keygrip (ctrl_t ctrl, const char *hexgrip) gpg_error_t err; unsigned char *public; size_t publiclen; - int algo; + const char *algostr; if (hexgrip[0] == '&') hexgrip++; @@ -1745,18 +1752,26 @@ check_keygrip (ctrl_t ctrl, const char *hexgrip) return 0; publiclen = gcry_sexp_canon_len (public, 0, NULL, NULL); - get_pk_algo_from_canon_sexp (public, publiclen, &algo); + get_pk_algo_from_canon_sexp (public, publiclen, &algostr); xfree (public); - switch (algo) - { - case GCRY_PK_RSA: return PUBKEY_ALGO_RSA; - case GCRY_PK_DSA: return PUBKEY_ALGO_DSA; - case GCRY_PK_ELG_E: return PUBKEY_ALGO_ELGAMAL_E; - case GCRY_PK_ECDH: return PUBKEY_ALGO_ECDH; - case GCRY_PK_ECDSA: return PUBKEY_ALGO_ECDSA; - default: return 0; - } + /* FIXME: Mapping of ECC algorithms is probably not correct. */ + if (!algostr) + return 0; + else if (!strcmp (algostr, "rsa")) + return PUBKEY_ALGO_RSA; + else if (!strcmp (algostr, "dsa")) + return PUBKEY_ALGO_DSA; + else if (!strcmp (algostr, "elg")) + return PUBKEY_ALGO_ELGAMAL_E; + else if (!strcmp (algostr, "ecc")) + return PUBKEY_ALGO_ECDH; + else if (!strcmp (algostr, "ecdsa")) + return PUBKEY_ALGO_ECDSA; + else if (!strcmp (algostr, "eddsa")) + return PUBKEY_ALGO_EDDSA; + else + return 0; } @@ -1803,13 +1818,13 @@ ask_algo (ctrl_t ctrl, int addmode, int *r_subkey_algo, unsigned int *r_usage, } if (opt.expert && !addmode) - tty_printf (_(" (%d) ECDSA and ECDH\n"), 9 ); + tty_printf (_(" (%d) ECC\n"), 9 ); if (opt.expert) - tty_printf (_(" (%d) ECDSA (sign only)\n"), 10 ); + tty_printf (_(" (%d) ECC (sign only)\n"), 10 ); if (opt.expert) - tty_printf (_(" (%d) ECDSA (set your own capabilities)\n"), 11 ); + tty_printf (_(" (%d) ECC (set your own capabilities)\n"), 11 ); if (opt.expert && addmode) - tty_printf (_(" (%d) ECDH (encrypt only)\n"), 12 ); + tty_printf (_(" (%d) ECC (encrypt only)\n"), 12 ); if (opt.expert && r_keygrip) tty_printf (_(" (%d) Existing key\n"), 13 ); @@ -1978,6 +1993,12 @@ ask_keysize (int algo, unsigned int primary_keysize) max=521; break; + case PUBKEY_ALGO_EDDSA: + min=255; + def=255; + max=441; + break; + case PUBKEY_ALGO_RSA: min=1024; break; @@ -2017,6 +2038,18 @@ ask_keysize (int algo, unsigned int primary_keysize) if (!autocomp) tty_printf (_("rounded up to %u bits\n"), nbits); } + else if (algo == PUBKEY_ALGO_EDDSA) + { + if (nbits != 255 && nbits != 441) + { + if (nbits < 256) + nbits = 255; + else + nbits = 441; + if (!autocomp) + tty_printf (_("rounded to %u bits\n"), nbits); + } + } else if (algo == PUBKEY_ALGO_ECDH || algo == PUBKEY_ALGO_ECDSA) { if (nbits != 256 && nbits != 384 && nbits != 521) @@ -2613,7 +2646,9 @@ do_create (int algo, unsigned int nbits, const char *curve, KBNODE pub_root, else if (algo == PUBKEY_ALGO_DSA) err = gen_dsa (nbits, pub_root, timestamp, expiredate, is_subkey, keygen_flags, cache_nonce_addr); - else if (algo == PUBKEY_ALGO_ECDSA || algo == PUBKEY_ALGO_ECDH) + else if (algo == PUBKEY_ALGO_ECDSA + || algo == PUBKEY_ALGO_EDDSA + || algo == PUBKEY_ALGO_ECDH) err = gen_ecc (algo, curve, pub_root, timestamp, expiredate, is_subkey, keygen_flags, cache_nonce_addr); else if (algo == PUBKEY_ALGO_RSA) @@ -3410,9 +3445,12 @@ generate_keypair (ctrl_t ctrl, const char *fname, const char *card_serialno, sprintf( r->u.value, "%d", algo ); r->next = para; para = r; - if (algo == PUBKEY_ALGO_ECDSA || algo == PUBKEY_ALGO_ECDH) + if (algo == PUBKEY_ALGO_ECDSA + || algo == PUBKEY_ALGO_EDDSA + || algo == PUBKEY_ALGO_ECDH) { curve = ask_curve (); + nbits = 0; r = xmalloc_clear (sizeof *r + strlen (curve)); r->key = pKEYCURVE; strcpy (r->u.value, curve); @@ -3467,7 +3505,9 @@ generate_keypair (ctrl_t ctrl, const char *fname, const char *card_serialno, nbits = 0; } - if (algo == PUBKEY_ALGO_ECDSA || algo == PUBKEY_ALGO_ECDH) + if (algo == PUBKEY_ALGO_ECDSA + || algo == PUBKEY_ALGO_EDDSA + || algo == PUBKEY_ALGO_ECDH) { if (!both) curve = ask_curve (); @@ -3969,7 +4009,9 @@ generate_subkeypair (ctrl_t ctrl, kbnode_t keyblock) if (hexgrip) nbits = 0; - else if (algo == PUBKEY_ALGO_ECDSA || algo == PUBKEY_ALGO_ECDH) + else if (algo == PUBKEY_ALGO_ECDSA + || algo == PUBKEY_ALGO_EDDSA + || algo == PUBKEY_ALGO_ECDH) curve = ask_curve (); else nbits = ask_keysize (algo, 0); diff --git a/g10/keyid.c b/g10/keyid.c index d08ccee..5fa44ef 100644 --- a/g10/keyid.c +++ b/g10/keyid.c @@ -57,6 +57,7 @@ pubkey_letter( int algo ) case PUBKEY_ALGO_ELGAMAL_E: return 'g' ; case PUBKEY_ALGO_ELGAMAL: return 'G' ; case PUBKEY_ALGO_DSA: return 'D' ; + case PUBKEY_ALGO_EDDSA: return 'E' ; /* ECC EdDSA (sign only) */ case PUBKEY_ALGO_ECDSA: return 'E' ; /* ECC DSA (sign only) */ case PUBKEY_ALGO_ECDH: return 'e' ; /* ECC DH (encrypt only) */ default: return '?'; @@ -733,6 +734,7 @@ keygrip_from_pk (PKT_public_key *pk, unsigned char *array) pk->pkey[0], pk->pkey[1]); break; + case PUBKEY_ALGO_EDDSA: case PUBKEY_ALGO_ECDSA: case PUBKEY_ALGO_ECDH: { diff --git a/g10/keylist.c b/g10/keylist.c index 356fac3..9a96c87 100644 --- a/g10/keylist.c +++ b/g10/keylist.c @@ -818,6 +818,7 @@ list_keyblock_print (KBNODE keyblock, int secret, int fpr, void *opaque) keystr_from_pk (pk), datestr_from_pk (pk)); if (pk->pubkey_algo == PUBKEY_ALGO_ECDSA + || pk->pubkey_algo == PUBKEY_ALGO_EDDSA || pk->pubkey_algo == PUBKEY_ALGO_ECDH) { char *curve = openpgp_oid_to_str (pk->pkey[0]); @@ -953,6 +954,7 @@ list_keyblock_print (KBNODE keyblock, int secret, int fpr, void *opaque) keystr_from_pk (pk2), datestr_from_pk (pk2)); if (pk2->pubkey_algo == PUBKEY_ALGO_ECDSA + || pk2->pubkey_algo == PUBKEY_ALGO_EDDSA || pk2->pubkey_algo == PUBKEY_ALGO_ECDH) { char *curve = openpgp_oid_to_str (pk2->pkey[0]); @@ -1207,6 +1209,7 @@ list_keyblock_colon (KBNODE keyblock, int secret, int fpr) es_putc (':', es_stdout); /* End of field 15. */ es_putc (':', es_stdout); /* End of field 16. */ if (pk->pubkey_algo == PUBKEY_ALGO_ECDSA + || pk->pubkey_algo == PUBKEY_ALGO_EDDSA || pk->pubkey_algo == PUBKEY_ALGO_ECDH) { char *curve = openpgp_oid_to_str (pk->pkey[0]); @@ -1332,6 +1335,7 @@ list_keyblock_colon (KBNODE keyblock, int secret, int fpr) es_putc (':', es_stdout); /* End of field 15. */ es_putc (':', es_stdout); /* End of field 16. */ if (pk->pubkey_algo == PUBKEY_ALGO_ECDSA + || pk->pubkey_algo == PUBKEY_ALGO_EDDSA || pk->pubkey_algo == PUBKEY_ALGO_ECDH) { char *curve = openpgp_oid_to_str (pk->pkey[0]); diff --git a/g10/keyserver.c b/g10/keyserver.c index 0ec616b..0f60f7d 100644 --- a/g10/keyserver.c +++ b/g10/keyserver.c @@ -508,7 +508,7 @@ print_keyrec(int number,struct keyrec *keyrec) { const char *str; - str = gcry_pk_algo_name (map_pk_openpgp_to_gcry (keyrec->type)); + str = openpgp_pk_algo_name (keyrec->type); if (str && strcmp (str, "?")) es_printf ("%s ",str); diff --git a/g10/main.h b/g10/main.h index 4d3ab1b..26283a7 100644 --- a/g10/main.h +++ b/g10/main.h @@ -100,13 +100,12 @@ int map_cipher_openpgp_to_gcry (int algo); int openpgp_cipher_blocklen (int algo); int openpgp_cipher_test_algo( int algo ); const char *openpgp_cipher_algo_name (int algo); -int map_pk_openpgp_to_gcry (int algo); int map_pk_gcry_to_openpgp (enum gcry_pk_algos algo); -int openpgp_pk_test_algo( int algo ); -int openpgp_pk_test_algo2 ( int algo, unsigned int use ); +int openpgp_pk_test_algo (pubkey_algo_t algo); +int openpgp_pk_test_algo2 (pubkey_algo_t algo, unsigned int use); int openpgp_pk_algo_usage ( int algo ); int openpgp_md_test_algo( int algo ); -const char *openpgp_pk_algo_name (int algo); +const char *openpgp_pk_algo_name (pubkey_algo_t algo); const char *openpgp_md_algo_name (int algo); struct expando_args @@ -153,10 +152,10 @@ int is_valid_mailbox (const char *name); const char *get_libexecdir (void); int path_access(const char *file,int mode); -int pubkey_get_npkey( int algo ); -int pubkey_get_nskey( int algo ); -int pubkey_get_nsig( int algo ); -int pubkey_get_nenc( int algo ); +int pubkey_get_npkey (pubkey_algo_t algo); +int pubkey_get_nskey (pubkey_algo_t algo); +int pubkey_get_nsig (pubkey_algo_t algo); +int pubkey_get_nenc (pubkey_algo_t algo); /* Temporary helpers. */ unsigned int pubkey_nbits( int algo, gcry_mpi_t *pkey ); diff --git a/g10/mainproc.c b/g10/mainproc.c index d8606cd..5f8d119 100644 --- a/g10/mainproc.c +++ b/g10/mainproc.c @@ -389,6 +389,7 @@ proc_pubkey_enc( CTX c, PACKET *pkt ) else if( is_ELGAMAL(enc->pubkey_algo) || enc->pubkey_algo == PUBKEY_ALGO_DSA || enc->pubkey_algo == PUBKEY_ALGO_ECDSA + || enc->pubkey_algo == PUBKEY_ALGO_EDDSA || enc->pubkey_algo == PUBKEY_ALGO_ECDH || is_RSA(enc->pubkey_algo) || enc->pubkey_algo == PUBKEY_ALGO_ELGAMAL) { diff --git a/g10/misc.c b/g10/misc.c index 9f6ff1e..1ac5430 100644 --- a/g10/misc.c +++ b/g10/misc.c @@ -366,21 +366,9 @@ map_cipher_gcry_to_openpgp (int algo) } } -/* Map OpenPGP public key algorithm numbers to those used by - Libgcrypt. */ -int -map_pk_openpgp_to_gcry (int algo) -{ - switch (algo) - { - case PUBKEY_ALGO_ECDSA: return GCRY_PK_ECDSA; - case PUBKEY_ALGO_ECDH: return GCRY_PK_ECDH; - default: return algo; - } -} - -/* Map Gcrypt public key algorithm numbers to those used by - OpenPGP. */ +/* Map Gcrypt public key algorithm numbers to those used by OpenPGP. + FIXME: This mapping is used at only two places - we should get rid + of it. */ int map_pk_gcry_to_openpgp (enum gcry_pk_algos algo) { @@ -439,41 +427,49 @@ openpgp_cipher_algo_name (int algo) return gnupg_cipher_algo_name (map_cipher_openpgp_to_gcry (algo)); } + +/* Return 0 if ALGO is a supported OpenPGP public key algorithm. */ int -openpgp_pk_test_algo( int algo ) +openpgp_pk_test_algo (pubkey_algo_t algo) { - /* Dont't allow type 20 keys unless in rfc2440 mode. */ - if (!RFC2440 && algo == 20) - return gpg_error (GPG_ERR_PUBKEY_ALGO); - - if (algo == GCRY_PK_ELG_E) - algo = GCRY_PK_ELG; - - if (algo < 0 || algo > 110) - return gpg_error (GPG_ERR_PUBKEY_ALGO); - - return gcry_pk_test_algo (map_pk_openpgp_to_gcry (algo)); + return openpgp_pk_test_algo2 (algo, 0); } + +/* Return 0 if ALGO is a supported OpenPGP public key algorithm and + allows the usage USE. */ int -openpgp_pk_test_algo2( int algo, unsigned int use ) +openpgp_pk_test_algo2 (pubkey_algo_t algo, unsigned int use) { + enum gcry_pk_algos ga = 0; size_t use_buf = use; - /* Dont't allow type 20 keys unless in rfc2440 mode. */ - if (!RFC2440 && algo == 20) - return gpg_error (GPG_ERR_PUBKEY_ALGO); - - if (algo == GCRY_PK_ELG_E) - algo = GCRY_PK_ELG; - - if (algo < 0 || algo > 110) + switch (algo) + { + case PUBKEY_ALGO_RSA: ga = GCRY_PK_RSA; break; + case PUBKEY_ALGO_RSA_E: ga = GCRY_PK_RSA_E; break; + case PUBKEY_ALGO_RSA_S: ga = GCRY_PK_RSA_S; break; + case PUBKEY_ALGO_ELGAMAL_E: ga = GCRY_PK_ELG; break; + case PUBKEY_ALGO_DSA: ga = GCRY_PK_DSA; break; + + case PUBKEY_ALGO_ECDH: + case PUBKEY_ALGO_ECDSA: + case PUBKEY_ALGO_EDDSA: ga = GCRY_PK_ECC; break; + + case PUBKEY_ALGO_ELGAMAL: + /* Dont't allow type 20 keys unless in rfc2440 mode. */ + if (RFC2440) + ga = GCRY_PK_ELG; + break; + } + if (!ga) return gpg_error (GPG_ERR_PUBKEY_ALGO); - return gcry_pk_algo_info (map_pk_openpgp_to_gcry (algo), - GCRYCTL_TEST_ALGO, NULL, &use_buf); + /* No check whether Libgcrypt has support for the algorithm. */ + return gcry_pk_algo_info (ga, GCRYCTL_TEST_ALGO, NULL, &use_buf); } + int openpgp_pk_algo_usage ( int algo ) { @@ -503,6 +499,7 @@ openpgp_pk_algo_usage ( int algo ) use = PUBKEY_USAGE_CERT | PUBKEY_USAGE_SIG | PUBKEY_USAGE_AUTH; break; case PUBKEY_ALGO_ECDSA: + case PUBKEY_ALGO_EDDSA: use = PUBKEY_USAGE_CERT | PUBKEY_USAGE_SIG | PUBKEY_USAGE_AUTH; default: break; @@ -514,9 +511,21 @@ openpgp_pk_algo_usage ( int algo ) string representation of the algorithm name. For unknown algorithm IDs this function returns "?". */ const char * -openpgp_pk_algo_name (int algo) +openpgp_pk_algo_name (pubkey_algo_t algo) { - return gcry_pk_algo_name (map_pk_openpgp_to_gcry (algo)); + switch (algo) + { + case PUBKEY_ALGO_RSA: + case PUBKEY_ALGO_RSA_E: + case PUBKEY_ALGO_RSA_S: return "RSA"; + case PUBKEY_ALGO_ELGAMAL: + case PUBKEY_ALGO_ELGAMAL_E: return "ELG"; + case PUBKEY_ALGO_DSA: return "DSA"; + case PUBKEY_ALGO_ECDH: + case PUBKEY_ALGO_ECDSA: + case PUBKEY_ALGO_EDDSA: return "ECC"; + } + return "?"; } @@ -1346,94 +1355,80 @@ path_access(const char *file,int mode) /* Return the number of public key parameters as used by OpenPGP. */ int -pubkey_get_npkey (int algo) +pubkey_get_npkey (pubkey_algo_t algo) { - size_t n; - - /* ECC is special. */ - if (algo == PUBKEY_ALGO_ECDSA) - return 2; - else if (algo == PUBKEY_ALGO_ECDH) - return 3; - - /* All other algorithms match those of Libgcrypt. */ - if (algo == GCRY_PK_ELG_E) - algo = GCRY_PK_ELG; - else if (is_RSA (algo)) - algo = GCRY_PK_RSA; - - if (gcry_pk_algo_info (algo, GCRYCTL_GET_ALGO_NPKEY, NULL, &n)) - n = 0; - return n; + switch (algo) + { + case PUBKEY_ALGO_RSA: + case PUBKEY_ALGO_RSA_E: + case PUBKEY_ALGO_RSA_S: return 2; + case PUBKEY_ALGO_ELGAMAL_E: return 3; + case PUBKEY_ALGO_DSA: return 4; + case PUBKEY_ALGO_ECDH: return 3; + case PUBKEY_ALGO_ECDSA: return 2; + case PUBKEY_ALGO_ELGAMAL: return 3; + case PUBKEY_ALGO_EDDSA: return 2; + } + return 0; } /* Return the number of secret key parameters as used by OpenPGP. */ int -pubkey_get_nskey (int algo) +pubkey_get_nskey (pubkey_algo_t algo) { - size_t n; - - /* ECC is special. */ - if (algo == PUBKEY_ALGO_ECDSA) - return 3; - else if (algo == PUBKEY_ALGO_ECDH) - return 4; - - /* All other algorithms match those of Libgcrypt. */ - if (algo == GCRY_PK_ELG_E) - algo = GCRY_PK_ELG; - else if (is_RSA (algo)) - algo = GCRY_PK_RSA; - - if (gcry_pk_algo_info( algo, GCRYCTL_GET_ALGO_NSKEY, NULL, &n )) - n = 0; - return n; + switch (algo) + { + case PUBKEY_ALGO_RSA: + case PUBKEY_ALGO_RSA_E: + case PUBKEY_ALGO_RSA_S: return 6; + case PUBKEY_ALGO_ELGAMAL_E: return 4; + case PUBKEY_ALGO_DSA: return 5; + case PUBKEY_ALGO_ECDH: return 4; + case PUBKEY_ALGO_ECDSA: return 3; + case PUBKEY_ALGO_ELGAMAL: return 4; + case PUBKEY_ALGO_EDDSA: return 3; + } + return 0; } /* Temporary helper. */ int -pubkey_get_nsig (int algo) +pubkey_get_nsig (pubkey_algo_t algo) { - size_t n; - - /* ECC is special. */ - if (algo == PUBKEY_ALGO_ECDSA) - return 2; - else if (algo == PUBKEY_ALGO_ECDH) - return 0; - - if (algo == GCRY_PK_ELG_E) - algo = GCRY_PK_ELG; - else if (is_RSA (algo)) - algo = GCRY_PK_RSA; - - if (gcry_pk_algo_info( algo, GCRYCTL_GET_ALGO_NSIGN, NULL, &n)) - n = 0; - return n; + switch (algo) + { + case PUBKEY_ALGO_RSA: + case PUBKEY_ALGO_RSA_E: + case PUBKEY_ALGO_RSA_S: return 1; + case PUBKEY_ALGO_ELGAMAL_E: return 0; + case PUBKEY_ALGO_DSA: return 2; + case PUBKEY_ALGO_ECDH: return 0; + case PUBKEY_ALGO_ECDSA: return 2; + case PUBKEY_ALGO_ELGAMAL: return 2; + case PUBKEY_ALGO_EDDSA: return 2; + } + return 0; } /* Temporary helper. */ int -pubkey_get_nenc (int algo) +pubkey_get_nenc (pubkey_algo_t algo) { - size_t n; - - /* ECC is special. */ - if (algo == PUBKEY_ALGO_ECDSA) - return 0; - else if (algo == PUBKEY_ALGO_ECDH) - return 2; - - if (algo == GCRY_PK_ELG_E) - algo = GCRY_PK_ELG; - else if (is_RSA (algo)) - algo = GCRY_PK_RSA; - - if (gcry_pk_algo_info( algo, GCRYCTL_GET_ALGO_NENCR, NULL, &n )) - n = 0; - return n; + switch (algo) + { + case PUBKEY_ALGO_RSA: + case PUBKEY_ALGO_RSA_E: + case PUBKEY_ALGO_RSA_S: return 1; + case PUBKEY_ALGO_ELGAMAL_E: return 2; + case PUBKEY_ALGO_DSA: return 0; + case PUBKEY_ALGO_ECDH: return 2; + case PUBKEY_ALGO_ECDSA: return 0; + case PUBKEY_ALGO_ELGAMAL: return 2; + case PUBKEY_ALGO_EDDSA: return 0; + } + return 0; } @@ -1459,7 +1454,8 @@ pubkey_nbits( int algo, gcry_mpi_t *key ) "(public-key(rsa(n%m)(e%m)))", key[0], key[1] ); } - else if( algo == PUBKEY_ALGO_ECDSA || algo == PUBKEY_ALGO_ECDH ) { + else if (algo == PUBKEY_ALGO_ECDSA || algo == PUBKEY_ALGO_ECDH + || algo == PUBKEY_ALGO_EDDSA) { char *curve = openpgp_oid_to_str (key[0]); if (!curve) rc = gpg_error_from_syserror (); diff --git a/g10/parse-packet.c b/g10/parse-packet.c index 32fbbd6..f708788 100644 --- a/g10/parse-packet.c +++ b/g10/parse-packet.c @@ -1989,9 +1989,11 @@ parse_key (IOBUF inp, int pkttype, unsigned long pktlen, { for (i = 0; i < npkey; i++) { - if ((algorithm == PUBKEY_ALGO_ECDSA && (i == 0)) - || ((algorithm == PUBKEY_ALGO_ECDH) && (i == 0 || i == 2))) + if ( (algorithm == PUBKEY_ALGO_ECDSA && (i == 0)) + || (algorithm == PUBKEY_ALGO_EDDSA && (i == 0)) + || (algorithm == PUBKEY_ALGO_ECDH && (i == 0 || i == 2))) { + /* Read the OID (i==1) or the KDF params (i==2). */ size_t n; err = read_size_body (inp, pktlen, &n, pk->pkey+i); pktlen -= n; @@ -2011,6 +2013,7 @@ parse_key (IOBUF inp, int pkttype, unsigned long pktlen, es_fprintf (listfp, "\tpkey[%d]: ", i); mpi_print (listfp, pk->pkey[i], mpi_print_mode); if ((algorithm == PUBKEY_ALGO_ECDSA + || algorithm == PUBKEY_ALGO_EDDSA || algorithm == PUBKEY_ALGO_ECDH) && i==0) { char *curve = openpgp_oid_to_str (pk->pkey[0]); diff --git a/g10/pkglue.c b/g10/pkglue.c index 7e50a1c..67d2efd 100644 --- a/g10/pkglue.c +++ b/g10/pkglue.c @@ -1,5 +1,6 @@ /* pkglue.c - public key operations glue code - * Copyright (C) 2000, 2003, 2010 Free Software Foundation, Inc. + * Copyright (C) 2000, 2003, 2010 Free Software Foundation, Inc. + * Copyright (C) 2014 Werner Koch * * This file is part of GnuPG. * @@ -53,51 +54,55 @@ get_mpi_from_sexp (gcry_sexp_t sexp, const char *item, int mpifmt) * change the internal design to directly fit to libgcrypt. */ int -pk_verify (int algo, gcry_mpi_t hash, gcry_mpi_t *data, gcry_mpi_t *pkey) +pk_verify (pubkey_algo_t pkalgo, gcry_mpi_t hash, + gcry_mpi_t *data, gcry_mpi_t *pkey) { gcry_sexp_t s_sig, s_hash, s_pkey; int rc; - const int pkalgo = map_pk_openpgp_to_gcry (algo); - int is_ed25519 = 0; /* Make a sexp from pkey. */ - if (pkalgo == GCRY_PK_DSA) + if (pkalgo == PUBKEY_ALGO_DSA) { rc = gcry_sexp_build (&s_pkey, NULL, "(public-key(dsa(p%m)(q%m)(g%m)(y%m)))", pkey[0], pkey[1], pkey[2], pkey[3]); } - else if (pkalgo == GCRY_PK_ELG || pkalgo == GCRY_PK_ELG_E) + else if (pkalgo == PUBKEY_ALGO_ELGAMAL_E || pkalgo == PUBKEY_ALGO_ELGAMAL) { rc = gcry_sexp_build (&s_pkey, NULL, "(public-key(elg(p%m)(g%m)(y%m)))", pkey[0], pkey[1], pkey[2]); } - else if (pkalgo == GCRY_PK_RSA || pkalgo == GCRY_PK_RSA_S) + else if (pkalgo == PUBKEY_ALGO_RSA || pkalgo == PUBKEY_ALGO_RSA_S) { rc = gcry_sexp_build (&s_pkey, NULL, "(public-key(rsa(n%m)(e%m)))", pkey[0], pkey[1]); } - else if (pkalgo == GCRY_PK_ECDSA) /* Same as GCRY_PK_ECDH */ + else if (pkalgo == PUBKEY_ALGO_ECDSA) { - is_ed25519 = openpgp_oid_is_ed25519 (pkey[0]); - if (is_ed25519) - rc = gcry_sexp_build (&s_pkey, NULL, - "(public-key(ecc(curve Ed25519)" - "(flags eddsa)(q%m)))", - pkey[1]); + char *curve = openpgp_oid_to_str (pkey[0]); + if (!curve) + rc = gpg_error_from_syserror (); + else + { + rc = gcry_sexp_build (&s_pkey, NULL, + "(public-key(ecdsa(curve %s)(q%m)))", + curve, pkey[1]); + xfree (curve); + } + } + else if (pkalgo == PUBKEY_ALGO_EDDSA) + { + char *curve = openpgp_oid_to_str (pkey[0]); + if (!curve) + rc = gpg_error_from_syserror (); else { - char *curve = openpgp_oid_to_str (pkey[0]); - if (!curve) - rc = gpg_error_from_syserror (); - else - { - rc = gcry_sexp_build (&s_pkey, NULL, - "(public-key(ecdsa(curve %s)(q%m)))", - curve, pkey[1]); - xfree (curve); - } + rc = gcry_sexp_build (&s_pkey, NULL, + "(public-key(ecc(curve %s)" + "(flags eddsa)(q%m)))", + curve, pkey[1]); + xfree (curve); } } else @@ -107,7 +112,7 @@ pk_verify (int algo, gcry_mpi_t hash, gcry_mpi_t *data, gcry_mpi_t *pkey) BUG (); /* gcry_sexp_build should never fail. */ /* Put hash into a S-Exp s_hash. */ - if (is_ed25519) + if (pkalgo == PUBKEY_ALGO_EDDSA) { if (gcry_sexp_build (&s_hash, NULL, "(data(flags eddsa)(hash-algo sha512)(value %m))", @@ -122,7 +127,7 @@ pk_verify (int algo, gcry_mpi_t hash, gcry_mpi_t *data, gcry_mpi_t *pkey) /* Put data into a S-Exp s_sig. */ s_sig = NULL; - if (pkalgo == GCRY_PK_DSA) + if (pkalgo == PUBKEY_ALGO_DSA) { if (!data[0] || !data[1]) rc = gpg_error (GPG_ERR_BAD_MPI); @@ -130,18 +135,23 @@ pk_verify (int algo, gcry_mpi_t hash, gcry_mpi_t *data, gcry_mpi_t *pkey) rc = gcry_sexp_build (&s_sig, NULL, "(sig-val(dsa(r%m)(s%m)))", data[0], data[1]); } - else if (pkalgo == GCRY_PK_ECDSA) + else if (pkalgo == PUBKEY_ALGO_ECDSA) { if (!data[0] || !data[1]) rc = gpg_error (GPG_ERR_BAD_MPI); - else if (is_ed25519) - rc = gcry_sexp_build (&s_sig, NULL, - "(sig-val(eddsa(r%M)(s%M)))", data[0], data[1]); else rc = gcry_sexp_build (&s_sig, NULL, "(sig-val(ecdsa(r%m)(s%m)))", data[0], data[1]); } - else if (pkalgo == GCRY_PK_ELG || pkalgo == GCRY_PK_ELG_E) + else if (pkalgo == PUBKEY_ALGO_EDDSA) + { + if (!data[0] || !data[1]) + rc = gpg_error (GPG_ERR_BAD_MPI); + else + rc = gcry_sexp_build (&s_sig, NULL, + "(sig-val(eddsa(r%M)(s%M)))", data[0], data[1]); + } + else if (pkalgo == PUBKEY_ALGO_ELGAMAL || pkalgo == PUBKEY_ALGO_ELGAMAL_E) { if (!data[0] || !data[1]) rc = gpg_error (GPG_ERR_BAD_MPI); @@ -149,7 +159,7 @@ pk_verify (int algo, gcry_mpi_t hash, gcry_mpi_t *data, gcry_mpi_t *pkey) rc = gcry_sexp_build (&s_sig, NULL, "(sig-val(elg(r%m)(s%m)))", data[0], data[1]); } - else if (pkalgo == GCRY_PK_RSA || pkalgo == GCRY_PK_RSA_S) + else if (pkalgo == PUBKEY_ALGO_RSA || pkalgo == PUBKEY_ALGO_RSA_S) { if (!data[0]) rc = gpg_error (GPG_ERR_BAD_MPI); @@ -177,14 +187,14 @@ pk_verify (int algo, gcry_mpi_t hash, gcry_mpi_t *data, gcry_mpi_t *pkey) * PK is only required to compute the fingerprint for ECDH. */ int -pk_encrypt (int algo, gcry_mpi_t *resarr, gcry_mpi_t data, +pk_encrypt (pubkey_algo_t algo, gcry_mpi_t *resarr, gcry_mpi_t data, PKT_public_key *pk, gcry_mpi_t *pkey) { gcry_sexp_t s_ciph, s_data, s_pkey; int rc; /* Make a sexp from pkey. */ - if (algo == GCRY_PK_ELG || algo == GCRY_PK_ELG_E) + if (algo == PUBKEY_ALGO_ELGAMAL || algo == PUBKEY_ALGO_ELGAMAL_E) { rc = gcry_sexp_build (&s_pkey, NULL, "(public-key(elg(p%m)(g%m)(y%m)))", @@ -194,7 +204,7 @@ pk_encrypt (int algo, gcry_mpi_t *resarr, gcry_mpi_t data, BUG (); } - else if (algo == GCRY_PK_RSA || algo == GCRY_PK_RSA_E) + else if (algo == PUBKEY_ALGO_RSA || algo == PUBKEY_ALGO_RSA_E) { rc = gcry_sexp_build (&s_pkey, NULL, "(public-key(rsa(n%m)(e%m)))", @@ -280,7 +290,7 @@ pk_encrypt (int algo, gcry_mpi_t *resarr, gcry_mpi_t data, { /* Fixme: Add better error handling or make gnupg use S-expressions directly. */ resarr[0] = get_mpi_from_sexp (s_ciph, "a", GCRYMPI_FMT_USG); - if (algo != GCRY_PK_RSA && algo != GCRY_PK_RSA_E) + if (!is_RSA (algo)) resarr[1] = get_mpi_from_sexp (s_ciph, "b", GCRYMPI_FMT_USG); } @@ -291,53 +301,55 @@ pk_encrypt (int algo, gcry_mpi_t *resarr, gcry_mpi_t data, /* Check whether SKEY is a suitable secret key. */ int -pk_check_secret_key (int algo, gcry_mpi_t *skey) +pk_check_secret_key (pubkey_algo_t pkalgo, gcry_mpi_t *skey) { gcry_sexp_t s_skey; int rc; - const int gcry_pkalgo = map_pk_openpgp_to_gcry( algo ); - if (gcry_pkalgo == GCRY_PK_DSA) + if (pkalgo == PUBKEY_ALGO_DSA) { rc = gcry_sexp_build (&s_skey, NULL, "(private-key(dsa(p%m)(q%m)(g%m)(y%m)(x%m)))", skey[0], skey[1], skey[2], skey[3], skey[4]); } - else if (gcry_pkalgo == GCRY_PK_ELG || gcry_pkalgo == GCRY_PK_ELG_E) + else if (pkalgo == PUBKEY_ALGO_ELGAMAL || pkalgo == PUBKEY_ALGO_ELGAMAL_E) { rc = gcry_sexp_build (&s_skey, NULL, "(private-key(elg(p%m)(g%m)(y%m)(x%m)))", skey[0], skey[1], skey[2], skey[3]); } - else if (gcry_pkalgo == GCRY_PK_RSA - || gcry_pkalgo == GCRY_PK_RSA_S || gcry_pkalgo == GCRY_PK_RSA_E) + else if (is_RSA (pkalgo)) { rc = gcry_sexp_build (&s_skey, NULL, "(private-key(rsa(n%m)(e%m)(d%m)(p%m)(q%m)(u%m)))", skey[0], skey[1], skey[2], skey[3], skey[4], skey[5]); } - else if (gcry_pkalgo == GCRY_PK_ECDSA || gcry_pkalgo == GCRY_PK_ECDH) + else if (pkalgo == PUBKEY_ALGO_ECDSA || pkalgo == PUBKEY_ALGO_ECDH) { - if (openpgp_oid_is_ed25519 (skey[0])) + char *curve = openpgp_oid_to_str (skey[0]); + if (!curve) + rc = gpg_error_from_syserror (); + else { rc = gcry_sexp_build (&s_skey, NULL, - "(private-key(ecc(curve Ed25519)" - "(flags eddsa)(q%m)(d%m)))", - skey[1], skey[2]); + "(private-key(ecc(curve%s)(q%m)(d%m)))", + curve, skey[1], skey[2]); + xfree (curve); } + } + else if (pkalgo == PUBKEY_ALGO_EDDSA) + { + char *curve = openpgp_oid_to_str (skey[0]); + if (!curve) + rc = gpg_error_from_syserror (); else { - char *curve = openpgp_oid_to_str (skey[0]); - if (!curve) - rc = gpg_error_from_syserror (); - else - { - rc = gcry_sexp_build (&s_skey, NULL, - "(private-key(ecdsa(curve%s)(q%m)(d%m)))", - curve, skey[1], skey[2]); - xfree (curve); - } + rc = gcry_sexp_build (&s_skey, NULL, + "(private-key(ecc(curve %s)" + "(flags eddsa)(q%m)(d%m)))", + curve, skey[1], skey[2]); + xfree (curve); } } else diff --git a/g10/pkglue.h b/g10/pkglue.h index 48bfbb5..ba1097c 100644 --- a/g10/pkglue.h +++ b/g10/pkglue.h @@ -25,11 +25,11 @@ /*-- pkglue.c --*/ gcry_mpi_t get_mpi_from_sexp (gcry_sexp_t sexp, const char *item, int mpifmt); -int pk_verify (int algo, gcry_mpi_t hash, gcry_mpi_t *data, +int pk_verify (pubkey_algo_t algo, gcry_mpi_t hash, gcry_mpi_t *data, gcry_mpi_t *pkey); -int pk_encrypt (int algo, gcry_mpi_t *resarr, gcry_mpi_t data, +int pk_encrypt (pubkey_algo_t algo, gcry_mpi_t *resarr, gcry_mpi_t data, PKT_public_key *pk, gcry_mpi_t *pkey); -int pk_check_secret_key (int algo, gcry_mpi_t *skey); +int pk_check_secret_key (pubkey_algo_t algo, gcry_mpi_t *skey); /*-- ecdh.c --*/ diff --git a/g10/pubkey-enc.c b/g10/pubkey-enc.c index ab18ed7..042a255 100644 --- a/g10/pubkey-enc.c +++ b/g10/pubkey-enc.c @@ -151,7 +151,6 @@ get_it (PKT_pubkey_enc *enc, DEK *dek, PKT_public_key *sk, u32 *keyid) char *keygrip; byte fp[MAX_FINGERPRINT_LEN]; size_t fpn; - const int pkalgo = map_pk_openpgp_to_gcry (sk->pubkey_algo); if (DBG_CLOCK) log_clock ("decryption start"); @@ -162,7 +161,8 @@ get_it (PKT_pubkey_enc *enc, DEK *dek, PKT_public_key *sk, u32 *keyid) goto leave; /* Convert the data to an S-expression. */ - if (pkalgo == GCRY_PK_ELG || pkalgo == GCRY_PK_ELG_E) + if (sk->pubkey_algo == PUBKEY_ALGO_ELGAMAL + || sk->pubkey_algo == PUBKEY_ALGO_ELGAMAL_E) { if (!enc->data[0] || !enc->data[1]) err = gpg_error (GPG_ERR_BAD_MPI); @@ -170,7 +170,8 @@ get_it (PKT_pubkey_enc *enc, DEK *dek, PKT_public_key *sk, u32 *keyid) err = gcry_sexp_build (&s_data, NULL, "(enc-val(elg(a%m)(b%m)))", enc->data[0], enc->data[1]); } - else if (pkalgo == GCRY_PK_RSA || pkalgo == GCRY_PK_RSA_E) + else if (sk->pubkey_algo == PUBKEY_ALGO_RSA + || sk->pubkey_algo == PUBKEY_ALGO_RSA_E) { if (!enc->data[0]) err = gpg_error (GPG_ERR_BAD_MPI); @@ -178,7 +179,7 @@ get_it (PKT_pubkey_enc *enc, DEK *dek, PKT_public_key *sk, u32 *keyid) err = gcry_sexp_build (&s_data, NULL, "(enc-val(rsa(a%m)))", enc->data[0]); } - else if (pkalgo == GCRY_PK_ECDH) + else if (sk->pubkey_algo == PUBKEY_ALGO_ECDH) { if (!enc->data[0] || !enc->data[1]) err = gpg_error (GPG_ERR_BAD_MPI); diff --git a/g10/seskey.c b/g10/seskey.c index 7d04292..410f0bf 100644 --- a/g10/seskey.c +++ b/g10/seskey.c @@ -255,20 +255,20 @@ gcry_mpi_t encode_md_value (PKT_public_key *pk, gcry_md_hd_t md, int hash_algo) { gcry_mpi_t frame; - int pkalgo; size_t mdlen; assert (hash_algo); assert (pk); - pkalgo = map_pk_openpgp_to_gcry (pk->pubkey_algo); - - if (pkalgo == GCRY_PK_ECDSA && openpgp_oid_is_ed25519 (pk->pkey[0])) + if (pk->pubkey_algo == PUBKEY_ALGO_EDDSA) { + /* EdDSA signs data of arbitrary length. Thus no special + treatment is required. */ frame = gcry_mpi_set_opaque_copy (NULL, gcry_md_read (md, hash_algo), 8*gcry_md_get_algo_dlen (hash_algo)); } - else if (pkalgo == GCRY_PK_DSA || pkalgo == GCRY_PK_ECDSA) + else if (pk->pubkey_algo == PUBKEY_ALGO_DSA + || pk->pubkey_algo == PUBKEY_ALGO_ECDSA) { /* It's a DSA signature, so find out the size of q. */ @@ -276,11 +276,10 @@ encode_md_value (PKT_public_key *pk, gcry_md_hd_t md, int hash_algo) /* pkey[1] is Q for ECDSA, which is an uncompressed point, i.e. 04 */ - if (pkalgo == GCRY_PK_ECDSA) + if (pk->pubkey_algo == PUBKEY_ALGO_ECDSA) qbits = ecdsa_qbits_from_Q (qbits); /* Make sure it is a multiple of 8 bits. */ - if ((qbits%8)) { log_error(_("DSA requires the hash length to be a" @@ -297,7 +296,8 @@ encode_md_value (PKT_public_key *pk, gcry_md_hd_t md, int hash_algo) if (qbits < 160) { log_error (_("%s key %s uses an unsafe (%zu bit) hash\n"), - gcry_pk_algo_name (pkalgo), keystr_from_pk (pk), qbits); + openpgp_pk_algo_name (pk->pubkey_algo), + keystr_from_pk (pk), qbits); return NULL; } @@ -305,7 +305,7 @@ encode_md_value (PKT_public_key *pk, gcry_md_hd_t md, int hash_algo) /* ECDSA 521 is special has it is larger than the largest hash we have (SHA-512). Thus we chnage the size for further processing to 512. */ - if (pkalgo == GCRY_PK_ECDSA && qbits > 512) + if (pk->pubkey_algo == PUBKEY_ALGO_ECDSA && qbits > 512) qbits = 512; /* Check if we're too short. Too long is safe as we'll @@ -315,8 +315,8 @@ encode_md_value (PKT_public_key *pk, gcry_md_hd_t md, int hash_algo) { log_error (_("%s key %s requires a %zu bit or larger hash " "(hash is %s)\n"), - gcry_pk_algo_name (pkalgo), - keystr_from_pk(pk), qbits, + openpgp_pk_algo_name (pk->pubkey_algo), + keystr_from_pk (pk), qbits, gcry_md_algo_name (hash_algo)); return NULL; } diff --git a/g10/sign.c b/g10/sign.c index e4d3290..098655d 100644 --- a/g10/sign.c +++ b/g10/sign.c @@ -446,7 +446,7 @@ hash_for (PKT_public_key *pk) { return recipient_digest_algo; } - else if (pk->pubkey_algo == PUBKEY_ALGO_ECDSA + else if (pk->pubkey_algo == PUBKEY_ALGO_EDDSA && openpgp_oid_is_ed25519 (pk->pkey[0])) { if (opt.personal_digest_prefs) @@ -944,13 +944,13 @@ sign_file (ctrl_t ctrl, strlist_t filenames, int detached, strlist_t locusr, for (sk_rover = sk_list; sk_rover; sk_rover = sk_rover->next ) { if (sk_rover->pk->pubkey_algo == PUBKEY_ALGO_DSA - || (sk_rover->pk->pubkey_algo == PUBKEY_ALGO_ECDSA + || (sk_rover->pk->pubkey_algo == PUBKEY_ALGO_EDDSA && !openpgp_oid_is_ed25519 (sk_rover->pk->pkey[1]))) { int temp_hashlen = (gcry_mpi_get_nbits (sk_rover->pk->pkey[1])); - if (sk_rover->pk->pubkey_algo == PUBKEY_ALGO_ECDSA) + if (sk_rover->pk->pubkey_algo == PUBKEY_ALGO_EDDSA) temp_hashlen = ecdsa_qbits_from_Q (temp_hashlen); temp_hashlen = (temp_hashlen+7)/8; @@ -1510,7 +1510,8 @@ make_keysig_packet( PKT_signature **ret_sig, PKT_public_key *pk, digest_algo = DIGEST_ALGO_MD5; else if(pksk->pubkey_algo == PUBKEY_ALGO_DSA) digest_algo = match_dsa_hash (gcry_mpi_get_nbits (pksk->pkey[1])/8); - else if(pksk->pubkey_algo == PUBKEY_ALGO_ECDSA ) + else if (pksk->pubkey_algo == PUBKEY_ALGO_ECDSA + || pksk->pubkey_algo == PUBKEY_ALGO_EDDSA) { if (openpgp_oid_is_ed25519 (pksk->pkey[0])) digest_algo = DIGEST_ALGO_SHA256; diff --git a/sm/certreqgen-ui.c b/sm/certreqgen-ui.c index 1035404..368dc55 100644 --- a/sm/certreqgen-ui.c +++ b/sm/certreqgen-ui.c @@ -95,7 +95,7 @@ check_keygrip (ctrl_t ctrl, const char *hexgrip) gpg_error_t err; ksba_sexp_t public; size_t publiclen; - int algo; + const char *algostr; if (hexgrip[0] == '&') hexgrip++; @@ -105,17 +105,21 @@ check_keygrip (ctrl_t ctrl, const char *hexgrip) return NULL; publiclen = gcry_sexp_canon_len (public, 0, NULL, NULL); - get_pk_algo_from_canon_sexp (public, publiclen, &algo); + get_pk_algo_from_canon_sexp (public, publiclen, &algostr); xfree (public); - switch (algo) - { - case GCRY_PK_RSA: return "RSA"; - case GCRY_PK_DSA: return "DSA"; - case GCRY_PK_ELG: return "ELG"; - case GCRY_PK_ECDSA: return "ECDSA"; - default: return NULL; - } + if (!algostr) + return NULL; + else if (!strcmp (algostr, "rsa")) + return "RSA"; + else if (!strcmp (algostr, "dsa")) + return "DSA"; + else if (!strcmp (algostr, "elg")) + return "ELG"; + else if (!strcmp (algostr, "ecdsa")) + return "ECDSA"; + else + return NULL; } ----------------------------------------------------------------------- Summary of changes: agent/pksign.c | 5 +- common/sexputil.c | 19 +++-- common/util.h | 2 +- g10/build-packet.c | 5 +- g10/export.c | 4 +- g10/getkey.c | 1 + g10/import.c | 3 +- g10/keygen.c | 86 +++++++++++++++------ g10/keyid.c | 2 + g10/keylist.c | 4 + g10/keyserver.c | 2 +- g10/main.h | 15 ++-- g10/mainproc.c | 1 + g10/misc.c | 218 ++++++++++++++++++++++++++-------------------------- g10/parse-packet.c | 7 +- g10/pkglue.c | 126 ++++++++++++++++-------------- g10/pkglue.h | 6 +- g10/pubkey-enc.c | 9 ++- g10/seskey.c | 22 +++--- g10/sign.c | 9 ++- sm/certreqgen-ui.c | 24 +++--- 21 files changed, 320 insertions(+), 250 deletions(-) hooks/post-receive -- The GNU Privacy Guard http://git.gnupg.org From cvs at cvs.gnupg.org Fri Jan 31 08:54:59 2014 From: cvs at cvs.gnupg.org (by Jussi Kivilinna) Date: Fri, 31 Jan 2014 08:54:59 +0100 Subject: [git] GCRYPT - branch, LIBGCRYPT-1-6-BRANCH, updated. libgcrypt-1.6.1-3-ga76148a Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The GNU crypto library". The branch, LIBGCRYPT-1-6-BRANCH has been updated via a76148ac8fed0f0b82d85e94df5018659592893a (commit) from 3216da3ddbc3eeb49171ab179acd9d75ca4d0218 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit a76148ac8fed0f0b82d85e94df5018659592893a Author: Jussi Kivilinna Date: Mon Dec 30 15:10:13 2013 +0200 Parse /proc/cpuinfo for ARM HW features * src/hwf-arm.c [__linux__] (HAS_PROC_CPUINFO) (detect_arm_proc_cpuinfo): New. (_gcry_hwf_detect_arm) [HAS_PROC_CPUINFO]: Check '/proc/cpuinfo' for HW features. -- Some Linux platforms (read: Android) block read access to '/proc/self/auxv', which prevents NEON HW detection. Patch adds alternative check which parses '/proc/cpuinfo' which should be accessable by Android applications. Signed-off-by: Jussi Kivilinna (cherry picked from commit a05be441d8cd89b90d8d58e3a343a436dae377d0) diff --git a/src/hwf-arm.c b/src/hwf-arm.c index 5c99a1d..aa4bfd7 100644 --- a/src/hwf-arm.c +++ b/src/hwf-arm.c @@ -32,6 +32,7 @@ #endif #undef HAS_SYS_AT_HWCAP +#undef HAS_PROC_CPUINFO #ifdef __linux__ #define HAS_SYS_AT_HWCAP 1 @@ -94,6 +95,54 @@ detect_arm_at_hwcap(void) return features; } +#define HAS_PROC_CPUINFO 1 + +static unsigned int +detect_arm_proc_cpuinfo(void) +{ + char buf[1024]; /* large enough */ + char *str_features, *str_neon; + FILE *f; + int readlen, i; + static int cpuinfo_initialized = 0; + static unsigned int stored_cpuinfo_features; + + if (cpuinfo_initialized) + return stored_cpuinfo_features; + + f = fopen("/proc/cpuinfo", "r"); + if (!f) + return 0; + + memset (buf, 0, sizeof(buf)); + readlen = fread (buf, 1, sizeof(buf), f); + fclose (f); + if (readlen <= 0 || readlen > sizeof(buf)) + return 0; + + buf[sizeof(buf) - 1] = '\0'; + + cpuinfo_initialized = 1; + stored_cpuinfo_features = 0; + + /* Find features line. */ + str_features = strstr(buf, "Features"); + if (!str_features) + return stored_cpuinfo_features; + + /* Lines to strings. */ + for (i = 0; i < sizeof(buf); i++) + if (buf[i] == '\n') + buf[i] = '\0'; + + /* Check for NEON. */ + str_neon = strstr(str_features, " neon"); + if (str_neon && (str_neon[5] == ' ' || str_neon[5] == '\0')) + stored_cpuinfo_features |= HWF_ARM_NEON; + + return stored_cpuinfo_features; +} + #endif /* __linux__ */ unsigned int @@ -103,8 +152,10 @@ _gcry_hwf_detect_arm (void) #if defined (HAS_SYS_AT_HWCAP) ret |= detect_arm_at_hwcap (); -#else - ret |= 0; +#endif + +#if defined (HAS_PROC_CPUINFO) + ret |= detect_arm_proc_cpuinfo (); #endif #if defined(__ARM_NEON__) && defined(ENABLE_NEON_SUPPORT) ----------------------------------------------------------------------- Summary of changes: src/hwf-arm.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 53 insertions(+), 2 deletions(-) hooks/post-receive -- The GNU crypto library http://git.gnupg.org From cvs at cvs.gnupg.org Fri Jan 31 15:56:45 2014 From: cvs at cvs.gnupg.org (by Werner Koch) Date: Fri, 31 Jan 2014 15:56:45 +0100 Subject: [git] GnuPG - branch, master, updated. gnupg-2.1.0beta3-296-g71540d4 Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The GNU Privacy Guard". The branch, master has been updated via 71540d40414dc8b304b45dc476e5e5650a2db20a (commit) via bf50604a0d50b974c1d4b8ccf5d774489f996cae (commit) via 16a6311adefff0139056714521214f845315b7f8 (commit) from b7f8dec6325f1c80640f878ed3080bbc194fbc78 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 71540d40414dc8b304b45dc476e5e5650a2db20a Author: Werner Koch Date: Fri Jan 31 15:55:04 2014 +0100 gpg: Improve --version algo info output. * g10/misc.c (openpgp_pk_algo_name): Return a different string for each ECC algorithm. * g10/gpg.c (build_list_pk_test_algo): New wrapper to cope with the different algo type enums. (build_list_pk_algo_name): Ditto. (build_list_cipher_test_algo): Ditto. (build_list_cipher_algo_name): Ditto. (build_list_md_test_algo): Ditto. (build_list_md_algo_name): Ditto. (my_strusage): Use them. (list_config): Ditto. Add "pubkeyname". (build_list): Add letter==1 hack. diff --git a/g10/gpg.c b/g10/gpg.c index a770d74..5b33105 100644 --- a/g10/gpg.c +++ b/g10/gpg.c @@ -811,6 +811,43 @@ make_libversion (const char *libname, const char *(*getfnc)(const char*)) } +static int +build_list_pk_test_algo (int algo) +{ + return openpgp_pk_test_algo (algo); +} + +static const char * +build_list_pk_algo_name (int algo) +{ + return openpgp_pk_algo_name (algo); +} + +static int +build_list_cipher_test_algo (int algo) +{ + return openpgp_cipher_test_algo (algo); +} + +static const char * +build_list_cipher_algo_name (int algo) +{ + return openpgp_cipher_algo_name (algo); +} + +static int +build_list_md_test_algo (int algo) +{ + return openpgp_md_test_algo (algo); +} + +static const char * +build_list_md_algo_name (int algo) +{ + return openpgp_md_algo_name (algo); +} + + static const char * my_strusage( int level ) { @@ -861,23 +898,23 @@ my_strusage( int level ) case 33: p = _("\nSupported algorithms:\n"); break; case 34: if (!pubkeys) - pubkeys = build_list (_("Pubkey: "), 0, - openpgp_pk_algo_name, - openpgp_pk_test_algo ); + pubkeys = build_list (_("Pubkey: "), 1, + build_list_pk_algo_name, + build_list_pk_test_algo ); p = pubkeys; break; case 35: if( !ciphers ) ciphers = build_list(_("Cipher: "), 'S', - openpgp_cipher_algo_name, - openpgp_cipher_test_algo ); + build_list_cipher_algo_name, + build_list_cipher_test_algo ); p = ciphers; break; case 36: if( !digests ) digests = build_list(_("Hash: "), 'H', - gcry_md_algo_name, - openpgp_md_test_algo ); + build_list_md_algo_name, + build_list_md_test_algo ); p = digests; break; case 37: @@ -931,7 +968,10 @@ build_list (const char *text, char letter, if (opt.verbose && letter) { char num[20]; - snprintf (num, sizeof num, " (%c%d)", letter, i); + if (letter == 1) + snprintf (num, sizeof num, " (%d)", i); + else + snprintf (num, sizeof num, " (%c%d)", letter, i); put_membuf_str (&mb, num); } } @@ -1533,7 +1573,16 @@ list_config(char *items) if(show_all || ascii_strcasecmp(name,"pubkey")==0) { es_printf ("cfg:pubkey:"); - print_algo_numbers (openpgp_pk_test_algo); + print_algo_numbers (build_list_pk_test_algo); + es_printf ("\n"); + any=1; + } + + if(show_all || ascii_strcasecmp(name,"pubkeyname")==0) + { + es_printf ("cfg:pubkeyname:"); + print_algo_names (build_list_pk_test_algo, + build_list_pk_algo_name); es_printf ("\n"); any=1; } @@ -1541,7 +1590,7 @@ list_config(char *items) if(show_all || ascii_strcasecmp(name,"cipher")==0) { es_printf ("cfg:cipher:"); - print_algo_numbers(openpgp_cipher_test_algo); + print_algo_numbers (build_list_cipher_test_algo); es_printf ("\n"); any=1; } @@ -1549,7 +1598,8 @@ list_config(char *items) if (show_all || !ascii_strcasecmp (name,"ciphername")) { es_printf ("cfg:ciphername:"); - print_algo_names (openpgp_cipher_test_algo,openpgp_cipher_algo_name); + print_algo_names (build_list_cipher_test_algo, + build_list_cipher_algo_name); es_printf ("\n"); any = 1; } @@ -1559,7 +1609,7 @@ list_config(char *items) || ascii_strcasecmp(name,"hash")==0) { es_printf ("cfg:digest:"); - print_algo_numbers(openpgp_md_test_algo); + print_algo_numbers (build_list_md_test_algo); es_printf ("\n"); any=1; } @@ -1569,7 +1619,8 @@ list_config(char *items) || !ascii_strcasecmp(name,"hashname")) { es_printf ("cfg:digestname:"); - print_algo_names (openpgp_md_test_algo, gcry_md_algo_name); + print_algo_names (build_list_md_test_algo, + build_list_md_algo_name); es_printf ("\n"); any=1; } diff --git a/g10/misc.c b/g10/misc.c index 06d0b8f..6d3a7b8 100644 --- a/g10/misc.c +++ b/g10/misc.c @@ -572,9 +572,9 @@ openpgp_pk_algo_name (pubkey_algo_t algo) case PUBKEY_ALGO_ELGAMAL: case PUBKEY_ALGO_ELGAMAL_E: return "ELG"; case PUBKEY_ALGO_DSA: return "DSA"; - case PUBKEY_ALGO_ECDH: - case PUBKEY_ALGO_ECDSA: - case PUBKEY_ALGO_EDDSA: return "ECC"; + case PUBKEY_ALGO_ECDH: return "ECDH"; + case PUBKEY_ALGO_ECDSA: return "ECDSA"; + case PUBKEY_ALGO_EDDSA: return "EDDSA"; } return "?"; } commit bf50604a0d50b974c1d4b8ccf5d774489f996cae Author: Werner Koch Date: Fri Jan 31 15:33:03 2014 +0100 gpg: Start using OpenPGP digest algo ids. * g10/misc.c (print_pubkey_algo_note): Use enum typedef for the arg. (print_cipher_algo_note): Ditto. (print_digest_algo_note): Ditto. (map_md_openpgp_to_gcry): New. (openpgp_md_test_algo): Rewrite. (openpgp_md_algo_name): Rewrite to do without Libgcrypt. * g10/cpr.c (write_status_begin_signing): Remove hardwired list of algo ranges. diff --git a/g10/cpr.c b/g10/cpr.c index 8d2262e..99c8eec 100644 --- a/g10/cpr.c +++ b/g10/cpr.c @@ -307,24 +307,19 @@ write_status_begin_signing (gcry_md_hd_t md) { char buf[100]; size_t buflen; - int i; - - /* We use a hard coded list of possible algorithms. Using other - algorithms than specified by OpenPGP does not make sense - anyway. We do this out of performance reasons: Walking all - the 110 allowed Ids is not a good idea given the way the - check is implemented in libgcrypt. Recall that the only use - of this status code is to create the micalg algorithm for - PGP/MIME. */ + int i, ga; + buflen = 0; - for (i=1; i <= 11; i++) - if (i < 4 || i > 7) - if (gcry_md_is_enabled (md, i) && buflen < DIM(buf)) + for (i=1; i <= 110; i++) + { + ga = map_md_openpgp_to_gcry (i); + if (ga && gcry_md_is_enabled (md, ga) && buflen+10 < DIM(buf)) { snprintf (buf+buflen, DIM(buf) - buflen - 1, "%sH%d", buflen? " ":"",i); buflen += strlen (buf+buflen); } + } write_status_text (STATUS_BEGIN_SIGNING, buf); } else diff --git a/g10/main.h b/g10/main.h index 1ee563e..28115ca 100644 --- a/g10/main.h +++ b/g10/main.h @@ -71,9 +71,9 @@ extern int g10_errors_seen; #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 ); +void print_pubkey_algo_note (pubkey_algo_t algo); +void print_cipher_algo_note (cipher_algo_t algo); +void print_digest_algo_note (digest_algo_t algo); /*-- armor.c --*/ char *make_radix64_string( const byte *data, size_t len ); @@ -108,7 +108,8 @@ int openpgp_pk_test_algo2 (pubkey_algo_t algo, unsigned int use); int openpgp_pk_algo_usage ( int algo ); const char *openpgp_pk_algo_name (pubkey_algo_t algo); -int openpgp_md_test_algo( int algo ); +enum gcry_md_algos map_md_openpgp_to_gcry (digest_algo_t algo); +int openpgp_md_test_algo (digest_algo_t algo); const char *openpgp_md_algo_name (int algo); struct expando_args diff --git a/g10/misc.c b/g10/misc.c index 1626b21..06d0b8f 100644 --- a/g10/misc.c +++ b/g10/misc.c @@ -1,6 +1,7 @@ /* misc.c - miscellaneous functions * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, * 2008, 2009, 2010 Free Software Foundation, Inc. + * Copyright (C) 2014 Werner Koch * * This file is part of GnuPG. * @@ -286,7 +287,7 @@ buffer_to_u32( const byte *buffer ) } void -print_pubkey_algo_note( int algo ) +print_pubkey_algo_note (pubkey_algo_t algo) { if(algo >= 100 && algo <= 110) { @@ -305,7 +306,7 @@ print_pubkey_algo_note( int algo ) } void -print_cipher_algo_note( int algo ) +print_cipher_algo_note (cipher_algo_t algo) { if(algo >= 100 && algo <= 110) { @@ -320,7 +321,7 @@ print_cipher_algo_note( int algo ) } void -print_digest_algo_note( int algo ) +print_digest_algo_note (digest_algo_t algo) { if(algo >= 100 && algo <= 110) { @@ -579,17 +580,43 @@ openpgp_pk_algo_name (pubkey_algo_t algo) } +/* Explicit mapping of OpenPGP digest algos to Libgcrypt. */ +/* FIXME: We do not yes use it everywhere. */ +enum gcry_md_algos +map_md_openpgp_to_gcry (digest_algo_t algo) +{ + switch (algo) + { + case DIGEST_ALGO_MD5: return GCRY_MD_MD5; + case DIGEST_ALGO_SHA1: return GCRY_MD_SHA1; + case DIGEST_ALGO_RMD160: return GCRY_MD_RMD160; + case DIGEST_ALGO_SHA224: return GCRY_MD_SHA224; + case DIGEST_ALGO_SHA256: return GCRY_MD_SHA256; + case DIGEST_ALGO_SHA384: return GCRY_MD_SHA384; + case DIGEST_ALGO_SHA512: return GCRY_MD_SHA512; + } + return 0; +} + + +/* Return 0 if ALGO is suitable and implemented OpenPGP hash + algorithm. Note: To only test for a valid OpenPGP hash algorithm, + it is better to use map_md_openpgp_to_gcry. */ int -openpgp_md_test_algo( int algo ) +openpgp_md_test_algo (digest_algo_t algo) { - /* Note: If the list of actual supported OpenPGP algorithms changes, - make sure that our hard coded values at - print_status_begin_signing() gets updated. */ - /* 4, 5, 6, 7 are defined by rfc2440 but will be removed from the - next revision of the standard. */ - if (algo < 0 || algo > 110 || (algo >= 4 && algo <= 7)) + enum gcry_md_algos ga; + + ga = map_md_openpgp_to_gcry (algo); + switch (algo) + { + default: + break; + } + if (!ga) return gpg_error (GPG_ERR_DIGEST_ALGO); - return gcry_md_test_algo (algo); + + return gcry_md_test_algo (ga); } @@ -599,9 +626,17 @@ openpgp_md_test_algo( int algo ) const char * openpgp_md_algo_name (int algo) { - if (algo < 0 || algo > 110) - return "?"; - return gcry_md_algo_name (algo); + switch (algo) + { + case DIGEST_ALGO_MD5: return "MD5"; + case DIGEST_ALGO_SHA1: return "SHA1"; + case DIGEST_ALGO_RMD160: return "RIPEMD160"; + case DIGEST_ALGO_SHA256: return "SHA256"; + case DIGEST_ALGO_SHA384: return "SHA384"; + case DIGEST_ALGO_SHA512: return "SHA512"; + case DIGEST_ALGO_SHA224: return "SHA224"; + } + return "?"; } @@ -920,6 +955,8 @@ string_to_digest_algo (const char *string) { int val; + /* FIXME: We should make use of our wrapper fucntion and not assume + that there is a 1 to 1 mapping between OpenPGP and Libgcrypt. */ val = gcry_md_map_name (string); if (!val && string && (string[0]=='H' || string[0]=='h')) { commit 16a6311adefff0139056714521214f845315b7f8 Author: Werner Koch Date: Fri Jan 31 14:35:49 2014 +0100 gpg: Use only OpenPGP cipher algo ids. * g10/misc.c (map_cipher_openpgp_to_gcry): Use explicit mapping and use enums for the arg and return value. (map_cipher_gcry_to_openpgp): Ditto. (openpgp_cipher_blocklen): Use constant macros. (openpgp_cipher_test_algo): Use mapping function and prepare to disable algorithms. (openpgp_cipher_algo_name): Do not use Libgcrypt. * g10/ecdh.c (pk_ecdh_encrypt_with_shared_point): Replace CGRY_CIPHER_* by CIPHER_ALGO_*. * common/openpgpdefs.h (cipher_algo_t): Remove unused CIPHER_ALGO_DUMMY. Signed-off-by: Werner Koch diff --git a/common/openpgpdefs.h b/common/openpgpdefs.h index 0a58442..ac1af37 100644 --- a/common/openpgpdefs.h +++ b/common/openpgpdefs.h @@ -107,9 +107,7 @@ typedef enum CIPHER_ALGO_TWOFISH = 10, /* 256 bit */ CIPHER_ALGO_CAMELLIA128 = 11, CIPHER_ALGO_CAMELLIA192 = 12, - CIPHER_ALGO_CAMELLIA256 = 13, - - CIPHER_ALGO_DUMMY = 110 /* No encryption at all (private). */ + CIPHER_ALGO_CAMELLIA256 = 13 } cipher_algo_t; diff --git a/g10/ecdh.c b/g10/ecdh.c index 752181e..0b06239 100644 --- a/g10/ecdh.c +++ b/g10/ecdh.c @@ -183,9 +183,9 @@ pk_ecdh_encrypt_with_shared_point (int is_encrypt, gcry_mpi_t shared_mpi, xfree (secret_x); return gpg_error (GPG_ERR_BAD_PUBKEY); } - if (kdf_encr_algo != GCRY_CIPHER_AES128 - && kdf_encr_algo != GCRY_CIPHER_AES192 - && kdf_encr_algo != GCRY_CIPHER_AES256) + if (kdf_encr_algo != CIPHER_ALGO_AES + && kdf_encr_algo != CIPHER_ALGO_AES192 + && kdf_encr_algo != CIPHER_ALGO_AES256) { xfree (secret_x); return gpg_error (GPG_ERR_BAD_PUBKEY); diff --git a/g10/main.h b/g10/main.h index 26283a7..1ee563e 100644 --- a/g10/main.h +++ b/g10/main.h @@ -90,22 +90,25 @@ 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); + +enum gcry_cipher_algos map_cipher_openpgp_to_gcry (cipher_algo_t 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 map_pk_gcry_to_openpgp (enum gcry_pk_algos algo); +int openpgp_cipher_blocklen (cipher_algo_t algo); +int openpgp_cipher_test_algo(cipher_algo_t algo); +const char *openpgp_cipher_algo_name (cipher_algo_t algo); + +pubkey_algo_t map_pk_gcry_to_openpgp (enum gcry_pk_algos algo); int openpgp_pk_test_algo (pubkey_algo_t algo); int openpgp_pk_test_algo2 (pubkey_algo_t algo, unsigned int use); int openpgp_pk_algo_usage ( int algo ); -int openpgp_md_test_algo( int algo ); const char *openpgp_pk_algo_name (pubkey_algo_t algo); + +int openpgp_md_test_algo( int algo ); const char *openpgp_md_algo_name (int algo); struct expando_args diff --git a/g10/misc.c b/g10/misc.c index 1ac5430..1626b21 100644 --- a/g10/misc.c +++ b/g10/misc.c @@ -341,35 +341,53 @@ print_digest_algo_note( int algo ) /* Map OpenPGP algo numbers to those used by Libgcrypt. We need to do this for algorithms we implemented in Libgcrypt after they become part of OpenPGP. */ -int -map_cipher_openpgp_to_gcry (int algo) +enum gcry_cipher_algos +map_cipher_openpgp_to_gcry (cipher_algo_t algo) { switch (algo) { - case CIPHER_ALGO_CAMELLIA128: return 310; - case CIPHER_ALGO_CAMELLIA192: return 311; - case CIPHER_ALGO_CAMELLIA256: return 312; - default: return algo; + case CIPHER_ALGO_NONE: return GCRY_CIPHER_NONE; + case CIPHER_ALGO_IDEA: return GCRY_CIPHER_IDEA; + case CIPHER_ALGO_3DES: return GCRY_CIPHER_3DES; + case CIPHER_ALGO_CAST5: return GCRY_CIPHER_CAST5; + case CIPHER_ALGO_BLOWFISH: return GCRY_CIPHER_BLOWFISH; + case CIPHER_ALGO_AES: return GCRY_CIPHER_AES; + case CIPHER_ALGO_AES192: return GCRY_CIPHER_AES192; + case CIPHER_ALGO_AES256: return GCRY_CIPHER_AES256; + case CIPHER_ALGO_TWOFISH: return GCRY_CIPHER_TWOFISH; + case CIPHER_ALGO_CAMELLIA128: return GCRY_CIPHER_CAMELLIA128; + case CIPHER_ALGO_CAMELLIA192: return GCRY_CIPHER_CAMELLIA192; + case CIPHER_ALGO_CAMELLIA256: return GCRY_CIPHER_CAMELLIA256; } + return 0; } -/* The inverse fucntion of above. */ -static int -map_cipher_gcry_to_openpgp (int algo) +/* The inverse function of above. */ +static cipher_algo_t +map_cipher_gcry_to_openpgp (enum gcry_cipher_algos algo) { switch (algo) { - case 310: return CIPHER_ALGO_CAMELLIA128; - case 311: return CIPHER_ALGO_CAMELLIA192; - case 312: return CIPHER_ALGO_CAMELLIA256; - default: return algo; + case GCRY_CIPHER_NONE: return CIPHER_ALGO_NONE; + case GCRY_CIPHER_IDEA: return CIPHER_ALGO_IDEA; + case GCRY_CIPHER_3DES: return CIPHER_ALGO_3DES; + case GCRY_CIPHER_CAST5: return CIPHER_ALGO_CAST5; + case GCRY_CIPHER_BLOWFISH: return CIPHER_ALGO_BLOWFISH; + case GCRY_CIPHER_AES: return CIPHER_ALGO_AES; + case GCRY_CIPHER_AES192: return CIPHER_ALGO_AES192; + case GCRY_CIPHER_AES256: return CIPHER_ALGO_AES256; + case GCRY_CIPHER_TWOFISH: return CIPHER_ALGO_TWOFISH; + case GCRY_CIPHER_CAMELLIA128: return CIPHER_ALGO_CAMELLIA128; + case GCRY_CIPHER_CAMELLIA192: return CIPHER_ALGO_CAMELLIA192; + case GCRY_CIPHER_CAMELLIA256: return CIPHER_ALGO_CAMELLIA256; + default: return 0; } } /* Map Gcrypt public key algorithm numbers to those used by OpenPGP. FIXME: This mapping is used at only two places - we should get rid of it. */ -int +pubkey_algo_t map_pk_gcry_to_openpgp (enum gcry_pk_algos algo) { switch (algo) @@ -383,7 +401,7 @@ map_pk_gcry_to_openpgp (enum gcry_pk_algos algo) /* Return the block length of an OpenPGP cipher algorithm. */ int -openpgp_cipher_blocklen (int algo) +openpgp_cipher_blocklen (cipher_algo_t algo) { /* We use the numbers from OpenPGP to be sure that we get the right block length. This is so that the packet parsing code works even @@ -394,9 +412,13 @@ openpgp_cipher_blocklen (int algo) size. */ switch (algo) { - case 7: case 8: case 9: /* AES */ - case 10: /* Twofish */ - case 11: case 12: case 13: /* Camellia */ + case CIPHER_ALGO_AES: + case CIPHER_ALGO_AES192: + case CIPHER_ALGO_AES256: + case CIPHER_ALGO_TWOFISH: + case CIPHER_ALGO_CAMELLIA128: + case CIPHER_ALGO_CAMELLIA192: + case CIPHER_ALGO_CAMELLIA256: return 16; default: @@ -409,22 +431,50 @@ openpgp_cipher_blocklen (int algo) * the OpenPGP contraints for the algo ID. */ int -openpgp_cipher_test_algo( int algo ) +openpgp_cipher_test_algo (cipher_algo_t algo) { - /* (5 and 6 are marked reserved by rfc4880.) */ - if ( algo < 0 || algo > 110 || algo == 5 || algo == 6 ) + enum gcry_cipher_algos ga; + + ga = map_cipher_openpgp_to_gcry (algo); + + /* Use this explicit list to disable certain algorithms. */ + switch (algo) + { + /* case CIPHER_ALGO_IDEA: */ + /* ga = 0; */ + /* break; */ + default: + break; + } + + if (!ga) return gpg_error (GPG_ERR_CIPHER_ALGO); - return gcry_cipher_test_algo (map_cipher_openpgp_to_gcry (algo)); + return gcry_cipher_test_algo (ga); } /* Map the OpenPGP cipher algorithm whose ID is contained in ALGORITHM to a string representation of the algorithm name. For unknown algorithm IDs this function returns "?". */ const char * -openpgp_cipher_algo_name (int algo) +openpgp_cipher_algo_name (cipher_algo_t algo) { - return gnupg_cipher_algo_name (map_cipher_openpgp_to_gcry (algo)); + switch (algo) + { + case CIPHER_ALGO_NONE: break; + case CIPHER_ALGO_IDEA: return "IDEA"; + case CIPHER_ALGO_3DES: return "3DES"; + case CIPHER_ALGO_CAST5: return "CAST5"; + case CIPHER_ALGO_BLOWFISH: return "BLOWFISH"; + case CIPHER_ALGO_AES: return "AES"; + case CIPHER_ALGO_AES192: return "AES192"; + case CIPHER_ALGO_AES256: return "AES256"; + case CIPHER_ALGO_TWOFISH: return "TWOFISH"; + case CIPHER_ALGO_CAMELLIA128: return "CAMELLIA128"; + case CIPHER_ALGO_CAMELLIA192: return "CAMELLIA192"; + case CIPHER_ALGO_CAMELLIA256: return "CAMELLIA256"; + } + return "?"; } ----------------------------------------------------------------------- Summary of changes: common/openpgpdefs.h | 4 +- g10/cpr.c | 19 +++--- g10/ecdh.c | 6 +- g10/gpg.c | 77 +++++++++++++++++++---- g10/main.h | 22 ++++--- g10/misc.c | 169 ++++++++++++++++++++++++++++++++++++++------------ 6 files changed, 216 insertions(+), 81 deletions(-) hooks/post-receive -- The GNU Privacy Guard http://git.gnupg.org From cvs at cvs.gnupg.org Fri Jan 31 22:48:32 2014 From: cvs at cvs.gnupg.org (by Werner Koch) Date: Fri, 31 Jan 2014 22:48:32 +0100 Subject: [git] GnuPG - branch, master, updated. gnupg-2.1.0beta3-297-g2ba818d Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The GNU Privacy Guard". The branch, master has been updated via 2ba818de1aa311ba8eb27012d69e93dd16e7d4ed (commit) from 71540d40414dc8b304b45dc476e5e5650a2db20a (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 2ba818de1aa311ba8eb27012d69e93dd16e7d4ed Author: Werner Koch Date: Fri Jan 31 22:47:11 2014 +0100 gpg: Add configure options to disable algorithms * acinclude.m4 (GNUPG_GPG_DISABLE_ALGO): New. * configure.ac: Add --enable-gpg-* options to disable non MUS algorithms. * g10/misc.c (map_cipher_openpgp_to_gcry): Implement these options. (openpgp_pk_test_algo2): Ditto. (map_md_openpgp_to_gcry): Ditto. (openpgp_cipher_test_algo, openpgp_md_test_algo): Simplify. -- We have a similar feature in GnuPG-1. Although we don't shrink the size of the gpg binary by disabling algorithms (they are implemented in Libgcrypt), this feature may still be useful for inerop testing. diff --git a/acinclude.m4 b/acinclude.m4 index a37e0f5..7c264a4 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -7,12 +7,12 @@ 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 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 dnl You should have received a copy of the GNU General Public License dnl along with this program; if not, see . @@ -38,7 +38,7 @@ AC_DEFUN([GNUPG_CHECK_TYPEDEF], 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 @@ -59,7 +59,7 @@ AC_DEFUN([GNUPG_CHECK_FAQPROG], if faqprog.pl -V 2>/dev/null | grep '^faqprog.pl ' >/dev/null 2>&1; then working_faqprog=yes FAQPROG="faqprog.pl" - else + else working_faqprog=no FAQPROG=": " fi @@ -77,7 +77,7 @@ 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 @@ -93,7 +93,7 @@ AC_DEFUN([GNUPG_CHECK_DOCBOOK_TO_TEXI], fi AC_MSG_RESULT($working_sgmltotexi) AM_CONDITIONAL(HAVE_DOCBOOK_TO_TEXI, test "$working_sgmltotexi" = "yes" ) - ]) + ]) @@ -162,7 +162,7 @@ AC_DEFUN([GNUPG_CHECK_ENDIAN], # 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 +# build_NAME and whether --enable-NAME or --disable-NAME is shown with # ./configure --help AC_DEFUN([GNUPG_BUILD_PROGRAM], [build_$1=$2 @@ -178,7 +178,7 @@ AC_DEFUN([GNUPG_BUILD_PROGRAM], case "$build_$1" in no|yes) ;; - *) + *) AC_MSG_ERROR([only yes or no allowed for feature --enable-$1]) ;; esac @@ -186,6 +186,23 @@ AC_DEFUN([GNUPG_BUILD_PROGRAM], +# GNUPG_DISABLE_GPG_ALGO(NAME,DESCRIPTION) +# +# Add a --disable-gpg-NAME option and the corresponding ac_define +# GPG_USE_. +AC_DEFUN([GNUPG_GPG_DISABLE_ALGO], + [AC_MSG_CHECKING([whether to enable the $2 for gpg]) + AC_ARG_ENABLE([gpg-$1], AC_HELP_STRING([--disable-gpg-$1], + [disable the $2 algorithm in gpg]), + , enableval=yes) + AC_MSG_RESULT($enableval) + if test x"$enableval" = xyes ; then + AC_DEFINE(GPG_USE_[]m4_toupper($1), 1, [Define to support the $2]) + fi + ]) + + + # 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) diff --git a/configure.ac b/configure.ac index f4b2d38..9476dc4 100644 --- a/configure.ac +++ b/configure.ac @@ -212,6 +212,39 @@ AC_ARG_ENABLE(selinux-support, selinux_support=$enableval, selinux_support=no) AC_MSG_RESULT($selinux_support) + +# +# Options to disable algorithm +# + +GNUPG_GPG_DISABLE_ALGO([rsa],[RSA public key]) +# Elgamal is a MUST algorithm +# DSA is a MUST algorithm +GNUPG_GPG_DISABLE_ALGO([ecdh],[ECDH public key]) +GNUPG_GPG_DISABLE_ALGO([ecdsa],[ECDSA public key]) +GNUPG_GPG_DISABLE_ALGO([eddsa],[EdDSA public key]) + +GNUPG_GPG_DISABLE_ALGO([idea],[IDEA cipher]) +# 3DES is a MUST algorithm +GNUPG_GPG_DISABLE_ALGO([cast5],[CAST5 cipher]) +GNUPG_GPG_DISABLE_ALGO([blowfish],[BLOWFISH cipher]) +GNUPG_GPG_DISABLE_ALGO([aes128],[AES128 cipher]) +GNUPG_GPG_DISABLE_ALGO([aes192],[AES192 cipher]) +GNUPG_GPG_DISABLE_ALGO([aes256],[AES256 cipher]) +GNUPG_GPG_DISABLE_ALGO([twofish],[TWOFISH cipher]) +GNUPG_GPG_DISABLE_ALGO([camellia128],[CAMELLIA128 cipher]) +GNUPG_GPG_DISABLE_ALGO([camellia192],[CAMELLIA192 cipher]) +GNUPG_GPG_DISABLE_ALGO([camellia256],[CAMELLIA256 cipher]) + +GNUPG_GPG_DISABLE_ALGO([md5],[MD5 hash]) +# SHA1 is a MUSt algorithm +GNUPG_GPG_DISABLE_ALGO([rmd160],[RIPE-MD160 hash]) +GNUPG_GPG_DISABLE_ALGO([sha224],[SHA-224 hash]) +GNUPG_GPG_DISABLE_ALGO([sha256],[SHA-256 hash]) +GNUPG_GPG_DISABLE_ALGO([sha384],[SHA-384 hash]) +GNUPG_GPG_DISABLE_ALGO([sha512],[SHA-512 hash]) + + # Allow disabling of zip support. # This is in general not a good idea because according to rfc4880 OpenPGP # implementations SHOULD support ZLIB. diff --git a/g10/misc.c b/g10/misc.c index 6d3a7b8..ef26a5a 100644 --- a/g10/misc.c +++ b/g10/misc.c @@ -348,17 +348,37 @@ map_cipher_openpgp_to_gcry (cipher_algo_t algo) switch (algo) { case CIPHER_ALGO_NONE: return GCRY_CIPHER_NONE; +#ifdef GPG_USE_IDEA case CIPHER_ALGO_IDEA: return GCRY_CIPHER_IDEA; +#endif case CIPHER_ALGO_3DES: return GCRY_CIPHER_3DES; +#ifdef GPG_USE_CAST5 case CIPHER_ALGO_CAST5: return GCRY_CIPHER_CAST5; +#endif +#ifdef GPG_USE_BLOWFISH case CIPHER_ALGO_BLOWFISH: return GCRY_CIPHER_BLOWFISH; +#endif +#ifdef GPG_USE_AES128 case CIPHER_ALGO_AES: return GCRY_CIPHER_AES; +#endif +#ifdef GPG_USE_AES192 case CIPHER_ALGO_AES192: return GCRY_CIPHER_AES192; +#endif +#ifdef GPG_USE_AES256 case CIPHER_ALGO_AES256: return GCRY_CIPHER_AES256; +#endif +#ifdef GPG_USE_TWOFISH case CIPHER_ALGO_TWOFISH: return GCRY_CIPHER_TWOFISH; +#endif +#ifdef GPG_USE_CAMELLIA128 case CIPHER_ALGO_CAMELLIA128: return GCRY_CIPHER_CAMELLIA128; +#endif +#ifdef GPG_USE_CAMELLIA192 case CIPHER_ALGO_CAMELLIA192: return GCRY_CIPHER_CAMELLIA192; +#endif +#ifdef GPG_USE_CAMELLIA256 case CIPHER_ALGO_CAMELLIA256: return GCRY_CIPHER_CAMELLIA256; +#endif } return 0; } @@ -437,17 +457,6 @@ openpgp_cipher_test_algo (cipher_algo_t algo) enum gcry_cipher_algos ga; ga = map_cipher_openpgp_to_gcry (algo); - - /* Use this explicit list to disable certain algorithms. */ - switch (algo) - { - /* case CIPHER_ALGO_IDEA: */ - /* ga = 0; */ - /* break; */ - default: - break; - } - if (!ga) return gpg_error (GPG_ERR_CIPHER_ALGO); @@ -497,15 +506,23 @@ openpgp_pk_test_algo2 (pubkey_algo_t algo, unsigned int use) switch (algo) { +#ifdef GPG_USE_RSA case PUBKEY_ALGO_RSA: ga = GCRY_PK_RSA; break; case PUBKEY_ALGO_RSA_E: ga = GCRY_PK_RSA_E; break; case PUBKEY_ALGO_RSA_S: ga = GCRY_PK_RSA_S; break; +#endif case PUBKEY_ALGO_ELGAMAL_E: ga = GCRY_PK_ELG; break; case PUBKEY_ALGO_DSA: ga = GCRY_PK_DSA; break; - case PUBKEY_ALGO_ECDH: - case PUBKEY_ALGO_ECDSA: +#ifdef GPG_USE_ECDH + case PUBKEY_ALGO_ECDH: ga = GCRY_PK_ECC; break; +#endif +#ifdef GPG_USE_ECDSA + case PUBKEY_ALGO_ECDSA: ga = GCRY_PK_ECC; break; +#endif +#ifdef GPG_USE_EDDSA case PUBKEY_ALGO_EDDSA: ga = GCRY_PK_ECC; break; +#endif case PUBKEY_ALGO_ELGAMAL: /* Dont't allow type 20 keys unless in rfc2440 mode. */ @@ -587,32 +604,38 @@ map_md_openpgp_to_gcry (digest_algo_t algo) { switch (algo) { +#ifdef GPG_USE_MD5 case DIGEST_ALGO_MD5: return GCRY_MD_MD5; +#endif case DIGEST_ALGO_SHA1: return GCRY_MD_SHA1; +#ifdef GPG_USE_RMD160 case DIGEST_ALGO_RMD160: return GCRY_MD_RMD160; +#endif +#ifdef GPG_USE_SHA224 case DIGEST_ALGO_SHA224: return GCRY_MD_SHA224; +#endif +#ifdef GPG_USE_SHA256 case DIGEST_ALGO_SHA256: return GCRY_MD_SHA256; +#endif +#ifdef GPG_USE_SHA384 case DIGEST_ALGO_SHA384: return GCRY_MD_SHA384; +#endif +#ifdef GPG_USE_512 case DIGEST_ALGO_SHA512: return GCRY_MD_SHA512; +#endif } return 0; } /* Return 0 if ALGO is suitable and implemented OpenPGP hash - algorithm. Note: To only test for a valid OpenPGP hash algorithm, - it is better to use map_md_openpgp_to_gcry. */ + algorithm. */ int openpgp_md_test_algo (digest_algo_t algo) { enum gcry_md_algos ga; ga = map_md_openpgp_to_gcry (algo); - switch (algo) - { - default: - break; - } if (!ga) return gpg_error (GPG_ERR_DIGEST_ALGO); ----------------------------------------------------------------------- Summary of changes: acinclude.m4 | 33 ++++++++++++++++++++++-------- configure.ac | 33 ++++++++++++++++++++++++++++++ g10/misc.c | 63 +++++++++++++++++++++++++++++++++++++++------------------- 3 files changed, 101 insertions(+), 28 deletions(-) hooks/post-receive -- The GNU Privacy Guard http://git.gnupg.org