From cvs at cvs.gnupg.org Wed Feb 1 04:59:55 2012 From: cvs at cvs.gnupg.org (by David Shaw) Date: Wed, 01 Feb 2012 04:59:55 +0100 Subject: [git] GnuPG - branch, STABLE-BRANCH-1-4, updated. gnupg-1.4.12-1-g509fe4c 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 509fe4ce5d50089776b072c33c199798d3defe8c (commit) from 75b347a2a191ad479123a57f935e27b78e079188 (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 509fe4ce5d50089776b072c33c199798d3defe8c Author: David Shaw Date: Tue Jan 31 21:30:05 2012 -0500 Honor --cert-digest-algo when recreating a cert. * g10/sign.c (update_keysig_packet): Honor --cert-digest-algo when recreating a cert. This is used by various things in --edit-key like setpref, primary, etc. Suggested by Christian Aistleitner. diff --git a/g10/sign.c b/g10/sign.c index 5003e9e..462392d 100644 --- a/g10/sign.c +++ b/g10/sign.c @@ -1,6 +1,6 @@ /* sign.c - sign data * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - * 2007, 2010 Free Software Foundation, Inc. + * 2007, 2010, 2012 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -1489,7 +1489,7 @@ update_keysig_packet( PKT_signature **ret_sig, void *opaque ) { PKT_signature *sig; - int rc=0; + int rc=0, digest_algo; MD_HANDLE md; if ((!orig_sig || !pk || !sk) @@ -1497,7 +1497,12 @@ update_keysig_packet( PKT_signature **ret_sig, || (orig_sig->sig_class == 0x18 && !subpk)) return G10ERR_GENERAL; - md = md_open( orig_sig->digest_algo, 0 ); + if ( opt.cert_digest_algo ) + digest_algo = opt.cert_digest_algo; + else + digest_algo = orig_sig->digest_algo; + + md = md_open( digest_algo, 0 ); /* hash the public key certificate and the user id */ hash_public_key( md, pk ); ----------------------------------------------------------------------- Summary of changes: g10/sign.c | 11 ++++++++--- 1 files changed, 8 insertions(+), 3 deletions(-) hooks/post-receive -- The GNU Privacy Guard http://git.gnupg.org From cvs at cvs.gnupg.org Wed Feb 1 05:03:56 2012 From: cvs at cvs.gnupg.org (by David Shaw) Date: Wed, 01 Feb 2012 05:03:56 +0100 Subject: [git] GnuPG - branch, STABLE-BRANCH-2-0, updated. gnupg-2.0.18-18-g258192d 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-2-0 has been updated via 258192d4d453e27c4c54dbeefaae901ef94b5f4b (commit) from 4a9d69ca87d4e21b015b7ceab6b2b6ba3809ec22 (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 258192d4d453e27c4c54dbeefaae901ef94b5f4b Author: David Shaw Date: Tue Jan 31 21:30:05 2012 -0500 Honor --cert-digest-algo when recreating a cert. * g10/sign.c (update_keysig_packet): Honor --cert-digest-algo when recreating a cert. This is used by various things in --edit-key like setpref, primary, etc. Suggested by Christian Aistleitner. diff --git a/g10/sign.c b/g10/sign.c index 94e107c..8d280ed 100644 --- a/g10/sign.c +++ b/g10/sign.c @@ -1,6 +1,6 @@ /* sign.c - sign data * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - * 2007 Free Software Foundation, Inc. + * 2007, 2010, 2012 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -1504,7 +1504,7 @@ update_keysig_packet( PKT_signature **ret_sig, void *opaque ) { PKT_signature *sig; - int rc=0; + int rc=0, digest_algo; gcry_md_hd_t md; if ((!orig_sig || !pk || !sk) @@ -1512,6 +1512,11 @@ update_keysig_packet( PKT_signature **ret_sig, || (orig_sig->sig_class == 0x18 && !subpk)) return G10ERR_GENERAL; + if ( opt.cert_digest_algo ) + digest_algo = opt.cert_digest_algo; + else + digest_algo = orig_sig->digest_algo; + if ( gcry_md_open (&md, orig_sig->digest_algo, 0 ) ) BUG (); ----------------------------------------------------------------------- Summary of changes: g10/sign.c | 9 +++++++-- 1 files changed, 7 insertions(+), 2 deletions(-) hooks/post-receive -- The GNU Privacy Guard http://git.gnupg.org From cvs at cvs.gnupg.org Wed Feb 1 05:18:12 2012 From: cvs at cvs.gnupg.org (by David Shaw) Date: Wed, 01 Feb 2012 05:18:12 +0100 Subject: [git] GnuPG - branch, master, updated. gnupg-2.1.0beta3-39-g2b3cb2e 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 2b3cb2ee94625498e7a7f939216c9bcddef6ec20 (commit) from bdde44ae8d4709e33c09781c3d37a5da2c7a5e0d (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 2b3cb2ee94625498e7a7f939216c9bcddef6ec20 Author: David Shaw Date: Tue Jan 31 21:30:05 2012 -0500 Honor --cert-digest-algo when recreating a cert. * g10/sign.c (update_keysig_packet): Honor --cert-digest-algo when recreating a cert. This is used by various things in --edit-key like setpref, primary, etc. Suggested by Christian Aistleitner. diff --git a/g10/sign.c b/g10/sign.c index 4cc813c..b2c8f0e 100644 --- a/g10/sign.c +++ b/g10/sign.c @@ -1,6 +1,6 @@ /* sign.c - sign data * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - * 2007, 2010 Free Software Foundation, Inc. + * 2007, 2010, 2012 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -1576,7 +1576,7 @@ update_keysig_packet( PKT_signature **ret_sig, void *opaque) { PKT_signature *sig; - int rc=0; + int rc=0, digest_algo; gcry_md_hd_t md; if ((!orig_sig || !pk || !pksk) @@ -1584,6 +1584,11 @@ update_keysig_packet( PKT_signature **ret_sig, || (orig_sig->sig_class == 0x18 && !subpk)) return G10ERR_GENERAL; + if ( opt.cert_digest_algo ) + digest_algo = opt.cert_digest_algo; + else + digest_algo = orig_sig->digest_algo; + if ( gcry_md_open (&md, orig_sig->digest_algo, 0 ) ) BUG (); ----------------------------------------------------------------------- Summary of changes: g10/sign.c | 9 +++++++-- 1 files changed, 7 insertions(+), 2 deletions(-) hooks/post-receive -- The GNU Privacy Guard http://git.gnupg.org From cvs at cvs.gnupg.org Thu Feb 2 04:59:24 2012 From: cvs at cvs.gnupg.org (by Ben Kibbey) Date: Thu, 02 Feb 2012 04:59:24 +0100 Subject: [git] GnuPG - branch, master, updated. gnupg-2.1.0beta3-40-g3f7788f 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 3f7788f2e035eb939abb27b3a53854ec0fc6178c (commit) from 2b3cb2ee94625498e7a7f939216c9bcddef6ec20 (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 3f7788f2e035eb939abb27b3a53854ec0fc6178c Author: Ben Kibbey Date: Wed Feb 1 21:38:13 2012 -0500 Inform the client of the preset passphrase length. * agent/command.c (cmd_preset_passphrase): Send the INQUIRE_MAXLEN status message before inquiring the passphrase. diff --git a/agent/command.c b/agent/command.c index 5fa8bce..732046c 100644 --- a/agent/command.c +++ b/agent/command.c @@ -1696,7 +1696,13 @@ cmd_preset_passphrase (assuan_context_t ctx, char *line) { /* Note that the passphrase will be truncated at any null byte and the * limit is 480 characters. */ - rc = assuan_inquire (ctx, "PASSPHRASE", &passphrase, &len, 480); + char buf[50]; + size_t maxlen = 480; + + snprintf (buf, sizeof (buf), "%u", maxlen); + rc = assuan_write_status (ctx, "INQUIRE_MAXLEN", buf); + if (!rc) + rc = assuan_inquire (ctx, "PASSPHRASE", &passphrase, &len, maxlen); } else rc = set_error (GPG_ERR_NOT_IMPLEMENTED, "passphrase is required"); ----------------------------------------------------------------------- Summary of changes: agent/command.c | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletions(-) hooks/post-receive -- The GNU Privacy Guard http://git.gnupg.org From cvs at cvs.gnupg.org Sat Feb 4 01:13:56 2012 From: cvs at cvs.gnupg.org (by Ben Kibbey) Date: Sat, 04 Feb 2012 01:13:56 +0100 Subject: [git] GnuPG - branch, master, updated. gnupg-2.1.0beta3-41-gecda654 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 ecda65498ac60dfde50fbbc71cd0cc321d7175a9 (commit) from 3f7788f2e035eb939abb27b3a53854ec0fc6178c (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 ecda65498ac60dfde50fbbc71cd0cc321d7175a9 Author: Ben Kibbey Date: Fri Feb 3 17:50:22 2012 -0500 Also let GENKEY and PKDECRYPT send the INQUIRE_MAXLEN status message. * agent/command.c (cmd_pkdecrypt): Send the INQUIRE_MAXLEN status message before doing the inquire. (cmd_genkey): Ditto. diff --git a/agent/command.c b/agent/command.c index 732046c..c673662 100644 --- a/agent/command.c +++ b/agent/command.c @@ -855,12 +855,16 @@ cmd_pkdecrypt (assuan_context_t ctx, char *line) unsigned char *value; size_t valuelen; membuf_t outbuf; + char buf[50]; (void)line; /* First inquire the data to decrypt */ - rc = assuan_inquire (ctx, "CIPHERTEXT", - &value, &valuelen, MAXLEN_CIPHERTEXT); + snprintf (buf, sizeof (buf), "%u", MAXLEN_CIPHERTEXT); + rc = assuan_write_status (ctx, "INQUIRE_MAXLEN", buf); + if (!rc) + rc = assuan_inquire (ctx, "CIPHERTEXT", + &value, &valuelen, MAXLEN_CIPHERTEXT); if (rc) return rc; @@ -908,6 +912,7 @@ cmd_genkey (assuan_context_t ctx, char *line) char *cache_nonce = NULL; int opt_preset; char *p; + char buf[50]; opt_preset = has_option (line, "--preset"); no_protection = has_option (line, "--no-protection"); @@ -921,7 +926,10 @@ cmd_genkey (assuan_context_t ctx, char *line) cache_nonce = xtrystrdup (line); /* First inquire the parameters */ - rc = assuan_inquire (ctx, "KEYPARAM", &value, &valuelen, MAXLEN_KEYPARAM); + snprintf (buf, sizeof (buf), "%u", MAXLEN_KEYPARAM); + rc = assuan_write_status (ctx, "INQUIRE_MAXLEN", buf); + if (!rc) + rc = assuan_inquire (ctx, "KEYPARAM", &value, &valuelen, MAXLEN_KEYPARAM); if (rc) return rc; ----------------------------------------------------------------------- Summary of changes: agent/command.c | 14 +++++++++++--- 1 files changed, 11 insertions(+), 3 deletions(-) hooks/post-receive -- The GNU Privacy Guard http://git.gnupg.org From cvs at cvs.gnupg.org Mon Feb 6 22:04:42 2012 From: cvs at cvs.gnupg.org (by Werner Koch) Date: Mon, 06 Feb 2012 22:04:42 +0100 Subject: [git] GnuPG - branch, master, updated. gnupg-2.1.0beta3-45-g115a6ed 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 115a6ed55d1f6be33f66de6734359fa590ca3749 (commit) via 7981cdd1345d51fd917b2375691ead60c24db2cd (commit) via 1a0df8506050448f16c63666850e3ae6d94a971b (commit) via eb0faef81dae2cba1f62056fdc4dc2a7d58ac86a (commit) from ecda65498ac60dfde50fbbc71cd0cc321d7175a9 (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 115a6ed55d1f6be33f66de6734359fa590ca3749 Author: Werner Koch Date: Mon Feb 6 21:06:16 2012 +0100 Add replacement hack for Android's broken ttyname. * configure.ac (HAVE_TTYNAME) [__ANDROID__]: Add hack. diff --git a/configure.ac b/configure.ac index f008d23..47c6d12 100644 --- a/configure.ac +++ b/configure.ac @@ -490,6 +490,13 @@ AH_BOTTOM([ # endif #endif +/* Hacks required for Android. */ +#ifdef __ANDROID__ + /* ttyname is a stub in BIONIC, printing a FIXME warning. */ +# define ttyname broken_native_ttyname +# undef HAVE_TTYNAME +#endif /*__ANDROID__*/ + /* Tell libgcrypt not to use its own libgpg-error implementation. */ #define USE_LIBGPG_ERROR 1 commit 7981cdd1345d51fd917b2375691ead60c24db2cd Author: Werner Koch Date: Mon Feb 6 21:04:22 2012 +0100 agent: Simplify printing of INQUIRE_MAXLEN. * agent/command.c: Include asshelp.h. (cmd_pkdecrypt, cmd_genkey, cmd_preset_passphrase) (pinentry_loopback): Use print_assuan_status for INQUIRE_MAXLEN. diff --git a/agent/command.c b/agent/command.c index c673662..a369c4f 100644 --- a/agent/command.c +++ b/agent/command.c @@ -39,6 +39,7 @@ #include "i18n.h" #include "cvt-openpgp.h" #include "../common/ssh-utils.h" +#include "../common/asshelp.h" /* Maximum allowed size of the inquired ciphertext. */ @@ -855,13 +856,11 @@ cmd_pkdecrypt (assuan_context_t ctx, char *line) unsigned char *value; size_t valuelen; membuf_t outbuf; - char buf[50]; (void)line; /* First inquire the data to decrypt */ - snprintf (buf, sizeof (buf), "%u", MAXLEN_CIPHERTEXT); - rc = assuan_write_status (ctx, "INQUIRE_MAXLEN", buf); + rc = print_assuan_status (ctx, "INQUIRE_MAXLEN", "%u", MAXLEN_CIPHERTEXT); if (!rc) rc = assuan_inquire (ctx, "CIPHERTEXT", &value, &valuelen, MAXLEN_CIPHERTEXT); @@ -912,7 +911,6 @@ cmd_genkey (assuan_context_t ctx, char *line) char *cache_nonce = NULL; int opt_preset; char *p; - char buf[50]; opt_preset = has_option (line, "--preset"); no_protection = has_option (line, "--no-protection"); @@ -926,8 +924,7 @@ cmd_genkey (assuan_context_t ctx, char *line) cache_nonce = xtrystrdup (line); /* First inquire the parameters */ - snprintf (buf, sizeof (buf), "%u", MAXLEN_KEYPARAM); - rc = assuan_write_status (ctx, "INQUIRE_MAXLEN", buf); + rc = print_assuan_status (ctx, "INQUIRE_MAXLEN", "%u", MAXLEN_KEYPARAM); if (!rc) rc = assuan_inquire (ctx, "KEYPARAM", &value, &valuelen, MAXLEN_KEYPARAM); if (rc) @@ -1704,11 +1701,9 @@ cmd_preset_passphrase (assuan_context_t ctx, char *line) { /* Note that the passphrase will be truncated at any null byte and the * limit is 480 characters. */ - char buf[50]; size_t maxlen = 480; - snprintf (buf, sizeof (buf), "%u", maxlen); - rc = assuan_write_status (ctx, "INQUIRE_MAXLEN", buf); + rc = print_assuan_status (ctx, "INQUIRE_MAXLEN", "%u", maxlen); if (!rc) rc = assuan_inquire (ctx, "PASSPHRASE", &passphrase, &len, maxlen); } @@ -2805,10 +2800,8 @@ pinentry_loopback(ctrl_t ctrl, const char *keyword, { gpg_error_t rc; assuan_context_t ctx = ctrl->server_local->assuan_ctx; - char buf[50]; - snprintf (buf, sizeof (buf), "%u", max_length); - rc = assuan_write_status (ctx, "INQUIRE_MAXLEN", buf); + rc = print_assuan_status (ctx, "INQUIRE_MAXLEN", "%u", max_length); if (rc) return rc; commit 1a0df8506050448f16c63666850e3ae6d94a971b Author: Werner Koch Date: Mon Feb 6 20:52:27 2012 +0100 common: Add function print_assuan_status. * common/asshelp2.c: New. (print_assuan_status): New function. * common/Makefile.am (common_sources): Add asshelp2.c. diff --git a/common/Makefile.am b/common/Makefile.am index 2ff4ade..b9cba11 100644 --- a/common/Makefile.am +++ b/common/Makefile.am @@ -79,7 +79,7 @@ common_sources = \ membuf.c membuf.h \ iobuf.c iobuf.h \ ttyio.c ttyio.h \ - asshelp.c asshelp.h \ + asshelp.c asshelp2.c asshelp.h \ exechelp.h \ signal.c \ audit.c audit.h \ diff --git a/common/asshelp.h b/common/asshelp.h index 728c039..68be289 100644 --- a/common/asshelp.h +++ b/common/asshelp.h @@ -25,6 +25,8 @@ #include "session-env.h" +/*-- asshelp.c --*/ + void setup_libassuan_logging (unsigned int *debug_var_address); void set_libassuan_log_cats (unsigned int newcats); @@ -62,5 +64,14 @@ start_new_dirmngr (assuan_context_t *r_ctx, ctrl_t status_cb_arg); +/*-- asshelp2.c --*/ + +/* Helper function to print an assuan status line using a printf + format string. */ +gpg_error_t print_assuan_status (assuan_context_t ctx, + const char *keyword, + const char *format, + ...) JNLIB_GCC_A_PRINTF(3,4); + #endif /*GNUPG_COMMON_ASSHELP_H*/ diff --git a/common/asshelp2.c b/common/asshelp2.c new file mode 100644 index 0000000..762a14d --- /dev/null +++ b/common/asshelp2.c @@ -0,0 +1,49 @@ +/* asshelp2.c - More helper functions for Assuan + * Copyright (C) 2012 Free Software Foundation, Inc. + * + * This file is part of GnuPG. + * + * GnuPG is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * GnuPG is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + */ + +#include +#include +#include +#include +#include +#include + +#include "util.h" +#include "asshelp.h" + +/* Helper function to print an assuan status line using a printf + format string. */ +gpg_error_t +print_assuan_status (assuan_context_t ctx, + const char *keyword, + const char *format, ...) +{ + va_list arg_ptr; + int rc; + char *buf; + + va_start (arg_ptr, format); + rc = estream_vasprintf (&buf, format, arg_ptr); + va_end (arg_ptr); + if (rc < 0) + return gpg_err_make (default_errsource, gpg_err_code_from_syserror ()); + rc = assuan_write_status (ctx, keyword, buf); + xfree (buf); + return rc; +} commit eb0faef81dae2cba1f62056fdc4dc2a7d58ac86a Author: Werner Koch Date: Mon Feb 6 20:50:47 2012 +0100 common: Add a global variable to for the default error source. For the shared code parts it is cumbersome to pass an error sourse variable to each function. Its value is always a constant for a given binary and thus a global variable makes things a lot easier than the former macro stuff. * common/init.c (default_errsource): New global var. (init_common_subsystems): Rename to _init_common_subsystems. Set DEFAULT_ERRSOURCE. * common/init.h: Assert value of GPG_ERR_SOURCE_DEFAULT. (init_common_subsystems): New macro. * common/util.h (default_errsource): Add declaration. * kbx/keybox-defs.h: Add some GPG_ERR_SOURCE_DEFAULT trickery. diff --git a/agent/gpg-agent.c b/agent/gpg-agent.c index bc5a6cd..3a86867 100644 --- a/agent/gpg-agent.c +++ b/agent/gpg-agent.c @@ -52,6 +52,8 @@ #include "exechelp.h" #include "asshelp.h" #include "../include/cipher.h" /* for PUBKEY_ALGO_ECDSA, PUBKEY_ALGO_ECDH */ +#include "../common/init.h" + enum cmd_and_opt_values { aNull = 0, diff --git a/agent/preset-passphrase.c b/agent/preset-passphrase.c index f303d5b..3f79336 100644 --- a/agent/preset-passphrase.c +++ b/agent/preset-passphrase.c @@ -46,6 +46,7 @@ #include "simple-pwquery.h" #include "i18n.h" #include "sysutils.h" +#include "../common/init.h" enum cmd_and_opt_values diff --git a/agent/protect-tool.c b/agent/protect-tool.c index a253143..57842a0 100644 --- a/agent/protect-tool.c +++ b/agent/protect-tool.c @@ -43,6 +43,7 @@ #include "i18n.h" #include "get-passphrase.h" #include "sysutils.h" +#include "../common/init.h" enum cmd_and_opt_values diff --git a/common/init.c b/common/init.c index f551416..475eaef 100644 --- a/common/init.c +++ b/common/init.c @@ -37,6 +37,12 @@ #include "util.h" +/* The default error source of the application. This is different + from GPG_ERR_SOURCE_DEFAULT in that it does not depend on the + source file and thus is usable in code shared by applications. */ +gpg_err_source_t default_errsource; + + #ifdef HAVE_W32CE_SYSTEM static void parse_std_file_handles (int *argcp, char ***argvp); static void @@ -74,10 +80,16 @@ writestring_via_estream (int mode, const char *string) required for logging is ready. ARGCP and ARGVP are the addresses of the parameters given to main. This function may modify them. + This function should be called only via the macro + init_common_subsystems. + CAUTION: This might be called while running suid(root). */ void -init_common_subsystems (int *argcp, char ***argvp) +_init_common_subsystems (gpg_err_source_t errsource, int *argcp, char ***argvp) { + /* Store the error source in a gloabl variable. */ + default_errsource = errsource; + /* Try to auto set the character set. */ set_native_charset (NULL); diff --git a/common/init.h b/common/init.h index e8fe499..b13c060 100644 --- a/common/init.h +++ b/common/init.h @@ -1,5 +1,5 @@ /* init.h - Definitions for init fucntions. - * Copyright (C) 2007 Free Software Foundation, Inc. + * Copyright (C) 2007, 2012 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -20,7 +20,15 @@ #ifndef GNUPG_COMMON_INIT_H #define GNUPG_COMMON_INIT_H -void init_common_subsystems (int *argcp, char ***argvp); +#ifndef GPG_ERR_SOURCE_DEFAULT +# error GPG_ERR_SOURCE_DEFAULT is not defined +#elseif GPG_ERR_SOURCE_DEFAULT == GPG_ERR_SOURCE_UNKNOWN +# error GPG_ERR_SOURCE_DEFAULT has default value +#endif +void _init_common_subsystems (gpg_err_source_t errsource, + int *argcp, char ***argvp); +#define init_common_subsystems(a,b) \ + _init_common_subsystems (GPG_ERR_SOURCE_DEFAULT, (a), (b)) #endif /*GNUPG_COMMON_INIT_H*/ diff --git a/common/util.h b/common/util.h index 9381f29..5ea7b81 100644 --- a/common/util.h +++ b/common/util.h @@ -63,7 +63,6 @@ #include "../common/utf8conv.h" #include "../common/dynload.h" -#include "init.h" #include "gettime.h" /* Redefine asprintf by our estream version which uses our own memory @@ -113,6 +112,12 @@ typedef char **rl_completion_func_t (const char *, int, int); #define xmalloc_clear(a) gcry_xcalloc (1, (a)) #define xmalloc_secure_clear(a) gcry_xcalloc_secure (1, (a)) +/* The default error source of the application. This is different + from GPG_ERR_SOURCE_DEFAULT in that it does not depend on the + source file and thus is usable in code shared by applications. + Defined by init.c. */ +extern gpg_err_source_t default_errsource; + /* Convenience function to return a gpg-error code for memory allocation failures. This function makes sure that an error will be returned even if accidently ERRNO is not set. */ diff --git a/dirmngr/dirmngr.c b/dirmngr/dirmngr.c index b0410af..ee85718 100644 --- a/dirmngr/dirmngr.c +++ b/dirmngr/dirmngr.c @@ -56,6 +56,7 @@ #include "ldapserver.h" #include "asshelp.h" #include "ldap-wrapper.h" +#include "../common/init.h" /* The plain Windows version uses the windows service system. For example to start the service you may use "sc start dirmngr". diff --git a/dirmngr/dirmngr_ldap.c b/dirmngr/dirmngr_ldap.c index f166f19..2e73493 100644 --- a/dirmngr/dirmngr_ldap.c +++ b/dirmngr/dirmngr_ldap.c @@ -57,6 +57,7 @@ #include "i18n.h" #include "util.h" +#include "../common/init.h" /* With the ldap wrapper, there is no need for the npth_unprotect and leave functions; thus we redefine them to nops. If we are not using the diff --git a/g10/gpg.c b/g10/gpg.c index aa37a88..07d5172 100644 --- a/g10/gpg.c +++ b/g10/gpg.c @@ -55,6 +55,7 @@ #include "gc-opt-flags.h" #include "asshelp.h" #include "call-dirmngr.h" +#include "../common/init.h" #if defined(HAVE_DOSISH_SYSTEM) || defined(__CYGWIN__) #define MY_O_BINARY O_BINARY diff --git a/g10/gpgv.c b/g10/gpgv.c index b62ab82..07e4a2e 100644 --- a/g10/gpgv.c +++ b/g10/gpgv.c @@ -49,6 +49,7 @@ #include "sysutils.h" #include "status.h" #include "call-agent.h" +#include "../common/init.h" enum cmd_and_opt_values { diff --git a/g13/g13.c b/g13/g13.c index b33ea61..6fc83b5 100644 --- a/g13/g13.c +++ b/g13/g13.c @@ -36,6 +36,7 @@ #include "sysutils.h" #include "gc-opt-flags.h" #include "asshelp.h" +#include "../common/init.h" #include "keyblob.h" #include "server.h" #include "runner.h" diff --git a/kbx/kbxutil.c b/kbx/kbxutil.c index 333c286..9762add 100644 --- a/kbx/kbxutil.c +++ b/kbx/kbxutil.c @@ -34,11 +34,11 @@ #include "../common/stringhelp.h" #include "../common/utf8conv.h" #include "i18n.h" -#include "init.h" #include "keybox-defs.h" - +#include "../common/init.h" #include + enum cmd_and_opt_values { aNull = 0, oArmor = 'a', diff --git a/kbx/keybox-defs.h b/kbx/keybox-defs.h index aad07f9..9a29302 100644 --- a/kbx/keybox-defs.h +++ b/kbx/keybox-defs.h @@ -21,9 +21,12 @@ #define KEYBOX_DEFS_H 1 #ifdef GPG_ERR_SOURCE_DEFAULT -#error GPG_ERR_SOURCE_DEFAULT already defined +# if GPG_ERR_SOURCE_DEFAULT != GPG_ERR_SOURCE_KEYBOX +# error GPG_ERR_SOURCE_DEFAULT already defined +# endif +#else +# define GPG_ERR_SOURCE_DEFAULT GPG_ERR_SOURCE_KEYBOX #endif -#define GPG_ERR_SOURCE_DEFAULT GPG_ERR_SOURCE_KEYBOX #include #define map_assuan_err(a) \ map_assuan_err_with_source (GPG_ERR_SOURCE_DEFAULT, (a)) diff --git a/scd/scdaemon.c b/scd/scdaemon.c index e8073b7..7e7850d 100644 --- a/scd/scdaemon.c +++ b/scd/scdaemon.c @@ -53,6 +53,8 @@ #include "mkdtemp.h" #include "gc-opt-flags.h" #include "asshelp.h" +#include "../common/init.h" + enum cmd_and_opt_values { aNull = 0, diff --git a/sm/gpgsm.c b/sm/gpgsm.c index 7164f42..b2d1d2f 100644 --- a/sm/gpgsm.c +++ b/sm/gpgsm.c @@ -38,6 +38,8 @@ #include "sysutils.h" #include "gc-opt-flags.h" #include "asshelp.h" +#include "../common/init.h" + #ifndef O_BINARY #define O_BINARY 0 diff --git a/tools/gpg-check-pattern.c b/tools/gpg-check-pattern.c index 42a6c62..e6b8b27 100644 --- a/tools/gpg-check-pattern.c +++ b/tools/gpg-check-pattern.c @@ -45,9 +45,10 @@ #include "util.h" #include "i18n.h" #include "sysutils.h" +#include "../common/init.h" -enum cmd_and_opt_values +enum cmd_and_opt_values { aNull = 0, oVerbose = 'v', oArmor = 'a', @@ -66,12 +67,12 @@ enum cmd_and_opt_values /* The list of commands and options. */ static ARGPARSE_OPTS opts[] = { - + { 301, NULL, 0, N_("@Options:\n ") }, { oVerbose, "verbose", 0, "verbose" }, - { oHomedir, "homedir", 2, "@" }, + { oHomedir, "homedir", 2, "@" }, { oCheck, "check", 0, "run only a syntax check on the patternfile" }, { oNull, "null", 0, "input is expected to be null delimited" }, @@ -80,7 +81,7 @@ static ARGPARSE_OPTS opts[] = { /* Global options are accessed through the usual OPT structure. */ -static struct +static struct { int verbose; const char *homedir; @@ -99,7 +100,7 @@ enum { /* An object to decibe an item of our pattern table. */ struct pattern_s { - int type; + int type; unsigned int lineno; /* Line number of the pattern file. */ union { struct { @@ -111,7 +112,7 @@ struct pattern_s we need for PAT_STRING and we expect only a few regex in a patternfile. It would be a waste of core to have so many unused stuff in the table. */ - regex_t *regex; + regex_t *regex; } r; /*PAT_REGEX*/ } u; }; @@ -141,14 +142,14 @@ my_strusage (int level) case 19: p = _("Please report bugs to <@EMAIL@>.\n"); break; case 1: - case 40: + case 40: p = _("Usage: gpg-check-pattern [options] patternfile (-h for help)\n"); break; - case 41: + case 41: p = _("Syntax: gpg-check-pattern [options] patternfile\n" "Check a passphrase given on stdin against the patternfile\n"); break; - + default: p = NULL; } return p; @@ -165,7 +166,7 @@ main (int argc, char **argv ) set_strusage (my_strusage); gcry_control (GCRYCTL_SUSPEND_SECMEM_WARN); - log_set_prefix ("gpg-check-pattern", 1); + log_set_prefix ("gpg-check-pattern", 1); /* Make sure that our subsystems are ready. */ i18n_init (); @@ -194,13 +195,13 @@ main (int argc, char **argv ) case oHomedir: opt.homedir = pargs.r.ret_str; break; case oCheck: opt.checkonly = 1; break; case oNull: opt.null = 1; break; - + default : pargs.err = 2; break; } } if (log_get_errorcount(0)) exit (2); - + if (argc != 1) usage (1); @@ -239,7 +240,7 @@ read_file (const char *fname, size_t *r_length) FILE *fp; char *buf; size_t buflen; - + if (!strcmp (fname, "-")) { size_t nread, bufsize = 0; @@ -251,7 +252,7 @@ read_file (const char *fname, size_t *r_length) buf = NULL; buflen = 0; #define NCHUNK 8192 - do + do { bufsize += NCHUNK; if (!buf) @@ -282,14 +283,14 @@ read_file (const char *fname, size_t *r_length) log_error ("can't open `%s': %s\n", fname, strerror (errno)); return NULL; } - + if (fstat (fileno(fp), &st)) { log_error ("can't stat `%s': %s\n", fname, strerror (errno)); fclose (fp); return NULL; } - + buflen = st.st_size; buf = xmalloc (buflen+1); if (fread (buf, buflen, 1, fp) != 1) @@ -331,7 +332,7 @@ parse_pattern_file (char *data, size_t datalen) pattern_t *array; size_t arraysize, arrayidx; unsigned int lineno = 0; - + /* Estimate the number of entries by counting the non-comment lines. */ arraysize = 0; p = data; @@ -456,7 +457,7 @@ process (FILE *fp, pattern_t *patarray) int c; unsigned long lineno = 0; pattern_t *pat; - + idx = 0; c = 0; while (idx < sizeof buffer -1 && c != EOF ) diff --git a/tools/gpg-connect-agent.c b/tools/gpg-connect-agent.c index 7472728..d340c7f 100644 --- a/tools/gpg-connect-agent.c +++ b/tools/gpg-connect-agent.c @@ -37,6 +37,7 @@ #ifdef HAVE_W32_SYSTEM # include "../common/exechelp.h" #endif +#include "../common/init.h" #define CONTROL_D ('D' - 'A' + 1) diff --git a/tools/gpgconf.c b/tools/gpgconf.c index da10e4d..cff6e4b 100644 --- a/tools/gpgconf.c +++ b/tools/gpgconf.c @@ -26,6 +26,8 @@ #include "gpgconf.h" #include "i18n.h" #include "sysutils.h" +#include "../common/init.h" + /* Constants to identify the commands and options. */ enum cmd_and_opt_values diff --git a/tools/gpgtar.c b/tools/gpgtar.c index ace45c4..b6dd5e1 100644 --- a/tools/gpgtar.c +++ b/tools/gpgtar.c @@ -37,6 +37,7 @@ #include "i18n.h" #include "sysutils.h" #include "../common/openpgpdefs.h" +#include "../common/init.h" #include "gpgtar.h" @@ -71,7 +72,7 @@ enum cmd_and_opt_values /* The list of commands and options. */ static ARGPARSE_OPTS opts[] = { ARGPARSE_group (300, N_("@Commands:\n ")), - + ARGPARSE_c (aEncrypt, "encrypt", N_("create an archive")), ARGPARSE_c (aDecrypt, "decrypt", N_("extract an archive")), ARGPARSE_c (aSign, "sign", N_("create a signed archive")), @@ -146,7 +147,7 @@ set_cmd (enum cmd_and_opt_values *ret_cmd, enum cmd_and_opt_values new_cmd) cmd = aSignEncrypt; else if (cmd == aEncrypt && new_cmd == aSign) cmd = aSignEncrypt; - else + else { log_error (_("conflicting commands\n")); exit (2); @@ -194,7 +195,7 @@ main (int argc, char **argv) case oNoVerbose: opt.verbose = 0; break; case oFilesFrom: files_from = pargs.r.ret_str; break; case oNull: null_names = 1; break; - + case aList: case aDecrypt: case aEncrypt: @@ -217,7 +218,7 @@ main (int argc, char **argv) default: pargs.err = 2; break; } } - + if ((files_from && !null_names) || (!files_from && null_names)) log_error ("--files-from and --null may only be used in conjunction\n"); if (files_from && strcmp (files_from, "-")) @@ -324,7 +325,7 @@ write_record (estream_t stream, const void *record) } else err = 0; - + return err; } @@ -341,9 +342,9 @@ openpgp_message_p (estream_t fp) if (ctb != EOF) { if (es_ungetc (ctb, fp)) - log_fatal ("error ungetting first byte: %s\n", + log_fatal ("error ungetting first byte: %s\n", gpg_strerror (gpg_error_from_syserror ())); - + if ((ctb & 0x80)) { switch ((ctb & 0x40) ? (ctb & 0x3f) : ((ctb>>2)&0xf)) diff --git a/tools/symcryptrun.c b/tools/symcryptrun.c index c75f637..942fafa 100644 --- a/tools/symcryptrun.c +++ b/tools/symcryptrun.c @@ -89,6 +89,7 @@ #define JNLIB_NEED_LOG_LOGV #include "i18n.h" #include "../common/util.h" +#include "../common/init.h" #include "mkdtemp.h" /* FIXME: Bah. For spwq_secure_free. */ ----------------------------------------------------------------------- Summary of changes: agent/command.c | 17 ++++---------- agent/gpg-agent.c | 2 + agent/preset-passphrase.c | 1 + agent/protect-tool.c | 1 + common/Makefile.am | 2 +- common/asshelp.h | 11 +++++++++ g13/be-truecrypt.c => common/asshelp2.c | 32 ++++++++++++++++++-------- common/init.c | 14 +++++++++++- common/init.h | 12 ++++++++- common/util.h | 7 +++++- configure.ac | 7 ++++++ dirmngr/dirmngr.c | 1 + dirmngr/dirmngr_ldap.c | 1 + g10/gpg.c | 1 + g10/gpgv.c | 1 + g13/g13.c | 1 + kbx/kbxutil.c | 4 +- kbx/keybox-defs.h | 7 ++++- scd/scdaemon.c | 2 + sm/gpgsm.c | 2 + tools/gpg-check-pattern.c | 37 ++++++++++++++++--------------- tools/gpg-connect-agent.c | 1 + tools/gpgconf.c | 2 + tools/gpgtar.c | 15 ++++++------ tools/symcryptrun.c | 1 + 25 files changed, 126 insertions(+), 56 deletions(-) copy g13/be-truecrypt.c => common/asshelp2.c (53%) hooks/post-receive -- The GNU Privacy Guard http://git.gnupg.org From cvs at cvs.gnupg.org Tue Feb 7 14:50:54 2012 From: cvs at cvs.gnupg.org (by Werner Koch) Date: Tue, 07 Feb 2012 14:50:54 +0100 Subject: [git] GnuPG - branch, master, updated. gnupg-2.1.0beta3-50-g12ea5c9 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 12ea5c904c0008a2adec2e8bbe45dac629548e7d (commit) via e78585cd0f553d92f332e33810ab636758bc88a2 (commit) from 508ffb4e02900e2d8785eec2293d001e97a26578 (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 12ea5c904c0008a2adec2e8bbe45dac629548e7d Author: Werner Koch Date: Tue Feb 7 13:51:47 2012 +0100 Use new status printing functions. * agent/command.c (cmd_geteventcounter): Get rid of static buffers. * scd/command.c (cmd_serialno, cmd_learn): Simplify by using print_assuan_status. diff --git a/agent/command.c b/agent/command.c index 6fd3f65..9de3e47 100644 --- a/agent/command.c +++ b/agent/command.c @@ -499,21 +499,13 @@ static gpg_error_t cmd_geteventcounter (assuan_context_t ctx, char *line) { ctrl_t ctrl = assuan_get_pointer (ctx); - char any_counter[25]; - char key_counter[25]; - char card_counter[25]; (void)line; - snprintf (any_counter, sizeof any_counter, "%u", eventcounter.any); - snprintf (key_counter, sizeof key_counter, "%u", eventcounter.key); - snprintf (card_counter, sizeof card_counter, "%u", eventcounter.card); - - return agent_write_status (ctrl, "EVENTCOUNTER", - any_counter, - key_counter, - card_counter, - NULL); + return agent_print_status (ctrl, "EVENTCOUNTER", "%u %u %u", + eventcounter.any, + eventcounter.key, + eventcounter.card); } diff --git a/scd/command.c b/scd/command.c index 4c3646c..21c1b20 100644 --- a/scd/command.c +++ b/scd/command.c @@ -40,7 +40,7 @@ #ifdef HAVE_LIBUSB #include "ccid-driver.h" #endif - +#include "asshelp.h" /* Maximum length allowed as a PIN; used for INQUIRE NEEDPIN */ #define MAXLEN_PIN 100 @@ -561,7 +561,6 @@ cmd_serialno (assuan_context_t ctx, char *line) { ctrl_t ctrl = assuan_get_pointer (ctx); int rc = 0; - char *serial_and_stamp; char *serial; time_t stamp; int retries = 0; @@ -587,15 +586,10 @@ cmd_serialno (assuan_context_t ctx, char *line) if (rc) return rc; - rc = estream_asprintf (&serial_and_stamp, "%s %lu", - serial, (unsigned long)stamp); + rc = print_assuan_status (ctx, "SERIALNO", "%s %lu", + serial, (unsigned long)stamp); xfree (serial); - if (rc < 0) - return out_of_core (); - rc = 0; - assuan_write_status (ctx, "SERIALNO", serial_and_stamp); - xfree (serial_and_stamp); - return 0; + return rc; } @@ -684,32 +678,32 @@ cmd_learn (assuan_context_t ctx, char *line) knows about this card */ if (!only_keypairinfo) { - char *serial_and_stamp; char *serial; time_t stamp; rc = app_get_serial_and_stamp (ctrl->app_ctx, &serial, &stamp); if (rc) return rc; - rc = estream_asprintf (&serial_and_stamp, "%s %lu", - serial, (unsigned long)stamp); - xfree (serial); + + rc = print_assuan_status (ctx, "SERIALNO", "%s %lu", + serial, (unsigned long)stamp); if (rc < 0) - return out_of_core (); - rc = 0; - assuan_write_status (ctx, "SERIALNO", serial_and_stamp); + { + xfree (serial); + return out_of_core (); + } if (!has_option (line, "--force")) { char *command; - rc = estream_asprintf (&command, "KNOWNCARDP %s", serial_and_stamp); + rc = estream_asprintf (&command, "KNOWNCARDP %s %lu", + serial, (unsigned long)stamp); if (rc < 0) { - xfree (serial_and_stamp); + xfree (serial); return out_of_core (); } - rc = 0; rc = assuan_inquire (ctx, command, NULL, NULL, 0); xfree (command); if (rc) @@ -717,12 +711,12 @@ cmd_learn (assuan_context_t ctx, char *line) if (gpg_err_code (rc) != GPG_ERR_ASS_CANCELED) log_error ("inquire KNOWNCARDP failed: %s\n", gpg_strerror (rc)); - xfree (serial_and_stamp); + xfree (serial); return rc; } /* Not canceled, so we have to proceeed. */ } - xfree (serial_and_stamp); + xfree (serial); } /* Let the application print out its collection of useful status commit e78585cd0f553d92f332e33810ab636758bc88a2 Author: Werner Koch Date: Tue Feb 7 12:46:32 2012 +0100 agent: New function agent_print_status. * common/asshelp2.c (vprint_assuan_status): New. (print_assuan_status): Re-implement using above func. * agent/command.c (agent_print_status): New. diff --git a/agent/agent.h b/agent/agent.h index 4f4e477..d345c66 100644 --- a/agent/agent.h +++ b/agent/agent.h @@ -288,6 +288,9 @@ int map_pk_openpgp_to_gcry (int openpgp_algo); gpg_error_t agent_inq_pinentry_launched (ctrl_t ctrl, unsigned long pid); gpg_error_t agent_write_status (ctrl_t ctrl, const char *keyword, ...) GNUPG_GCC_A_SENTINEL(0); +gpg_error_t agent_print_status (ctrl_t ctrl, const char *keyword, + const char *format, ...) + JNLIB_GCC_A_PRINTF(3,4); void bump_key_eventcounter (void); void bump_card_eventcounter (void); void start_command_handler (ctrl_t, gnupg_fd_t, gnupg_fd_t); diff --git a/agent/command.c b/agent/command.c index a369c4f..6fd3f65 100644 --- a/agent/command.c +++ b/agent/command.c @@ -413,6 +413,22 @@ agent_write_status (ctrl_t ctrl, const char *keyword, ...) } +/* This function is similar to print_assuan_status but takes a CTRL + arg instead of an assuan context as first argument. */ +gpg_error_t +agent_print_status (ctrl_t ctrl, const char *keyword, const char *format, ...) +{ + gpg_error_t err; + va_list arg_ptr; + assuan_context_t ctx = ctrl->server_local->assuan_ctx; + + va_start (arg_ptr, format); + err = vprint_assuan_status (ctx, keyword, format, arg_ptr); + va_end (arg_ptr); + return err; +} + + /* Helper to notify the client about a launched Pinentry. Because that might disturb some older clients, this is only done if enabled via an option. Returns an gpg error code. */ diff --git a/common/asshelp.h b/common/asshelp.h index 68be289..a6cf140 100644 --- a/common/asshelp.h +++ b/common/asshelp.h @@ -72,6 +72,10 @@ gpg_error_t print_assuan_status (assuan_context_t ctx, const char *keyword, const char *format, ...) JNLIB_GCC_A_PRINTF(3,4); +gpg_error_t vprint_assuan_status (assuan_context_t ctx, + const char *keyword, + const char *format, + va_list arg_ptr) JNLIB_GCC_A_PRINTF(3,0); #endif /*GNUPG_COMMON_ASSHELP_H*/ diff --git a/common/asshelp2.c b/common/asshelp2.c index 762a14d..2c0c9e8 100644 --- a/common/asshelp2.c +++ b/common/asshelp2.c @@ -30,20 +30,34 @@ /* Helper function to print an assuan status line using a printf format string. */ gpg_error_t -print_assuan_status (assuan_context_t ctx, - const char *keyword, - const char *format, ...) +vprint_assuan_status (assuan_context_t ctx, + const char *keyword, + const char *format, va_list arg_ptr) { - va_list arg_ptr; int rc; char *buf; - va_start (arg_ptr, format); rc = estream_vasprintf (&buf, format, arg_ptr); - va_end (arg_ptr); if (rc < 0) return gpg_err_make (default_errsource, gpg_err_code_from_syserror ()); rc = assuan_write_status (ctx, keyword, buf); xfree (buf); return rc; } + + +/* Helper function to print an assuan status line using a printf + format string. */ +gpg_error_t +print_assuan_status (assuan_context_t ctx, + const char *keyword, + const char *format, ...) +{ + va_list arg_ptr; + gpg_error_t err; + + va_start (arg_ptr, format); + err = vprint_assuan_status (ctx, keyword, format, arg_ptr); + va_end (arg_ptr); + return err; +} ----------------------------------------------------------------------- Summary of changes: agent/agent.h | 3 +++ agent/command.c | 32 ++++++++++++++++++++------------ common/asshelp.h | 4 ++++ common/asshelp2.c | 26 ++++++++++++++++++++------ scd/command.c | 38 ++++++++++++++++---------------------- 5 files changed, 63 insertions(+), 40 deletions(-) hooks/post-receive -- The GNU Privacy Guard http://git.gnupg.org From cvs at cvs.gnupg.org Tue Feb 7 15:16:06 2012 From: cvs at cvs.gnupg.org (by Werner Koch) Date: Tue, 07 Feb 2012 15:16:06 +0100 Subject: [git] GnuPG - branch, master, updated. gnupg-2.1.0beta3-51-gb817ae7 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 b817ae7df947093384a25797999a9aa187e20f9c (commit) from 12ea5c904c0008a2adec2e8bbe45dac629548e7d (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 b817ae7df947093384a25797999a9aa187e20f9c Author: Werner Koch Date: Tue Feb 7 14:17:33 2012 +0100 agent: Add pin length field to the shadowed private key format. This is not yet fully implemented. It will eventually allow to support pinpad equipped readers which do not support variable length pin lengths. * agent/protect.c (parse_shadow_info): Add optional arg R_PINLEN and parse pinlen info. Change all callers to pass NULL for it. diff --git a/agent/agent.h b/agent/agent.h index d345c66..45bc507 100644 --- a/agent/agent.h +++ b/agent/agent.h @@ -394,7 +394,7 @@ int agent_shadow_key (const unsigned char *pubkey, int agent_get_shadow_info (const unsigned char *shadowkey, unsigned char const **shadow_info); gpg_error_t parse_shadow_info (const unsigned char *shadow_info, - char **r_hexsn, char **r_idstr); + char **r_hexsn, char **r_idstr, int *r_pinlen); gpg_error_t s2k_hash_passphrase (const char *passphrase, int hashalgo, int s2kmode, const unsigned char *s2ksalt, diff --git a/agent/command.c b/agent/command.c index 9de3e47..88cd62c 100644 --- a/agent/command.c +++ b/agent/command.c @@ -1090,7 +1090,7 @@ do_one_keyinfo (ctrl_t ctrl, const unsigned char *grip, assuan_context_t ctx, if (shadow_info) { - err = parse_shadow_info (shadow_info, &serialno, &idstr); + err = parse_shadow_info (shadow_info, &serialno, &idstr, NULL); if (err) goto leave; } diff --git a/agent/divert-scd.c b/agent/divert-scd.c index 5926424..22cdf8e 100644 --- a/agent/divert-scd.c +++ b/agent/divert-scd.c @@ -44,7 +44,7 @@ ask_for_card (ctrl_t ctrl, const unsigned char *shadow_info, char **r_kid) *r_kid = NULL; - rc = parse_shadow_info (shadow_info, &want_sn, &want_kid); + rc = parse_shadow_info (shadow_info, &want_sn, &want_kid, NULL); if (rc) return rc; diff --git a/agent/keyformat.txt b/agent/keyformat.txt index 3ebba6e..7ba6af2 100644 --- a/agent/keyformat.txt +++ b/agent/keyformat.txt @@ -155,7 +155,12 @@ to keys stored on a token: The currently used protocol is "ti-v1" (token info version 1). The second list with the information has this layout: -(card_serial_number id_string_of_key) +(card_serial_number id_string_of_key fixed_pin_length) + +FIXED_PIN_LENGTH is optional. It can be used to store the length of +the PIN; a value of 0 indicates that this information is not +available. The rationale for this field is that some pinpad equipped +readers don't allow passing a variable length PIN. More items may be added to the list. diff --git a/agent/protect.c b/agent/protect.c index 64af4ed..68e1a04 100644 --- a/agent/protect.c +++ b/agent/protect.c @@ -1272,7 +1272,7 @@ agent_get_shadow_info (const unsigned char *shadowkey, required, NULL may be passed for them. */ gpg_error_t parse_shadow_info (const unsigned char *shadow_info, - char **r_hexsn, char **r_idstr) + char **r_hexsn, char **r_idstr, int *r_pinlen) { const unsigned char *s; size_t n; @@ -1281,6 +1281,8 @@ parse_shadow_info (const unsigned char *shadow_info, *r_hexsn = NULL; if (r_idstr) *r_idstr = NULL; + if (r_pinlen) + *r_pinlen = 0; s = shadow_info; if (*s != '(') @@ -1325,5 +1327,34 @@ parse_shadow_info (const unsigned char *shadow_info, (*r_idstr)[n] = 0; } + /* Parse the optional PINLEN. */ + n = snext (&s); + if (!n) + return 0; + + if (r_pinlen) + { + char *tmpstr = xtrymalloc (n+1); + if (!tmpstr) + { + if (r_hexsn) + { + xfree (*r_hexsn); + *r_hexsn = NULL; + } + if (r_idstr) + { + xfree (*r_idstr); + *r_idstr = NULL; + } + return gpg_error_from_syserror (); + } + memcpy (tmpstr, s, n); + tmpstr[n] = 0; + + *r_pinlen = (int)strtol (tmpstr, NULL, 10); + xfree (tmpstr); + } + return 0; } ----------------------------------------------------------------------- Summary of changes: agent/agent.h | 2 +- agent/command.c | 2 +- agent/divert-scd.c | 2 +- agent/keyformat.txt | 7 ++++++- agent/protect.c | 33 ++++++++++++++++++++++++++++++++- 5 files changed, 41 insertions(+), 5 deletions(-) hooks/post-receive -- The GNU Privacy Guard http://git.gnupg.org From cvs at cvs.gnupg.org Wed Feb 8 16:25:02 2012 From: cvs at cvs.gnupg.org (by Marcus Brinkmann) Date: Wed, 08 Feb 2012 16:25:02 +0100 Subject: [git] GPGME - branch, master, updated. gpgme-1.3.1-13-gdae3073 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 dae3073aaa8b7feb1c844fdaf711f79141b9cc65 (commit) via 0052a72f89c6830818e354358fdd84702d3494c8 (commit) via 3f03897cbd223d4a75eb62c3b7bdfeb800661641 (commit) from 24a10a4af948ebb1c767b69a92fa5bbe933a417c (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 dae3073aaa8b7feb1c844fdaf711f79141b9cc65 Author: Marcus Brinkmann Date: Wed Feb 8 15:26:17 2012 +0100 Use gpgme interface for error handling to avoid linking with gpg-error. * tests/t-data.c, tests/run-export.c, tests/run-keylist.c, tests/run-support.h, tests/run-verify.c, tests/gpg/t-decrypt-verify.c, tests/gpg/t-edit.c, tests/gpg/t-eventloop.c, tests/gpg/t-keylist-sig.c, tests/gpg/t-keylist.c, tests/gpg/t-support.h, tests/gpg/t-trustlist.c, tests/gpg/t-verify.c, tests/gpg/t-wait.c, tests/gpgsm/cms-decrypt.c, tests/gpgsm/cms-keylist.c, tests/gpgsm/t-keylist.c, tests/gpgsm/t-support.h, tests/gpgsm/t-verify.c, tests/opassuan/t-command.c: Use gpgme interface for gpg-error functions. diff --git a/tests/gpg/t-decrypt-verify.c b/tests/gpg/t-decrypt-verify.c index 697d383..113aec1 100644 --- a/tests/gpg/t-decrypt-verify.c +++ b/tests/gpg/t-decrypt-verify.c @@ -61,7 +61,7 @@ check_verify_result (gpgme_verify_result_t result, unsigned int summary, __FILE__, __LINE__, sig->fpr); exit (1); } - if (gpg_err_code (sig->status) != status) + if (gpgme_err_code (sig->status) != status) { fprintf (stderr, "%s:%i: Unexpected signature status: %s\n", __FILE__, __LINE__, gpgme_strerror (sig->status)); @@ -85,7 +85,7 @@ check_verify_result (gpgme_verify_result_t result, unsigned int summary, __FILE__, __LINE__, sig->validity); exit (1); } - if (gpg_err_code (sig->validity_reason) != GPG_ERR_NO_ERROR) + if (gpgme_err_code (sig->validity_reason) != GPG_ERR_NO_ERROR) { fprintf (stderr, "%s:%i: Unexpected validity reason: %s\n", __FILE__, __LINE__, gpgme_strerror (sig->validity_reason)); diff --git a/tests/gpg/t-edit.c b/tests/gpg/t-edit.c index 394379d..545db73 100644 --- a/tests/gpg/t-edit.c +++ b/tests/gpg/t-edit.c @@ -46,11 +46,11 @@ flush_data (gpgme_data_t dh) ret = gpgme_data_seek (dh, 0, SEEK_SET); if (ret) - fail_if_err (gpg_error_from_errno (errno)); + fail_if_err (gpgme_error_from_errno (errno)); while ((ret = gpgme_data_read (dh, buf, 100)) > 0) fwrite (buf, ret, 1, stdout); if (ret < 0) - fail_if_err (gpg_error_from_errno (errno)); + fail_if_err (gpgme_error_from_errno (errno)); } diff --git a/tests/gpg/t-eventloop.c b/tests/gpg/t-eventloop.c index bf1ab4e..cb1e57c 100644 --- a/tests/gpg/t-eventloop.c +++ b/tests/gpg/t-eventloop.c @@ -78,7 +78,7 @@ add_io_cb (void *data, int fd, int dir, gpgme_io_cb_t fnc, void *fnc_data, } } if (i == FDLIST_MAX) - return gpg_err_make (GPG_ERR_SOURCE_USER_1, GPG_ERR_GENERAL); + return gpgme_err_make (GPG_ERR_SOURCE_USER_1, GPG_ERR_GENERAL); *r_tag = &fds[i]; return 0; } diff --git a/tests/gpg/t-keylist-sig.c b/tests/gpg/t-keylist-sig.c index b89ba33..9482c74 100644 --- a/tests/gpg/t-keylist-sig.c +++ b/tests/gpg/t-keylist-sig.c @@ -605,14 +605,10 @@ main (int argc, char **argv) exit (1); } - - - - gpgme_key_unref (key); i++; } - if (gpg_err_code (err) != GPG_ERR_EOF) + if (gpgme_err_code (err) != GPG_ERR_EOF) fail_if_err (err); err = gpgme_op_keylist_end (ctx); fail_if_err (err); diff --git a/tests/gpg/t-keylist.c b/tests/gpg/t-keylist.c index 2c04935..67844cb 100644 --- a/tests/gpg/t-keylist.c +++ b/tests/gpg/t-keylist.c @@ -551,7 +551,7 @@ main (int argc, char **argv) gpgme_key_unref (key); i++; } - if (gpg_err_code (err) != GPG_ERR_EOF) + if (gpgme_err_code (err) != GPG_ERR_EOF) fail_if_err (err); err = gpgme_op_keylist_end (ctx); fail_if_err (err); diff --git a/tests/gpg/t-support.h b/tests/gpg/t-support.h index 6e282a3..6a18b5c 100644 --- a/tests/gpg/t-support.h +++ b/tests/gpg/t-support.h @@ -143,7 +143,7 @@ print_import_result (gpgme_import_result_t r) for (st=r->imports; st; st = st->next) { printf (" fpr: %s err: %d (%s) status:", nonnull (st->fpr), - st->result, gpg_strerror (st->result)); + st->result, gpgme_strerror (st->result)); if (st->status & GPGME_IMPORT_NEW) fputs (" new", stdout); if (st->status & GPGME_IMPORT_UID) diff --git a/tests/gpg/t-trustlist.c b/tests/gpg/t-trustlist.c index 7707639..5d24518 100644 --- a/tests/gpg/t-trustlist.c +++ b/tests/gpg/t-trustlist.c @@ -56,7 +56,7 @@ main (int argc, char *argv[]) item->validity, item->name); gpgme_trust_item_unref (item); } - if (gpg_err_code (err) != GPG_ERR_EOF) + if (gpgme_err_code (err) != GPG_ERR_EOF) fail_if_err (err); gpgme_release (ctx); diff --git a/tests/gpg/t-verify.c b/tests/gpg/t-verify.c index 0efd06f..dceabac 100644 --- a/tests/gpg/t-verify.c +++ b/tests/gpg/t-verify.c @@ -117,10 +117,10 @@ check_result (gpgme_verify_result_t result, unsigned int summary, char *fpr, __FILE__, __LINE__, sig->fpr); exit (1); } - if (gpg_err_code (sig->status) != status) + if (gpgme_err_code (sig->status) != status) { fprintf (stderr, "%s:%i: Unexpected signature status: %s\n", - __FILE__, __LINE__, gpg_strerror (sig->status)); + __FILE__, __LINE__, gpgme_strerror (sig->status)); exit (1); } if (notation) @@ -192,7 +192,7 @@ check_result (gpgme_verify_result_t result, unsigned int summary, char *fpr, __FILE__, __LINE__, sig->validity); exit (1); } - if (gpg_err_code (sig->validity_reason) != GPG_ERR_NO_ERROR) + if (gpgme_err_code (sig->validity_reason) != GPG_ERR_NO_ERROR) { fprintf (stderr, "%s:%i: Unexpected validity reason: %s\n", __FILE__, __LINE__, gpgme_strerror (sig->validity_reason)); @@ -259,7 +259,7 @@ main (int argc, char *argv[]) err = gpgme_data_new (&text); fail_if_err (err); err = gpgme_op_verify (ctx, sig, NULL, text); - if (gpg_err_code (err) != GPG_ERR_BAD_DATA) + if (gpgme_err_code (err) != GPG_ERR_BAD_DATA) { fprintf (stderr, "%s:%i: Double plaintext message not detected\n", __FILE__, __LINE__); diff --git a/tests/gpg/t-wait.c b/tests/gpg/t-wait.c index eec4d96..e58adad 100644 --- a/tests/gpg/t-wait.c +++ b/tests/gpg/t-wait.c @@ -61,7 +61,7 @@ main (int argc, char *argv[]) while (gpgme_wait (ctx, &err, 0) == NULL && err == 0) sleep(1); - if (gpg_err_code (err) != GPG_ERR_NO_DATA) + if (gpgme_err_code (err) != GPG_ERR_NO_DATA) { fprintf (stderr, "%s:%d: %s: %s\n", __FILE__, __LINE__, gpgme_strsource (err), diff --git a/tests/gpgsm/cms-decrypt.c b/tests/gpgsm/cms-decrypt.c index 767f87b..580832d 100644 --- a/tests/gpgsm/cms-decrypt.c +++ b/tests/gpgsm/cms-decrypt.c @@ -73,7 +73,7 @@ main (int argc, char **argv) err = gpgme_op_decrypt (ctx, in, out); printf ("gpgme_op_decrypt: %s <%s> (%u)\n", - gpg_strerror (err), gpg_strsource (err), err); + gpgme_strerror (err), gpgme_strsource (err), err); result = gpgme_op_decrypt_result (ctx); if (!result) { @@ -88,7 +88,7 @@ main (int argc, char **argv) for (recp = result->recipients; recp; recp = recp->next) { printf ("recipient.status: %s <%s> (%u)\n", - gpg_strerror (recp->status), gpg_strsource (recp->status), + gpgme_strerror (recp->status), gpgme_strsource (recp->status), recp->status); printf ("recipient.pkalgo: %d\n", recp->pubkey_algo); printf ("recipient.keyid : %s\n", nonnull (recp->keyid)); diff --git a/tests/gpgsm/cms-keylist.c b/tests/gpgsm/cms-keylist.c index 698a9d8..7ed3a4e 100644 --- a/tests/gpgsm/cms-keylist.c +++ b/tests/gpgsm/cms-keylist.c @@ -108,7 +108,7 @@ main (int argc, char **argv) gpgme_key_unref (key); } - if (gpg_err_code (err) != GPG_ERR_EOF) + if (gpgme_err_code (err) != GPG_ERR_EOF) fail_if_err (err); err = gpgme_op_keylist_end (ctx); fail_if_err (err); diff --git a/tests/gpgsm/t-keylist.c b/tests/gpgsm/t-keylist.c index 0f1cf33..bebd9d6 100644 --- a/tests/gpgsm/t-keylist.c +++ b/tests/gpgsm/t-keylist.c @@ -366,7 +366,7 @@ main (int argc, char **argv) gpgme_key_unref (key); i++; } - if (gpg_err_code (err) != GPG_ERR_EOF) + if (gpgme_err_code (err) != GPG_ERR_EOF) fail_if_err (err); err = gpgme_op_keylist_end (ctx); fail_if_err (err); diff --git a/tests/gpgsm/t-support.h b/tests/gpgsm/t-support.h index 6dc1456..cc1a7db 100644 --- a/tests/gpgsm/t-support.h +++ b/tests/gpgsm/t-support.h @@ -32,9 +32,9 @@ if (err) \ { \ fprintf (stderr, "%s:%d: %s: %s (%d.%d)\n", \ - __FILE__, __LINE__, gpg_strsource (err), \ - gpg_strerror (err), \ - gpg_err_source (err), gpg_err_code (err)); \ + __FILE__, __LINE__, gpgme_strsource (err), \ + gpgme_strerror (err), \ + gpgme_err_source (err), gpgme_err_code (err)); \ exit (1); \ } \ } \ @@ -50,11 +50,11 @@ print_data (gpgme_data_t dh) ret = gpgme_data_seek (dh, 0, SEEK_SET); if (ret) - fail_if_err (gpg_error_from_errno (errno)); + fail_if_err (gpgme_error_from_errno (errno)); while ((ret = gpgme_data_read (dh, buf, BUF_SIZE)) > 0) fwrite (buf, ret, 1, stdout); if (ret < 0) - fail_if_err (gpg_error_from_errno (errno)); + fail_if_err (gpgme_error_from_errno (errno)); } diff --git a/tests/gpgsm/t-verify.c b/tests/gpgsm/t-verify.c index d39487e..062c5a1 100644 --- a/tests/gpgsm/t-verify.c +++ b/tests/gpgsm/t-verify.c @@ -77,7 +77,7 @@ check_result (gpgme_verify_result_t result, int summary, char *fpr, __FILE__, __LINE__, sig->fpr); got_errors = 1; } - if (gpg_err_code (sig->status) != status) + if (gpgme_err_code (sig->status) != status) { fprintf (stderr, "%s:%i: Unexpected signature status: %s\n", __FILE__, __LINE__, gpgme_strerror (sig->status)); @@ -101,7 +101,7 @@ check_result (gpgme_verify_result_t result, int summary, char *fpr, __FILE__, __LINE__, sig->validity); got_errors = 1; } - if (gpg_err_code (sig->validity_reason) != GPG_ERR_NO_ERROR) + if (gpgme_err_code (sig->validity_reason) != GPG_ERR_NO_ERROR) { fprintf (stderr, "%s:%i: Unexpected validity reason: %s\n", __FILE__, __LINE__, gpgme_strerror (sig->validity_reason)); @@ -123,7 +123,7 @@ show_auditlog (gpgme_ctx_t ctx) { fprintf (stderr, "%s:%i: Can't get audit log: %s\n", __FILE__, __LINE__, gpgme_strerror (err)); - if (gpg_err_code (err) != GPG_ERR_ASS_UNKNOWN_CMD) + if (gpgme_err_code (err) != GPG_ERR_ASS_UNKNOWN_CMD) got_errors = 1; } print_data (data); diff --git a/tests/opassuan/t-command.c b/tests/opassuan/t-command.c index aa5f34c..87f8202 100644 --- a/tests/opassuan/t-command.c +++ b/tests/opassuan/t-command.c @@ -34,16 +34,16 @@ if (err) \ { \ fprintf (stderr, "%s:%d: %s: %s (%d.%d)\n", \ - __FILE__, __LINE__, gpg_strsource (err), \ - gpg_strerror (err), \ - gpg_err_source (err), gpg_err_code (err)); \ + __FILE__, __LINE__, gpgme_strsource (err), \ + gpgme_strerror (err), \ + gpgme_err_source (err), gpgme_err_code (err)); \ exit (1); \ } \ } \ while (0) -static gpg_error_t +static gpgme_error_t data_cb (void *opaque, const void *data, size_t datalen) { printf ("DATA_CB: datalen=%d\n", (int)datalen); @@ -51,12 +51,12 @@ data_cb (void *opaque, const void *data, size_t datalen) } -static gpg_error_t +static gpgme_error_t inq_cb (void *opaque, const char *name, const char *args, gpgme_data_t *r_data) { gpgme_data_t data; - gpg_error_t err; + gpgme_error_t err; if (name) { @@ -81,14 +81,14 @@ inq_cb (void *opaque, const char *name, const char *args, /* Uncomment the next lines and send a "SCD LEARN" to test sending cancel from in inquiry. */ /* if (name && !strcmp (name, "KNOWNCARDP")) */ - /* return gpg_error (GPG_ERR_ASS_CANCELED); */ + /* return gpgme_error (GPG_ERR_ASS_CANCELED); */ return 0; } -static gpg_error_t +static gpgme_error_t status_cb (void *opaque, const char *status, const char *args) { printf ("STATUS_CB: status=`%s' args=`%s'\n", status, args); diff --git a/tests/run-export.c b/tests/run-export.c index 8dddb5b..b70ed91 100644 --- a/tests/run-export.c +++ b/tests/run-export.c @@ -117,7 +117,7 @@ main (int argc, char **argv) gpgme_key_unref (key); } } - if (gpg_err_code (err) != GPG_ERR_EOF) + if (gpgme_err_code (err) != GPG_ERR_EOF) fail_if_err (err); err = gpgme_op_keylist_end (ctx); fail_if_err (err); diff --git a/tests/run-keylist.c b/tests/run-keylist.c index 8dd28b8..0f2154a 100644 --- a/tests/run-keylist.c +++ b/tests/run-keylist.c @@ -201,7 +201,7 @@ main (int argc, char **argv) else gpgme_key_unref (key); } - if (gpg_err_code (err) != GPG_ERR_EOF) + if (gpgme_err_code (err) != GPG_ERR_EOF) fail_if_err (err); err = gpgme_op_keylist_end (ctx); fail_if_err (err); diff --git a/tests/run-support.h b/tests/run-support.h index d7f0923..db7b7d5 100644 --- a/tests/run-support.h +++ b/tests/run-support.h @@ -142,7 +142,7 @@ print_import_result (gpgme_import_result_t r) for (st=r->imports; st; st = st->next) { printf (" fpr: %s err: %d (%s) status:", nonnull (st->fpr), - st->result, gpg_strerror (st->result)); + st->result, gpgme_strerror (st->result)); if (st->status & GPGME_IMPORT_NEW) fputs (" new", stdout); if (st->status & GPGME_IMPORT_UID) diff --git a/tests/run-verify.c b/tests/run-verify.c index 0dde815..4837d9c 100644 --- a/tests/run-verify.c +++ b/tests/run-verify.c @@ -94,14 +94,14 @@ print_result (gpgme_verify_result_t result) for (sig = result->signatures; sig; sig = sig->next) { printf ("Signature %d\n", count++); - printf (" status ....: %s\n", gpg_strerror (sig->status)); + printf (" status ....: %s\n", gpgme_strerror (sig->status)); printf (" summary ...:"); print_summary (sig->summary); putchar ('\n'); printf (" fingerprint: %s\n", nonnull (sig->fpr)); printf (" created ...: %lu\n", sig->timestamp); printf (" expires ...: %lu\n", sig->exp_timestamp); printf (" validity ..: "); print_validity (sig->validity); putchar ('\n'); - printf (" val.reason : %s\n", gpg_strerror (sig->status)); + printf (" val.reason : %s\n", gpgme_strerror (sig->status)); printf (" pubkey algo: %d\n", sig->pubkey_algo); printf (" digest algo: %d\n", sig->hash_algo); printf (" pka address: %s\n", nonnull (sig->pka_address)); @@ -185,9 +185,9 @@ main (int argc, char **argv) fp_sig = fopen (argv[0], "rb"); if (!fp_sig) { - err = gpg_error_from_syserror (); + err = gpgme_error_from_syserror (); fprintf (stderr, PGM ": can't open `%s': %s\n", - argv[0], gpg_strerror (err)); + argv[0], gpgme_strerror (err)); exit (1); } if (argc > 1) @@ -195,9 +195,9 @@ main (int argc, char **argv) fp_msg = fopen (argv[1], "rb"); if (!fp_msg) { - err = gpg_error_from_syserror (); + err = gpgme_error_from_syserror (); fprintf (stderr, PGM ": can't open `%s': %s\n", - argv[1], gpg_strerror (err)); + argv[1], gpgme_strerror (err)); exit (1); } } @@ -212,7 +212,7 @@ main (int argc, char **argv) if (err) { fprintf (stderr, PGM ": error allocating data object: %s\n", - gpg_strerror (err)); + gpgme_strerror (err)); exit (1); } if (fp_msg) @@ -221,7 +221,7 @@ main (int argc, char **argv) if (err) { fprintf (stderr, PGM ": error allocating data object: %s\n", - gpg_strerror (err)); + gpgme_strerror (err)); exit (1); } } @@ -232,7 +232,7 @@ main (int argc, char **argv) print_result (result); if (err) { - fprintf (stderr, PGM ": signing failed: %s\n", gpg_strerror (err)); + fprintf (stderr, PGM ": signing failed: %s\n", gpgme_strerror (err)); exit (1); } diff --git a/tests/t-data.c b/tests/t-data.c index 713da0a..a319484 100644 --- a/tests/t-data.c +++ b/tests/t-data.c @@ -163,7 +163,7 @@ write_test (round_t round, gpgme_data_t data) amt = gpgme_data_write (data, text, strlen (text)); if (amt != strlen (text)) - fail_if_err (gpg_error_from_errno (errno)); + fail_if_err (gpgme_error_from_errno (errno)); gpgme_data_seek (data, 0, SEEK_SET); @@ -237,8 +237,8 @@ main (int argc, char **argv) case TEST_INOUT_MEM_FROM_FILE_NO_COPY: err = gpgme_data_new_from_file (&data, text_filename, 0); /* This is not implemented yet. */ - if (gpg_err_code (err) == GPG_ERR_NOT_IMPLEMENTED - || gpg_err_code (err) == GPG_ERR_INV_VALUE) + if (gpgme_err_code (err) == GPG_ERR_NOT_IMPLEMENTED + || gpgme_err_code (err) == GPG_ERR_INV_VALUE) continue; break; case TEST_INOUT_MEM_FROM_FILE_PART_BY_NAME: commit 0052a72f89c6830818e354358fdd84702d3494c8 Author: Marcus Brinkmann Date: Wed Feb 8 15:19:33 2012 +0100 Link the thread test to pthread. * tests/gpg/Makefile.am (t_thread1_LDADD): Add -lpthread. diff --git a/tests/gpg/Makefile.am b/tests/gpg/Makefile.am index d4debd7..dd28d5e 100644 --- a/tests/gpg/Makefile.am +++ b/tests/gpg/Makefile.am @@ -48,7 +48,7 @@ INCLUDES = -I$(top_builddir)/src AM_CPPFLAGS = @GPG_ERROR_CFLAGS@ LDADD = ../../src/libgpgme.la -t_thread1_LDADD = ../../src/libgpgme-pthread.la +t_thread1_LDADD = ../../src/libgpgme-pthread.la -lpthread # We don't run t-genkey in the test suite, because it takes too long noinst_PROGRAMS = $(TESTS) t-genkey commit 3f03897cbd223d4a75eb62c3b7bdfeb800661641 Author: Marcus Brinkmann Date: Wed Feb 8 15:18:11 2012 +0100 Link gpgme-tool directly to libassuan, as it uses its interface. * src/Makefile.am (gpgme_tool_LDADD): Add @LIBASSUAN_LIBS at . diff --git a/src/Makefile.am b/src/Makefile.am index cc0b78d..e456d80 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -226,7 +226,7 @@ libgpgme_qt_la_LIBADD = $(gpgme_res) @LIBASSUAN_LIBS@ @LTLIBOBJS@ \ endif noinst_PROGRAMS = gpgme-tool -gpgme_tool_LDADD = libgpgme.la +gpgme_tool_LDADD = libgpgme.la @LIBASSUAN_LIBS@ status-table.h : gpgme.h extra-stati.h cat $(builddir)/gpgme.h $(srcdir)extra-stati.h \ ----------------------------------------------------------------------- Summary of changes: src/Makefile.am | 2 +- tests/gpg/Makefile.am | 2 +- tests/gpg/t-decrypt-verify.c | 4 ++-- tests/gpg/t-edit.c | 4 ++-- tests/gpg/t-eventloop.c | 2 +- tests/gpg/t-keylist-sig.c | 6 +----- tests/gpg/t-keylist.c | 2 +- tests/gpg/t-support.h | 2 +- tests/gpg/t-trustlist.c | 2 +- tests/gpg/t-verify.c | 8 ++++---- tests/gpg/t-wait.c | 2 +- tests/gpgsm/cms-decrypt.c | 4 ++-- tests/gpgsm/cms-keylist.c | 2 +- tests/gpgsm/t-keylist.c | 2 +- tests/gpgsm/t-support.h | 10 +++++----- tests/gpgsm/t-verify.c | 6 +++--- tests/opassuan/t-command.c | 16 ++++++++-------- tests/run-export.c | 2 +- tests/run-keylist.c | 2 +- tests/run-support.h | 2 +- tests/run-verify.c | 18 +++++++++--------- tests/t-data.c | 6 +++--- 22 files changed, 51 insertions(+), 55 deletions(-) hooks/post-receive -- GnuPG Made Easy http://git.gnupg.org From cvs at cvs.gnupg.org Tue Feb 14 14:34:02 2012 From: cvs at cvs.gnupg.org (by Marcus Brinkmann) Date: Tue, 14 Feb 2012 14:34:02 +0100 Subject: [git] GPGME - branch, master, updated. gpgme-1.3.1-14-g885243e 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 885243e05467e79e2375b3febe7904053ab45dfc (commit) from dae3073aaa8b7feb1c844fdaf711f79141b9cc65 (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 885243e05467e79e2375b3febe7904053ab45dfc Author: Marcus Brinkmann Date: Tue Feb 14 13:03:46 2012 +0100 Rework status table to be less dynamically generated. * src/Makefile.am (EXTRA_DIST): Remove mkstatus. (BUILT_SOURCE, MOSTLYCLEANFILES): Remove. (main_sources): Remove status-table.h, extra-stati.h. Add status-table.c. (status-table.h): Remove rules for built source. * src/decrypt.c: Don't include extra-stati.h. * src/engine-gpg.c: Don't include status-table.h. (status_cmp): Remove function. (read_status): Use _gpgme_parse_status. * src/engine-gpgsm.c: Don't include status-table.h. (status_cmp, parse_status): Remove function. (gpgsm_assuan_simple_command, status_handler): Use _gpgme_parse_status. * src/engine-uiserver.c: Don't include status-table.h. (status_cmp, parse_status): Remove function. (uiserver_assuan_simple_command, status_handler): Use _gpgme_parse_status. * src/gpgme.h.in (gpgme_status_code_t): Add GPGME_STATUS_DECRYPTION_INFO. * src/util.h (_gpgme_status_init,_gpgme_parse_status): New declaration. * src/status-table.c: New file. * src/extra-stati.h, src/mkstatus: Files removed. * version.c (do_subsystem_inits): Call _gpgme_status_init. diff --git a/src/Makefile.am b/src/Makefile.am index e456d80..ea8e70e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -19,11 +19,9 @@ ## Process this file with automake to produce Makefile.in # Note: moc_kdpipeiodevice should actually be a dependcy below. -EXTRA_DIST = gpgme-config.in gpgme.m4 mkstatus libgpgme.vers ChangeLog-2011 \ +EXTRA_DIST = gpgme-config.in gpgme.m4 libgpgme.vers ChangeLog-2011 \ gpgme.h.in versioninfo.rc.in gpgme.def moc_kdpipeiodevice.cpp -BUILT_SOURCES = status-table.h -MOSTLYCLEANFILES = status-table.h bin_SCRIPTS = gpgme-config m4datadir = $(datadir)/aclocal m4data_DATA = gpgme.m4 @@ -115,8 +113,7 @@ main_sources = \ 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 \ - engine.h engine-backend.h engine.c engine-gpg.c status-table.h \ - extra-stati.h \ + engine.h engine-backend.h engine.c engine-gpg.c status-table.c \ $(gpgsm_components) $(assuan_components) $(gpgconf_components) \ $(uiserver_components) \ $(g13_components) vfs-mount.c vfs-create.c \ @@ -228,10 +225,6 @@ endif noinst_PROGRAMS = gpgme-tool gpgme_tool_LDADD = libgpgme.la @LIBASSUAN_LIBS@ -status-table.h : gpgme.h extra-stati.h - cat $(builddir)/gpgme.h $(srcdir)extra-stati.h \ - | $(srcdir)/mkstatus > status-table.h - install-data-local: install-def-file uninstall-local: uninstall-def-file diff --git a/src/decrypt.c b/src/decrypt.c index b74c508..43945ec 100644 --- a/src/decrypt.c +++ b/src/decrypt.c @@ -31,7 +31,6 @@ #include "util.h" #include "context.h" #include "ops.h" -#include "extra-stati.h" diff --git a/src/engine-gpg.c b/src/engine-gpg.c index f163f0f..cbb456e 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 g10 Code GmbH + 2009, 2010, 2012 g10 Code GmbH This file is part of GPGME. @@ -43,7 +43,6 @@ #include "sema.h" #include "debug.h" -#include "status-table.h" #include "engine-backend.h" @@ -965,16 +964,6 @@ add_io_cb (engine_gpg_t gpg, int fd, int dir, gpgme_io_cb_t handler, void *data, } -static int -status_cmp (const void *ap, const void *bp) -{ - const struct status_table_s *a = ap; - const struct status_table_s *b = bp; - - return strcmp (a->name, b->name); -} - - /* Handle the status output of GnuPG. This function does read entire lines and passes them as C strings to the callback function (we can use C Strings because the status output is always UTF-8 encoded). @@ -1032,8 +1021,8 @@ read_status (engine_gpg_t gpg) if (!strncmp (buffer, "[GNUPG:] ", 9) && buffer[9] >= 'A' && buffer[9] <= 'Z') { - struct status_table_s t, *r; char *rest; + gpgme_status_code_t r; rest = strchr (buffer + 9, ' '); if (!rest) @@ -1041,18 +1030,15 @@ read_status (engine_gpg_t gpg) else *rest++ = 0; - t.name = buffer+9; - /* (the status table has one extra element) */ - r = bsearch (&t, status_table, DIM(status_table) - 1, - sizeof t, status_cmp); - if (r) + r = _gpgme_parse_status (buffer + 9); + if (r >= 0) { if (gpg->cmd.used - && (r->code == GPGME_STATUS_GET_BOOL - || r->code == GPGME_STATUS_GET_LINE - || r->code == GPGME_STATUS_GET_HIDDEN)) + && (r == GPGME_STATUS_GET_BOOL + || r == GPGME_STATUS_GET_LINE + || r == GPGME_STATUS_GET_HIDDEN)) { - gpg->cmd.code = r->code; + gpg->cmd.code = r; if (gpg->cmd.keyword) free (gpg->cmd.keyword); gpg->cmd.keyword = strdup (rest); @@ -1075,12 +1061,12 @@ read_status (engine_gpg_t gpg) { gpgme_error_t err; err = gpg->status.fnc (gpg->status.fnc_value, - r->code, rest); + r, rest); if (err) return err; } - if (r->code == GPGME_STATUS_END_STREAM) + if (r == GPGME_STATUS_END_STREAM) { if (gpg->cmd.used) { diff --git a/src/engine-gpgsm.c b/src/engine-gpgsm.c index 4b7b5a2..0620458 100644 --- a/src/engine-gpgsm.c +++ b/src/engine-gpgsm.c @@ -48,7 +48,6 @@ #include "data.h" #include "assuan.h" -#include "status-table.h" #include "debug.h" #include "engine-backend.h" @@ -559,9 +558,6 @@ gpgsm_set_locale (void *engine, int category, const char *value) } -/* Forward declaration. */ -static gpgme_status_code_t parse_status (const char *name); - static gpgme_error_t gpgsm_assuan_simple_command (assuan_context_t ctx, char *cmd, engine_status_handler_t status_fnc, @@ -604,7 +600,7 @@ gpgsm_assuan_simple_command (assuan_context_t ctx, char *cmd, else *(rest++) = 0; - r = parse_status (line + 2); + r = _gpgme_parse_status (line + 2); if (r >= 0 && status_fnc) err = status_fnc (status_fnc_value, r, rest); @@ -756,27 +752,6 @@ map_data_enc (gpgme_data_t d) } -static int -status_cmp (const void *ap, const void *bp) -{ - const struct status_table_s *a = ap; - const struct status_table_s *b = bp; - - return strcmp (a->name, b->name); -} - - -static gpgme_status_code_t -parse_status (const char *name) -{ - struct status_table_s t, *r; - t.name = name; - r = bsearch (&t, status_table, DIM(status_table) - 1, - sizeof t, status_cmp); - return r ? r->code : -1; -} - - static gpgme_error_t status_handler (void *opaque, int fd) { @@ -963,7 +938,7 @@ status_handler (void *opaque, int fd) else *(rest++) = 0; - r = parse_status (line + 2); + r = _gpgme_parse_status (line + 2); if (r >= 0) { diff --git a/src/engine-uiserver.c b/src/engine-uiserver.c index 92f7536..c705a4b 100644 --- a/src/engine-uiserver.c +++ b/src/engine-uiserver.c @@ -453,9 +453,6 @@ uiserver_set_protocol (void *engine, gpgme_protocol_t protocol) } -/* Forward declaration. */ -static gpgme_status_code_t parse_status (const char *name); - static gpgme_error_t uiserver_assuan_simple_command (assuan_context_t ctx, char *cmd, engine_status_handler_t status_fnc, @@ -498,7 +495,7 @@ uiserver_assuan_simple_command (assuan_context_t ctx, char *cmd, else *(rest++) = 0; - r = parse_status (line + 2); + r = _gpgme_parse_status (line + 2); if (r >= 0 && status_fnc) err = status_fnc (status_fnc_value, r, rest); @@ -620,27 +617,6 @@ map_data_enc (gpgme_data_t d) } -static int -status_cmp (const void *ap, const void *bp) -{ - const struct status_table_s *a = ap; - const struct status_table_s *b = bp; - - return strcmp (a->name, b->name); -} - - -static gpgme_status_code_t -parse_status (const char *name) -{ - struct status_table_s t, *r; - t.name = name; - r = bsearch (&t, status_table, DIM(status_table) - 1, - sizeof t, status_cmp); - return r ? r->code : -1; -} - - static gpgme_error_t status_handler (void *opaque, int fd) { @@ -827,7 +803,7 @@ status_handler (void *opaque, int fd) else *(rest++) = 0; - r = parse_status (line + 2); + r = _gpgme_parse_status (line + 2); if (r >= 0) { diff --git a/src/extra-stati.h b/src/extra-stati.h deleted file mode 100644 index 59cccf9..0000000 --- a/src/extra-stati.h +++ /dev/null @@ -1,29 +0,0 @@ -/* extra-stati.lst - Extra GnuPG status codes. - Copyright 2011 g10 Code GmbH - - This file is free software; as a special exception the author gives - unlimited permission to copy and/or distribute it, with or without - modifications, as long as this notice is preserved. - - This file is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY, to the extent permitted by law; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. */ - -/* A list of internal status code to be processed by mkstatus. Those - * status codes are not part of the API but internally required by - * gpgme. We use a second enum type here but make sure that the - * values don't clash with those of gpgme_status_code_t. - */ - -enum - { - /* This value is the first used one. It needs to be larger than - the last value of gpgme_status_code_t. There is no need to - explictly list the values because they are internal only. */ - _GPGME_STATUS_FIRST_EXTRA = 192, - - GPGME_STATUS_DECRYPTION_INFO, - - _GPGME_STATUS_LAST_EXTRA - }; diff --git a/src/gpgme.h.in b/src/gpgme.h.in index e75de19..dad8d94 100644 --- a/src/gpgme.h.in +++ b/src/gpgme.h.in @@ -499,11 +499,11 @@ typedef enum GPGME_STATUS_BACKUP_KEY_CREATED = 78, GPGME_STATUS_PKA_TRUST_BAD = 79, GPGME_STATUS_PKA_TRUST_GOOD = 80, - GPGME_STATUS_PLAINTEXT = 81, GPGME_STATUS_INV_SGNR = 82, GPGME_STATUS_NO_SGNR = 83, - GPGME_STATUS_SUCCESS = 84 + GPGME_STATUS_SUCCESS = 84, + GPGME_STATUS_DECRYPTION_INFO = 85 } gpgme_status_code_t; diff --git a/src/mkstatus b/src/mkstatus deleted file mode 100755 index 3fbfbf9..0000000 --- a/src/mkstatus +++ /dev/null @@ -1,54 +0,0 @@ -#!/bin/sh -# mkstatus - Extract error strings from rungpg.h -# and create a lookup table -# Copyright (C) 2000 Werner Koch (dd9jn) -# Copyright (C) 2001 g10 Code GmbH -# -# This file is part of GPGME. -# -# GPGME is free software; you can redistribute it and/or modify it -# under the terms of the GNU 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 - -# resetting collate is important, so that the bsearch works properly -LC_ALL=C -LC_COLLATE=C -export LC_ALL LC_COLLATE - -cat < +#endif + +#include + +#include "util.h" + +struct status_table_s { + const char *name; + gpgme_status_code_t code; +}; + + +/* Lexicographically sorted ('_' comes after any letter). You can use + the Emacs command M-x sort-lines. But don't sweat it, the table is + sorted at start up, too. */ +static struct status_table_s status_table[] = +{ + { "ALREADY_SIGNED", GPGME_STATUS_ALREADY_SIGNED }, + { "BACKUP_KEY_CREATED", GPGME_STATUS_BACKUP_KEY_CREATED }, + { "BADARMOR", GPGME_STATUS_BADARMOR }, + { "BADMDC", GPGME_STATUS_BADMDC }, + { "BADSIG", GPGME_STATUS_BADSIG }, + { "BAD_PASSPHRASE", GPGME_STATUS_BAD_PASSPHRASE }, + { "BEGIN_DECRYPTION", GPGME_STATUS_BEGIN_DECRYPTION }, + { "BEGIN_ENCRYPTION", GPGME_STATUS_BEGIN_ENCRYPTION }, + { "BEGIN_STREAM", GPGME_STATUS_BEGIN_STREAM }, + { "CARDCTRL", GPGME_STATUS_CARDCTRL }, + { "DECRYPTION_FAILED", GPGME_STATUS_DECRYPTION_FAILED }, + { "DECRYPTION_OKAY", GPGME_STATUS_DECRYPTION_OKAY }, + { "DELETE_PROBLEM", GPGME_STATUS_DELETE_PROBLEM }, + { "ENC_TO", GPGME_STATUS_ENC_TO }, + { "END_DECRYPTION", GPGME_STATUS_END_DECRYPTION }, + { "END_ENCRYPTION", GPGME_STATUS_END_ENCRYPTION }, + { "END_STREAM", GPGME_STATUS_END_STREAM }, + { "ENTER", GPGME_STATUS_ENTER }, + { "ERRMDC", GPGME_STATUS_ERRMDC }, + { "ERROR", GPGME_STATUS_ERROR }, + { "ERRSIG", GPGME_STATUS_ERRSIG }, + { "EXPKEYSIG", GPGME_STATUS_EXPKEYSIG }, + { "EXPSIG", GPGME_STATUS_EXPSIG }, + { "FILE_DONE", GPGME_STATUS_FILE_DONE }, + { "FILE_ERROR", GPGME_STATUS_FILE_ERROR }, + { "FILE_START", GPGME_STATUS_FILE_START }, + { "GET_BOOL", GPGME_STATUS_GET_BOOL }, + { "GET_HIDDEN", GPGME_STATUS_GET_HIDDEN }, + { "GET_LINE", GPGME_STATUS_GET_LINE }, + { "GOODMDC", GPGME_STATUS_GOODMDC }, + { "GOODSIG", GPGME_STATUS_GOODSIG }, + { "GOOD_PASSPHRASE", GPGME_STATUS_GOOD_PASSPHRASE }, + { "GOT_IT", GPGME_STATUS_GOT_IT }, + { "IMPORTED", GPGME_STATUS_IMPORTED }, + { "IMPORT_OK", GPGME_STATUS_IMPORT_OK }, + { "IMPORT_PROBLEM", GPGME_STATUS_IMPORT_PROBLEM }, + { "IMPORT_RES", GPGME_STATUS_IMPORT_RES }, + { "INV_RECP", GPGME_STATUS_INV_RECP }, + { "INV_SGNR", GPGME_STATUS_INV_SGNR }, + { "KEYEXPIRED", GPGME_STATUS_KEYEXPIRED }, + { "KEYREVOKED", GPGME_STATUS_KEYREVOKED }, + { "KEY_CREATED", GPGME_STATUS_KEY_CREATED }, + { "LEAVE", GPGME_STATUS_LEAVE }, + { "MISSING_PASSPHRASE", GPGME_STATUS_MISSING_PASSPHRASE }, + { "NEED_PASSPHRASE", GPGME_STATUS_NEED_PASSPHRASE }, + { "NEED_PASSPHRASE_PIN", GPGME_STATUS_NEED_PASSPHRASE_PIN }, + { "NEED_PASSPHRASE_SYM", GPGME_STATUS_NEED_PASSPHRASE_SYM }, + { "NEWSIG", GPGME_STATUS_NEWSIG }, + { "NODATA", GPGME_STATUS_NODATA }, + { "NOTATION_DATA", GPGME_STATUS_NOTATION_DATA }, + { "NOTATION_NAME", GPGME_STATUS_NOTATION_NAME }, + { "NO_PUBKEY", GPGME_STATUS_NO_PUBKEY }, + { "NO_RECP", GPGME_STATUS_NO_RECP }, + { "NO_SECKEY", GPGME_STATUS_NO_SECKEY }, + { "NO_SGNR", GPGME_STATUS_NO_SGNR }, + { "PKA_TRUST_BAD", GPGME_STATUS_PKA_TRUST_BAD }, + { "PKA_TRUST_GOOD", GPGME_STATUS_PKA_TRUST_GOOD }, + { "PLAINTEXT", GPGME_STATUS_PLAINTEXT }, + { "POLICY_URL", GPGME_STATUS_POLICY_URL }, + { "PROGRESS", GPGME_STATUS_PROGRESS }, + { "REVKEYSIG", GPGME_STATUS_REVKEYSIG }, + { "RSA_OR_IDEA", GPGME_STATUS_RSA_OR_IDEA }, + { "SC_OP_FAILURE", GPGME_STATUS_SC_OP_FAILURE }, + { "SC_OP_SUCCESS", GPGME_STATUS_SC_OP_SUCCESS }, + { "SESSION_KEY", GPGME_STATUS_SESSION_KEY }, + { "SHM_GET", GPGME_STATUS_SHM_GET }, + { "SHM_GET_BOOL", GPGME_STATUS_SHM_GET_BOOL }, + { "SHM_GET_HIDDEN", GPGME_STATUS_SHM_GET_HIDDEN }, + { "SHM_INFO", GPGME_STATUS_SHM_INFO }, + { "SIGEXPIRED", GPGME_STATUS_SIGEXPIRED }, + { "SIG_CREATED", GPGME_STATUS_SIG_CREATED }, + { "SIG_ID", GPGME_STATUS_SIG_ID }, + { "SIG_SUBPACKET", GPGME_STATUS_SIG_SUBPACKET }, + { "SUCCESS", GPGME_STATUS_SUCCESS }, + { "TRUNCATED", GPGME_STATUS_TRUNCATED }, + { "TRUST_FULLY", GPGME_STATUS_TRUST_FULLY }, + { "TRUST_MARGINAL", GPGME_STATUS_TRUST_MARGINAL }, + { "TRUST_NEVER", GPGME_STATUS_TRUST_NEVER }, + { "TRUST_ULTIMATE", GPGME_STATUS_TRUST_ULTIMATE }, + { "TRUST_UNDEFINED", GPGME_STATUS_TRUST_UNDEFINED }, + { "UNEXPECTED", GPGME_STATUS_UNEXPECTED }, + { "USERID_HINT", GPGME_STATUS_USERID_HINT }, + { "VALIDSIG", GPGME_STATUS_VALIDSIG }, + { "ABORT", GPGME_STATUS_ABORT }, + {NULL, 0} +}; + + +static int +status_cmp (const void *ap, const void *bp) +{ + const struct status_table_s *a = ap; + const struct status_table_s *b = bp; + + return strcmp (a->name, b->name); +} + + +void +_gpgme_status_init (void) +{ + qsort (status_table, + DIM(status_table) - 1, sizeof (status_table[0]), + status_cmp); +} + + +gpgme_status_code_t +_gpgme_parse_status (const char *name) +{ + struct status_table_s t, *r; + t.name = name; + r = bsearch (&t, status_table, DIM(status_table) - 1, + sizeof t, status_cmp); + return r ? r->code : -1; +} diff --git a/src/util.h b/src/util.h index 27620aa..cf18099 100644 --- a/src/util.h +++ b/src/util.h @@ -137,6 +137,12 @@ gpgme_error_t _gpgme_map_gnupg_error (char *err); gpgme_error_t _gpgme_getenv (const char *name, char **value); +/*-- status-table.c --*/ +/* Convert a status string to a status code. */ +void _gpgme_status_init (void); +gpgme_status_code_t _gpgme_parse_status (const char *name); + + #ifdef HAVE_W32_SYSTEM int _gpgme_mkstemp (int *fd, char **name); const char *_gpgme_get_w32spawn_path (void); diff --git a/src/version.c b/src/version.c index e02037e..3aef404 100644 --- a/src/version.c +++ b/src/version.c @@ -35,8 +35,9 @@ #include "debug.h" #include "context.h" -/* For _gpgme_sema_subsystem_init (). */ +/* For _gpgme_sema_subsystem_init and _gpgme_status_init. */ #include "sema.h" +#include "util.h" #ifdef HAVE_ASSUAN_H #include "assuan.h" @@ -76,6 +77,7 @@ do_subsystem_inits (void) _gpgme_sema_subsystem_init (); _gpgme_debug_subsystem_init (); _gpgme_io_subsystem_init (); + _gpgme_status_init (); done = 1; } ----------------------------------------------------------------------- Summary of changes: src/Makefile.am | 11 +--- src/decrypt.c | 1 - src/engine-gpg.c | 34 +++-------- src/engine-gpgsm.c | 29 +--------- src/engine-uiserver.c | 28 +-------- src/extra-stati.h | 29 --------- src/gpgme.h.in | 4 +- src/mkstatus | 54 ----------------- src/status-table.c | 156 +++++++++++++++++++++++++++++++++++++++++++++++++ src/util.h | 6 ++ src/version.c | 4 +- 11 files changed, 183 insertions(+), 173 deletions(-) delete mode 100644 src/extra-stati.h delete mode 100755 src/mkstatus create mode 100644 src/status-table.c hooks/post-receive -- GnuPG Made Easy http://git.gnupg.org From cvs at cvs.gnupg.org Thu Feb 16 19:03:13 2012 From: cvs at cvs.gnupg.org (by Marcus Brinkmann) Date: Thu, 16 Feb 2012 19:03:13 +0100 Subject: [git] GnuPG - branch, master, updated. gnupg-2.1.0beta3-52-g76ff42e 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 76ff42ef8d1232dd36bf48c1020b0b9b2afb1c7d (commit) from b817ae7df947093384a25797999a9aa187e20f9c (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 76ff42ef8d1232dd36bf48c1020b0b9b2afb1c7d Author: Marcus Brinkmann Date: Thu Feb 16 17:51:20 2012 +0100 Check for lber and link dirmngr_ldap to it. * configure.ac (LBER_LIBS, HAVE_LBER): New variables, check for lber. * dirmngr/Makefile.am (dirmngr_lda_LDADD): Add $(LBER_LIBS). diff --git a/configure.ac b/configure.ac index 47c6d12..6aadaa2 100644 --- a/configure.ac +++ b/configure.ac @@ -1009,7 +1009,14 @@ AM_CONDITIONAL(USE_DNS_SRV, test x"$use_dns_srv" = xyes) # if test "$try_ks_ldap" = yes || test "$build_dirmngr" = "yes" ; then GNUPG_CHECK_LDAP($NETLIBS) + AC_CHECK_LIB(lber, ber_free, + [ LBER_LIBS="$LBER_LIBS -llber" + AC_DEFINE(HAVE_LBER,1, + [defined if liblber is available]) + have_lber=yes + ]) fi +AC_SUBST(LBER_LIBS) # # Check for curl. We fake the curl API if libcurl isn't installed. diff --git a/dirmngr/Makefile.am b/dirmngr/Makefile.am index c5f073e..7c43165 100644 --- a/dirmngr/Makefile.am +++ b/dirmngr/Makefile.am @@ -72,7 +72,8 @@ dirmngr_ldap_SOURCES = dirmngr_ldap.c $(ldap_url) dirmngr_ldap_CFLAGS = $(GPG_ERROR_CFLAGS) $(LIBGCRYPT_CFLAGS) dirmngr_ldap_LDFLAGS = dirmngr_ldap_LDADD = $(libcommon) no-libgcrypt.o ../gl/libgnu.a $(DNSLIBS) \ - $(GPG_ERROR_LIBS) $(LDAPLIBS) $(LIBINTL) $(LIBICONV) + $(GPG_ERROR_LIBS) $(LDAPLIBS) $(LBER_LIBS) $(LIBINTL) \ + $(LIBICONV) endif dirmngr_client_SOURCES = dirmngr-client.c ----------------------------------------------------------------------- Summary of changes: configure.ac | 7 +++++++ dirmngr/Makefile.am | 3 ++- 2 files changed, 9 insertions(+), 1 deletions(-) hooks/post-receive -- The GNU Privacy Guard http://git.gnupg.org From cvs at cvs.gnupg.org Thu Feb 16 21:56:18 2012 From: cvs at cvs.gnupg.org (by Werner Koch) Date: Thu, 16 Feb 2012 21:56:18 +0100 Subject: [git] GCRYPT - branch, master, updated. libgcrypt-1.5.0-26-ge0fa449 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 e0fa4496412ab8d2d7a4685270427af21d030102 (commit) via 46035d28c9b413851d43a4008fdc8e4cdf5d686b (commit) via 318fd85f377c060908d371f792d41e599b3b7483 (commit) from 6078b05f5340d886e0b9e6cee1d9b5043e0cb210 (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 e0fa4496412ab8d2d7a4685270427af21d030102 Author: Werner Koch Date: Thu Feb 16 20:57:05 2012 +0100 Update NEWS and AUTHORS. -- diff --git a/AUTHORS b/AUTHORS index 0685a4e..94c1213 100644 --- a/AUTHORS +++ b/AUTHORS @@ -96,6 +96,11 @@ Assigns Past and Future Changes openpgp at brainhub.org (cipher/ecc.c and related files) +LIBGCRYPT Ulrich M?ller 2012-02-15 +Assigns Past and Future Changes +ulm at gentoo.org +(Changes to cipher/idea.c and related files) + More credits ============ @@ -123,7 +128,7 @@ security corporation. See the file for details. Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2006, - 2007, 2008, 2009, 2011 Free Software Foundation, Inc. + 2007, 2008, 2009, 2011, 2012 Free Software Foundation, Inc. This file is free software; as a special exception the author gives unlimited permission to copy and/or distribute it, with or without diff --git a/NEWS b/NEWS index 85117d4..465330a 100644 --- a/NEWS +++ b/NEWS @@ -9,6 +9,8 @@ Noteworthy changes in version 1.6.0 (unreleased) * The deprecated message digest debug macros have been removed. Use gcry_md_debug instead. + * Add support for the IDEA cipher algorithm. + * Interface changes relative to the 1.5.0 release: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ gcry_ac_* REMOVED. @@ -27,6 +29,7 @@ Noteworthy changes in version 1.6.0 (unreleased) gcry_md_stop_debug REMOVED (macro). + Noteworthy changes in version 1.5.0 (2011-06-29) ------------------------------------------------ commit 46035d28c9b413851d43a4008fdc8e4cdf5d686b Author: Werner Koch Date: Thu Feb 16 20:50:52 2012 +0100 Fix missing prototype. * src/g10lib.h (_gcry_secmem_module_init): Make it a real prototype. diff --git a/src/g10lib.h b/src/g10lib.h index 93652ed..46d5229 100644 --- a/src/g10lib.h +++ b/src/g10lib.h @@ -302,7 +302,7 @@ gcry_err_code_t _gcry_module_list (gcry_module_t modules, gcry_err_code_t _gcry_cipher_init (void); gcry_err_code_t _gcry_md_init (void); gcry_err_code_t _gcry_pk_init (void); -gcry_err_code_t _gcry_secmem_module_init (); +gcry_err_code_t _gcry_secmem_module_init (void); gcry_err_code_t _gcry_pk_module_lookup (int id, gcry_module_t *module); void _gcry_pk_module_release (gcry_module_t module); commit 318fd85f377c060908d371f792d41e599b3b7483 Author: Ulrich M??ller Date: Wed Jan 11 13:20:48 2012 +0100 Add support for the IDEA cipher. Adapt idea.c to the Libgcrypt framework. Add IDEA to cipher_table and to the build system. Patents on IDEA have expired: Europe: EP0482154 on 2011-05-16, Japan: JP3225440 on 2011-05-16, U.S.: 5,214,703 on 2012-01-07. * configure.ac: Add idea to the list of available ciphers. Define USE_IDEA if idea is enabled. * cipher/cipher.c (cipher_table): Add entry for IDEA. * cipher/idea.c: Update comment about patents. Include proper header files and remove redundant declarations. (expand_key, cipher, do_setkey, encrypt_block, decrypt_block): Define function arguments as const where appropriate. (cipher): Test for !WORDS_BIGENDIAN instead of LITTLE_ENDIAN_HOST. (do_setkey, decrypt_block): Don't call selftest. (idea_setkey): New function, wrapper for do_setkey. (idea_encrypt): New function, wrapper for encrypt_block. (_gcry_cipher_spec_idea): Define. * cipher/Makefile.am (EXTRA_libcipher_la_SOURCES): Add idea.c. * src/cipher.h (_gcry_cipher_spec_idea): Declare. * tests/basic.c (check_ciphers): Add GCRY_CIPHER_IDEA. diff --git a/cipher/Makefile.am b/cipher/Makefile.am index dcb4a47..473e3c8 100644 --- a/cipher/Makefile.am +++ b/cipher/Makefile.am @@ -53,6 +53,7 @@ des.c \ dsa.c \ elgamal.c \ ecc.c \ +idea.c \ md4.c \ md5.c \ rijndael.c rijndael-tables.h \ diff --git a/cipher/cipher.c b/cipher/cipher.c index 589c262..389bf7a 100644 --- a/cipher/cipher.c +++ b/cipher/cipher.c @@ -100,6 +100,10 @@ static struct cipher_table_entry { &_gcry_cipher_spec_camellia256, &dummy_extra_spec, GCRY_CIPHER_CAMELLIA256 }, #endif +#ifdef USE_IDEA + { &_gcry_cipher_spec_idea, + &dummy_extra_spec, GCRY_CIPHER_IDEA }, +#endif { NULL } }; diff --git a/cipher/idea.c b/cipher/idea.c index 65a8ec3..fe14b21 100644 --- a/cipher/idea.c +++ b/cipher/idea.c @@ -22,10 +22,10 @@ * used in advertising or otherwise to promote the sale, use or other dealings * in this Software without prior written authorization from Werner Koch. * - * DUE TO PATENT CLAIMS THE DISTRIBUTION OF THE SOFTWARE IS NOT ALLOWED IN - * THESE COUNTRIES: - * AUSTRIA, FRANCE, GERMANY, ITALY, JAPAN, THE NETHERLANDS, - * SPAIN, SWEDEN, SWITZERLAND, THE UK AND THE US. + * Patents on IDEA have expired: + * Europe: EP0482154 on 2011-05-16, + * Japan: JP3225440 on 2011-05-16, + * U.S.: 5,214,703 on 2012-01-07. */ /* @@ -34,60 +34,22 @@ * * The code herein is based on the one from: * Bruce Schneier: Applied Cryptography. John Wiley & Sons, 1996. - * ISBN 0-471-11709-9. . - * - * How to compile: - gcc -Wall -O2 -shared -fPIC -o idea idea.c - * - * 2001-06-08 wk Changed distribution conditions - * 2001-06-11 wk Fixed invert_key (which is not used in CFB mode) - * Thanks to Mark A. Borgerding. Added defintion for - * the PowerPC. + * ISBN 0-471-11709-9. */ +#include #include #include #include #include -/* configuration stuff */ -#ifdef __alpha__ - #define SIZEOF_UNSIGNED_LONG 8 -#else - #define SIZEOF_UNSIGNED_LONG 4 -#endif - -#if defined(__mc68000__) || defined (__sparc__) || defined (__PPC__) \ - || (defined(__mips__) && (defined(MIPSEB) || defined (__MIPSEB__)) ) \ - || defined(__powerpc__) \ - || defined(__hpux__) /* should be replaced by the Macro for the PA */ - #define BIG_ENDIAN_HOST 1 -#else - #define LITTLE_ENDIAN_HOST 1 -#endif - -typedef unsigned long ulong; -typedef unsigned short ushort; -typedef unsigned char byte; - -typedef unsigned short u16; -typedef unsigned long u32; - -/* end configurable stuff */ - -#ifndef DIM - #define DIM(v) (sizeof(v)/sizeof((v)[0])) - #define DIMof(type,member) DIM(((type *)0)->member) -#endif - -/* imports */ -void g10_log_fatal( const char *fmt, ... ); - +#include "types.h" /* for byte and u32 typedefs */ +#include "g10lib.h" +#include "cipher.h" -/* local stuff */ -#define FNCCAST_SETKEY(f) ((int(*)(void*, byte*, unsigned))(f)) +#define FNCCAST_SETKEY(f) ((int(*)(void*, byte*, unsigned int))(f)) #define FNCCAST_CRYPT(f) ((void(*)(void*, byte*, byte*))(f)) #define IDEA_KEYSIZE 16 @@ -102,13 +64,6 @@ typedef struct { } IDEA_context; -static int do_setkey( IDEA_context *c, byte *key, unsigned keylen ); -static void encrypt_block( IDEA_context *bc, byte *outbuf, byte *inbuf ); -static void decrypt_block( IDEA_context *bc, byte *outbuf, byte *inbuf ); -static void selftest(int); - - - static u16 mul_inv( u16 x ) { @@ -139,7 +94,7 @@ mul_inv( u16 x ) static void -expand_key( byte *userkey, u16 *ek ) +expand_key( const byte *userkey, u16 *ek ) { int i,j; @@ -202,7 +157,7 @@ invert_key( u16 *ek, u16 dk[IDEA_KEYLEN] ) static void -cipher( byte *outbuf, byte *inbuf, u16 *key ) +cipher( byte *outbuf, const byte *inbuf, u16 *key ) { u16 x1, x2, x3,x4, s2, s3; u16 *in, *out; @@ -230,7 +185,7 @@ cipher( byte *outbuf, byte *inbuf, u16 *key ) x2 = *in++; x3 = *in++; x4 = *in; - #ifdef LITTLE_ENDIAN_HOST + #ifndef WORDS_BIGENDIAN x1 = (x1>>8) | (x1<<8); x2 = (x2>>8) | (x2<<8); x3 = (x3>>8) | (x3<<8); @@ -263,7 +218,7 @@ cipher( byte *outbuf, byte *inbuf, u16 *key ) MUL(x4, *key); out = (u16*)outbuf; - #ifdef LITTLE_ENDIAN_HOST + #ifndef WORDS_BIGENDIAN *out++ = (x1>>8) | (x1<<8); *out++ = (x3>>8) | (x3<<8); *out++ = (x2>>8) | (x2<<8); @@ -279,14 +234,16 @@ cipher( byte *outbuf, byte *inbuf, u16 *key ) static int -do_setkey( IDEA_context *c, byte *key, unsigned keylen ) +do_setkey( IDEA_context *c, const byte *key, unsigned int keylen ) { +#if 0 static int initialized = 0; if( !initialized ) { initialized = 1; selftest(0); } +#endif assert(keylen == 16); c->have_dk = 0; expand_key( key, c->ek ); @@ -294,21 +251,40 @@ do_setkey( IDEA_context *c, byte *key, unsigned keylen ) return 0; } +static gcry_err_code_t +idea_setkey (void *context, const byte *key, unsigned int keylen) +{ + IDEA_context *ctx = context; + int rc = do_setkey (ctx, key, keylen); + _gcry_burn_stack (23+6*sizeof(void*)); + return rc; +} + static void -encrypt_block( IDEA_context *c, byte *outbuf, byte *inbuf ) +encrypt_block( IDEA_context *c, byte *outbuf, const byte *inbuf ) { cipher( outbuf, inbuf, c->ek ); } static void -decrypt_block( IDEA_context *c, byte *outbuf, byte *inbuf ) +idea_encrypt (void *context, byte *out, const byte *in) +{ + IDEA_context *ctx = context; + encrypt_block (ctx, out, in); + _gcry_burn_stack (24+3*sizeof (void*)); +} + +static void +decrypt_block( IDEA_context *c, byte *outbuf, const byte *inbuf ) { +#if 0 static int initialized; if( !initialized ) { initialized = 1; selftest(1); } +#endif if( !c->have_dk ) { c->have_dk = 1; invert_key( c->ek, c->dk ); @@ -316,7 +292,16 @@ decrypt_block( IDEA_context *c, byte *outbuf, byte *inbuf ) cipher( outbuf, inbuf, c->dk ); } +static void +idea_decrypt (void *context, byte *out, const byte *in) +{ + IDEA_context *ctx = context; + decrypt_block (ctx, out, in); + _gcry_burn_stack (24+3*sizeof (void*)); +} + +#if 0 static void selftest( int check_decrypt ) { @@ -388,89 +373,12 @@ static struct { } } } +#endif -/**************** - * Return some information about the algorithm. We need algo here to - * distinguish different flavors of the algorithm. - * Returns: A pointer to string describing the algorithm or NULL if - * the ALGO is invalid. - */ -const char * -idea_get_info( int algo, size_t *keylen, - size_t *blocksize, size_t *contextsize, - int (**r_setkey)( void *c, byte *key, unsigned keylen ), - void (**r_encrypt)( void *c, byte *outbuf, byte *inbuf ), - void (**r_decrypt)( void *c, byte *outbuf, byte *inbuf ) - ) +gcry_cipher_spec_t _gcry_cipher_spec_idea = { - *keylen = 128; - *blocksize = 8; - *contextsize = sizeof(IDEA_context); - *r_setkey = FNCCAST_SETKEY(do_setkey); - *r_encrypt= FNCCAST_CRYPT(encrypt_block); - *r_decrypt= FNCCAST_CRYPT(decrypt_block); - if( algo == 1 ) - return "IDEA"; - return NULL; -} - - - -const char * const gnupgext_version = "IDEA ($Revision: 1.11 $)"; - -static struct { - int class; - int version; - int value; - void (*func)(void); -} func_table[] = { - { 20, 1, 0, (void(*)(void))idea_get_info }, - { 21, 1, 1 }, + "IDEA", NULL, NULL, IDEA_BLOCKSIZE, 128, + sizeof (IDEA_context), + idea_setkey, idea_encrypt, idea_decrypt }; - - - -/**************** - * Enumerate the names of the functions together with informations about - * this function. Set sequence to an integer with a initial value of 0 and - * do not change it. - * If what is 0 all kind of functions are returned. - * Return values: class := class of function: - * 10 = message digest algorithm info function - * 11 = integer with available md algorithms - * 20 = cipher algorithm info function - * 21 = integer with available cipher algorithms - * 30 = public key algorithm info function - * 31 = integer with available pubkey algorithms - * version = interface version of the function/pointer - * (currently this is 1 for all functions) - */ -void * -gnupgext_enum_func( int what, int *sequence, int *class, int *vers ) -{ - void *ret; - int i = *sequence; - - do { - if( i >= DIM(func_table) || i < 0 ) { - return NULL; - } - *class = func_table[i].class; - *vers = func_table[i].version; - switch( *class ) { - case 11: - case 21: - case 31: - ret = &func_table[i].value; - break; - default: - ret = func_table[i].func; - break; - } - i++; - } while( what && what != *class ); - - *sequence = i; - return ret; -} diff --git a/configure.ac b/configure.ac index c354836..cf4a082 100644 --- a/configure.ac +++ b/configure.ac @@ -174,7 +174,7 @@ LIBGCRYPT_CONFIG_HOST="$host" # Definitions for symmetric ciphers. available_ciphers="arcfour blowfish cast5 des aes twofish serpent rfc2268 seed" -available_ciphers="$available_ciphers camellia" +available_ciphers="$available_ciphers camellia idea" enabled_ciphers="" # Definitions for public-key ciphers. @@ -1080,6 +1080,12 @@ if test "$found" = "1" ; then AC_DEFINE(USE_CAMELLIA, 1, [Defined if this module should be included]) fi +LIST_MEMBER(idea, $enabled_ciphers) +if test "$found" = "1" ; then + GCRYPT_CIPHERS="$GCRYPT_CIPHERS idea.lo" + AC_DEFINE(USE_IDEA, 1, [Defined if this module should be included]) +fi + LIST_MEMBER(dsa, $enabled_pubkey_ciphers) if test "$found" = "1" ; then GCRYPT_PUBKEY_CIPHERS="$GCRYPT_PUBKEY_CIPHERS dsa.lo" diff --git a/src/cipher.h b/src/cipher.h index 0f923d7..48eeeda 100644 --- a/src/cipher.h +++ b/src/cipher.h @@ -135,6 +135,7 @@ extern gcry_cipher_spec_t _gcry_cipher_spec_seed; extern gcry_cipher_spec_t _gcry_cipher_spec_camellia128; extern gcry_cipher_spec_t _gcry_cipher_spec_camellia192; extern gcry_cipher_spec_t _gcry_cipher_spec_camellia256; +extern gcry_cipher_spec_t _gcry_cipher_spec_idea; extern cipher_extra_spec_t _gcry_cipher_extraspec_tripledes; extern cipher_extra_spec_t _gcry_cipher_extraspec_aes; diff --git a/tests/basic.c b/tests/basic.c index 4d5196f..8001e86 100644 --- a/tests/basic.c +++ b/tests/basic.c @@ -1568,6 +1568,9 @@ check_ciphers (void) GCRY_CIPHER_CAMELLIA192, GCRY_CIPHER_CAMELLIA256, #endif +#if USE_IDEA + GCRY_CIPHER_IDEA, +#endif 0 }; static int algos2[] = { ----------------------------------------------------------------------- Summary of changes: AUTHORS | 7 ++- NEWS | 3 + cipher/Makefile.am | 1 + cipher/cipher.c | 4 + cipher/idea.c | 196 ++++++++++++++-------------------------------------- configure.ac | 8 ++- src/cipher.h | 1 + src/g10lib.h | 2 +- tests/basic.c | 3 + 9 files changed, 78 insertions(+), 147 deletions(-) hooks/post-receive -- The GNU crypto library http://git.gnupg.org From cvs at cvs.gnupg.org Fri Feb 17 14:41:24 2012 From: cvs at cvs.gnupg.org (by Ulrich Müller) Date: Fri, 17 Feb 2012 14:41:24 +0100 Subject: [git] GCRYPT - branch, master, updated. libgcrypt-1.5.0-27-g70cca61 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 70cca617ed75ea292e1fed769114dda5cc1d76f1 (commit) from e0fa4496412ab8d2d7a4685270427af21d030102 (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 70cca617ed75ea292e1fed769114dda5cc1d76f1 Author: Ulrich M?ller Date: Thu Feb 16 21:58:52 2012 +0100 Rework selftest in idea.c. * cipher/idea.c (do_setkey): Execute selftest when first called. (decrypt_block): Remove commented-out code. (selftest): Execute all selftests. Return NULL on success, or string in case of error. diff --git a/cipher/idea.c b/cipher/idea.c index fe14b21..39c9720 100644 --- a/cipher/idea.c +++ b/cipher/idea.c @@ -63,6 +63,8 @@ typedef struct { int have_dk; } IDEA_context; +static const char *selftest(void); + static u16 mul_inv( u16 x ) @@ -236,14 +238,18 @@ cipher( byte *outbuf, const byte *inbuf, u16 *key ) static int do_setkey( IDEA_context *c, const byte *key, unsigned int keylen ) { -#if 0 static int initialized = 0; + static const char *selftest_failed = 0; if( !initialized ) { initialized = 1; - selftest(0); + selftest_failed = selftest(); + if( selftest_failed ) + log_error( "%s\n", selftest_failed ); } -#endif + if( selftest_failed ) + return GPG_ERR_SELFTEST_FAILED; + assert(keylen == 16); c->have_dk = 0; expand_key( key, c->ek ); @@ -277,14 +283,6 @@ idea_encrypt (void *context, byte *out, const byte *in) static void decrypt_block( IDEA_context *c, byte *outbuf, const byte *inbuf ) { -#if 0 - static int initialized; - - if( !initialized ) { - initialized = 1; - selftest(1); - } -#endif if( !c->have_dk ) { c->have_dk = 1; invert_key( c->ek, c->dk ); @@ -301,9 +299,8 @@ idea_decrypt (void *context, byte *out, const byte *in) } -#if 0 -static void -selftest( int check_decrypt ) +static const char * +selftest( void ) { static struct { byte key[16]; @@ -361,19 +358,16 @@ static struct { for(i=0; i < DIM(test_vectors); i++ ) { do_setkey( &c, test_vectors[i].key, 16 ); - if( !check_decrypt ) { - encrypt_block( &c, buffer, test_vectors[i].plain ); - if( memcmp( buffer, test_vectors[i].cipher, 8 ) ) - g10_log_fatal("idea encryption (%d) failed\n", i); - } - else { - decrypt_block( &c, buffer, test_vectors[i].cipher ); - if( memcmp( buffer, test_vectors[i].plain, 8 ) ) - g10_log_fatal("idea decryption (%d) failed\n", i); - } + encrypt_block( &c, buffer, test_vectors[i].plain ); + if( memcmp( buffer, test_vectors[i].cipher, 8 ) ) + return "IDEA test encryption failed."; + decrypt_block( &c, buffer, test_vectors[i].cipher ); + if( memcmp( buffer, test_vectors[i].plain, 8 ) ) + return "IDEA test decryption failed."; } + + return NULL; } -#endif gcry_cipher_spec_t _gcry_cipher_spec_idea = ----------------------------------------------------------------------- Summary of changes: cipher/idea.c | 44 +++++++++++++++++++------------------------- 1 files changed, 19 insertions(+), 25 deletions(-) hooks/post-receive -- The GNU crypto library http://git.gnupg.org From cvs at cvs.gnupg.org Tue Feb 28 18:27:32 2012 From: cvs at cvs.gnupg.org (by Marcus Brinkmann) Date: Tue, 28 Feb 2012 18:27:32 +0100 Subject: [git] GnuPG - branch, master, updated. gnupg-2.1.0beta3-53-g8f8c659 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 8f8c6594147608b1021c16fc3561feb96da5d55a (commit) from 76ff42ef8d1232dd36bf48c1020b0b9b2afb1c7d (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 8f8c6594147608b1021c16fc3561feb96da5d55a Author: Marcus Brinkmann Date: Tue Feb 28 17:26:32 2012 +0100 Replace npth_yield in busy wait by npth_usleep. * dirmngr/ldap-wrapper.c (ldap_wrapper_wait_connections): Call npth_usleep instead of npth_yield. diff --git a/dirmngr/ldap-wrapper.c b/dirmngr/ldap-wrapper.c index 203b472..f2aaf59 100644 --- a/dirmngr/ldap-wrapper.c +++ b/dirmngr/ldap-wrapper.c @@ -468,7 +468,7 @@ ldap_wrapper_wait_connections () shutting_down = 1; /* FIXME: This is a busy wait. */ while (wrapper_list) - npth_yield (); + npth_usleep (200); } ----------------------------------------------------------------------- Summary of changes: dirmngr/ldap-wrapper.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) hooks/post-receive -- The GNU Privacy Guard http://git.gnupg.org