From 764e88d4df29204be6ea2206cf753c56ec0f5b5f Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Thu, 14 Oct 2010 16:34:31 +0000 Subject: All tests work are again working --- agent/ChangeLog | 5 ++ agent/agent.h | 3 +- agent/command.c | 9 ++- agent/genkey.c | 16 ++-- doc/DETAILS | 13 +++ doc/gpg-agent.texi | 14 +++- doc/tools.texi | 11 +++ g10/ChangeLog | 9 +++ g10/call-agent.c | 8 +- g10/call-agent.h | 2 +- g10/keygen.c | 66 ++++++++++----- tests/openpgp/ChangeLog | 21 +++++ tests/openpgp/Makefile.am | 89 ++++++--------------- tests/openpgp/decrypt-dsa.test | 2 +- tests/openpgp/decrypt.test | 2 +- tests/openpgp/defs.inc | 57 +++++++++---- tests/openpgp/encrypt-dsa.test | 8 +- tests/openpgp/finish.test | 17 ++++ tests/openpgp/genkey1024.test | 13 ++- tests/openpgp/gpg-agent.conf.tmpl | 6 +- tests/openpgp/mkdemodirs | 2 +- tests/openpgp/multisig.test | 4 +- .../0D6F6AD4C4C803B25470F9104E9F4E6A4CA64255.asc | 12 +++ .../13FDB8809B17C5547779F9D205C45F47CE0217CE.asc | 17 ++++ .../343D8AF79796EE107D645A2787A9D9252F924E6F.asc | 17 ++++ .../50B2D4FA4122C212611048BC5FC31BD44393626E.asc | 21 +++++ .../76F7E2B35832976B50A27A282D9B87E44577EB66.asc | 21 +++++ .../7E201E28B6FEB2927B321F443205F4724EBE637E.asc | 18 +++++ .../8B5ABF3EF9EB8D96B91A0B8C2C4401C91C834C34.asc | 14 ++++ .../A0747D5F9425E6664F4FFBEED20FBCA79FDED2BD.asc | 20 +++++ .../FD692BD59D6640A84C8422573D469F84F3B98E53.asc | 15 ++++ tests/openpgp/seat.test | 2 +- tests/openpgp/signencrypt-dsa.test | 8 +- tests/openpgp/sigs-dsa.test | 9 +-- tests/openpgp/sigs.test | 2 +- tests/openpgp/version.test | 93 +++++++++++++++++++++- tools/ChangeLog | 2 + tools/gpg-connect-agent.c | 6 +- 38 files changed, 508 insertions(+), 146 deletions(-) create mode 100755 tests/openpgp/finish.test create mode 100644 tests/openpgp/privkeys/0D6F6AD4C4C803B25470F9104E9F4E6A4CA64255.asc create mode 100644 tests/openpgp/privkeys/13FDB8809B17C5547779F9D205C45F47CE0217CE.asc create mode 100644 tests/openpgp/privkeys/343D8AF79796EE107D645A2787A9D9252F924E6F.asc create mode 100644 tests/openpgp/privkeys/50B2D4FA4122C212611048BC5FC31BD44393626E.asc create mode 100644 tests/openpgp/privkeys/76F7E2B35832976B50A27A282D9B87E44577EB66.asc create mode 100644 tests/openpgp/privkeys/7E201E28B6FEB2927B321F443205F4724EBE637E.asc create mode 100644 tests/openpgp/privkeys/8B5ABF3EF9EB8D96B91A0B8C2C4401C91C834C34.asc create mode 100644 tests/openpgp/privkeys/A0747D5F9425E6664F4FFBEED20FBCA79FDED2BD.asc create mode 100644 tests/openpgp/privkeys/FD692BD59D6640A84C8422573D469F84F3B98E53.asc diff --git a/agent/ChangeLog b/agent/ChangeLog index 12a853281..91aab9e6d 100644 --- a/agent/ChangeLog +++ b/agent/ChangeLog @@ -1,3 +1,8 @@ +2010-10-14 Werner Koch + + * command.c (cmd_genkey): Add option --no-protection. + * genkey.c (agent_genkey): Add arg NO_PROTECTION. + 2010-10-13 Werner Koch * call-pinentry.c (agent_get_passphrase): Support the close_button. diff --git a/agent/agent.h b/agent/agent.h index 7276e66c3..48511c565 100644 --- a/agent/agent.h +++ b/agent/agent.h @@ -293,7 +293,8 @@ int check_passphrase_constraints (ctrl_t ctrl, const char *pw, int silent); gpg_error_t agent_ask_new_passphrase (ctrl_t ctrl, const char *prompt, char **r_passphrase); int agent_genkey (ctrl_t ctrl, const char *cache_nonce, - const char *keyparam, size_t keyparmlen, membuf_t *outbuf); + const char *keyparam, size_t keyparmlen, + int no_protection, membuf_t *outbuf); int agent_protect_and_store (ctrl_t ctrl, gcry_sexp_t s_skey); /*-- protect.c --*/ diff --git a/agent/command.c b/agent/command.c index 5444e1811..0a56f1218 100644 --- a/agent/command.c +++ b/agent/command.c @@ -806,7 +806,7 @@ cmd_pkdecrypt (assuan_context_t ctx, char *line) static const char hlp_genkey[] = - "GENKEY []\n" + "GENKEY [--no-protection] []\n" "\n" "Generate a new key, store the secret part and return the public\n" "part. Here is an example transaction:\n" @@ -824,12 +824,16 @@ cmd_genkey (assuan_context_t ctx, char *line) { ctrl_t ctrl = assuan_get_pointer (ctx); int rc; + int no_protection; unsigned char *value; size_t valuelen; membuf_t outbuf; char *cache_nonce = NULL; char *p; + no_protection = has_option (line, "--no-protection"); + line = skip_options (line); + p = line; for (p=line; *p && *p != ' ' && *p != '\t'; p++) ; @@ -844,7 +848,8 @@ cmd_genkey (assuan_context_t ctx, char *line) init_membuf (&outbuf, 512); - rc = agent_genkey (ctrl, cache_nonce, (char*)value, valuelen, &outbuf); + rc = agent_genkey (ctrl, cache_nonce, (char*)value, valuelen, no_protection, + &outbuf); xfree (value); if (rc) clear_outbuf (&outbuf); diff --git a/agent/genkey.c b/agent/genkey.c index 0a35643e5..7612f99da 100644 --- a/agent/genkey.c +++ b/agent/genkey.c @@ -352,10 +352,11 @@ agent_ask_new_passphrase (ctrl_t ctrl, const char *prompt, /* Generate a new keypair according to the parameters given in KEYPARAM. If CACHE_NONCE is given first try to lookup a passphrase - using the cache nonce. */ + using the cache nonce. If NO_PROTECTION is true the key will not + be protected by a passphrase. */ int agent_genkey (ctrl_t ctrl, const char *cache_nonce, - const char *keyparam, size_t keyparamlen, + const char *keyparam, size_t keyparamlen, int no_protection, membuf_t *outbuf) { gcry_sexp_t s_keyparam, s_key, s_private, s_public; @@ -372,8 +373,12 @@ agent_genkey (ctrl_t ctrl, const char *cache_nonce, } /* Get the passphrase now, cause key generation may take a while. */ - passphrase = cache_nonce? agent_get_cache (cache_nonce, CACHE_MODE_NONCE):NULL; - if (passphrase) + if (no_protection || !cache_nonce) + passphrase = NULL; + else + passphrase = agent_get_cache (cache_nonce, CACHE_MODE_NONCE); + + if (passphrase || no_protection) rc = 0; else rc = agent_ask_new_passphrase (ctrl, @@ -424,7 +429,8 @@ agent_genkey (ctrl_t ctrl, const char *cache_nonce, gcry_create_nonce (tmpbuf, 12); cache_nonce = bin2hex (tmpbuf, 12, NULL); } - if (cache_nonce + if (cache_nonce + && !no_protection && !agent_put_cache (cache_nonce, CACHE_MODE_NONCE, passphrase, 900 /*seconds*/)) agent_write_status (ctrl, "CACHE_NONCE", cache_nonce, NULL); diff --git a/doc/DETAILS b/doc/DETAILS index 93dedbea0..dd3e357ec 100644 --- a/doc/DETAILS +++ b/doc/DETAILS @@ -826,6 +826,19 @@ The format of this file is as follows: entry code. This is a global option. %no-ask-passphrase Disable the ask-passphrase mode. + %no-protection + With GnuPG 2.1 it is not anymore possible to specify a + passphrase for unattended key generation. The passphrase + command is simply ignored and %ask-passpharse is thus + implicitly enabled. Using this option allows to the creation + of keys without any passphrases. This option is mainly + intended for regression tests. + %transient-key + If given the keys are created using a faster and a somewhat + less secure random number generator. This option may be used + for keys which are only used for a short time and do not + require full cryptographic strength. It takes only effect if + used together with the option no-protection. o The order of the parameters does not matter except for "Key-Type" which must be the first parameter. The parameters are only for the diff --git a/doc/gpg-agent.texi b/doc/gpg-agent.texi index d504d2a99..02a2c28a9 100644 --- a/doc/gpg-agent.texi +++ b/doc/gpg-agent.texi @@ -485,7 +485,7 @@ pinentry to pop up at the @code{tty} or display you started the agent. @item --enable-ssh-support @opindex enable-ssh-support -Enable emulation of the OpenSSH Agent protocol. +Enable the OpenSSH Agent protocol. In this mode of operation, the agent does not only implement the gpg-agent protocol, but also the agent protocol used by OpenSSH @@ -512,10 +512,20 @@ has been started. To switch this display to the current one, the following command may be used: @smallexample -echo UPDATESTARTUPTTY | gpg-connect-agent +gpg-connect-agent updatestartuptty /bye @end smallexample +Although all GnuPG components try to start the gpg-agent as needed, this +is not possible for the ssh support because ssh does not know about it. +Thus if no GnuPG tool which accesses the agent has been run, there is no +guarantee that ssh is abale to use gpg-agent for authentication. To fix +this you may start gpg-agent if needed using this simple command: +@smallexample +gpg-connect-agent /bye +@end smallexample + +Adding the @option{--verbose} shows the progress of starting the agent. @end table diff --git a/doc/tools.texi b/doc/tools.texi index efb37e699..ce7d2b3be 100644 --- a/doc/tools.texi +++ b/doc/tools.texi @@ -296,6 +296,12 @@ List the global configuration file in a colon separated format. If Run a syntax check on the global configuration file. If @var{filename} is given, check that file instead. +@item --reload [@var{component}] +@opindex reload +Reload all or the given component. This is basically the sam as sending +a SIGHUP to the component. Components which don't support reloading are +ignored. + @end table @@ -1170,6 +1176,11 @@ Try to be as quiet as possible. @include opt-homedir.texi +@item --agent-program @var{file} +@opindex agent-program +Specify the agent program to be started if none is running. + + @item -S @itemx --raw-socket @var{name} @opindex S diff --git a/g10/ChangeLog b/g10/ChangeLog index 43ba53604..d155ee38c 100644 --- a/g10/ChangeLog +++ b/g10/ChangeLog @@ -1,3 +1,12 @@ +2010-10-14 Werner Koch + + * call-agent.c (agent_genkey): Add arg NO_PROTECTION. + * keygen.c (do_create, gen_elg, gen_dsa, gen_rsa, common_gen): Add + arg KEYGEN_FLAGS. + (read_parameter_file): Add options no-protection and transient-key. + (KEYGEN_FLAG_NO_PROTECTION, KEYGEN_FLAG_TRANSIENT_KEY): New. + (gen_rsa, gen_dsa, gen_elg): Use transient-key. + 2010-10-13 Werner Koch * call-agent.c (start_agent): Send option agent-awareness. diff --git a/g10/call-agent.c b/g10/call-agent.c index afbd9d6db..89a6be7ce 100644 --- a/g10/call-agent.c +++ b/g10/call-agent.c @@ -1517,10 +1517,11 @@ inq_genkey_parms (void *opaque, const char *line) /* Call the agent to generate a new key. KEYPARMS is the usual S-expression giving the parameters of the key. gpg-agent passes it - gcry_pk_genkey. */ + gcry_pk_genkey. If NO_PROTECTION is true the agent is advised not + to protect the generated key. */ gpg_error_t agent_genkey (ctrl_t ctrl, char **cache_nonce_addr, - const char *keyparms, gcry_sexp_t *r_pubkey) + const char *keyparms, int no_protection, gcry_sexp_t *r_pubkey) { gpg_error_t err; struct genkey_parm_s gk_parm; @@ -1543,7 +1544,8 @@ agent_genkey (ctrl_t ctrl, char **cache_nonce_addr, gk_parm.ctrl = ctrl; gk_parm.ctx = agent_ctx; gk_parm.keyparms = keyparms; - snprintf (line, sizeof line, "GENKEY%s%s", + snprintf (line, sizeof line, "GENKEY%s%s%s", + no_protection? " --no-protection":"", cache_nonce_addr && *cache_nonce_addr? " ":"", cache_nonce_addr && *cache_nonce_addr? *cache_nonce_addr:""); err = assuan_transact (agent_ctx, line, diff --git a/g10/call-agent.h b/g10/call-agent.h index 5496e596e..6cba9c78c 100644 --- a/g10/call-agent.h +++ b/g10/call-agent.h @@ -155,7 +155,7 @@ gpg_error_t agent_get_keyinfo (ctrl_t ctrl, const char *hexkeygrip, /* Generate a new key. */ gpg_error_t agent_genkey (ctrl_t ctrl, char **cache_nonce_addr, - const char *keyparms, + const char *keyparms, int no_protection, gcry_sexp_t *r_pubkey); /* Create a signature. */ diff --git a/g10/keygen.c b/g10/keygen.c index 16a7f0b8d..03d53ce0b 100644 --- a/g10/keygen.c +++ b/g10/keygen.c @@ -49,6 +49,9 @@ #define DEFAULT_STD_ALGO GCRY_PK_RSA #define DEFAULT_STD_KEYSIZE 2048 +#define KEYGEN_FLAG_NO_PROTECTION 1 +#define KEYGEN_FLAG_TRANSIENT_KEY 2 + #define MAX_PREFS 30 @@ -99,6 +102,7 @@ struct output_control_s { int lnr; int dryrun; int ask_passphrase; + unsigned int keygen_flags; int use_files; struct { char *fname; @@ -1137,14 +1141,15 @@ key_from_sexp (gcry_mpi_t *array, gcry_sexp_t sexp, static int common_gen (const char *keyparms, int algo, const char *algoelem, kbnode_t pub_root, u32 timestamp, u32 expireval, int is_subkey, - char **cache_nonce_addr) + int keygen_flags, char **cache_nonce_addr) { int err; PACKET *pkt; PKT_public_key *pk; gcry_sexp_t s_key; - err = agent_genkey (NULL, cache_nonce_addr, keyparms, &s_key); + err = agent_genkey (NULL, cache_nonce_addr, keyparms, + !!(keygen_flags & KEYGEN_FLAG_NO_PROTECTION), &s_key); if (err) { log_error ("agent_genkey failed: %s\n", gpg_strerror (err) ); @@ -1196,7 +1201,8 @@ common_gen (const char *keyparms, int algo, const char *algoelem, */ static int gen_elg (int algo, unsigned int nbits, KBNODE pub_root, - u32 timestamp, u32 expireval, int is_subkey, char **cache_nonce_addr) + u32 timestamp, u32 expireval, int is_subkey, + int keygen_flags, char **cache_nonce_addr) { int err; char *keyparms; @@ -1216,18 +1222,23 @@ gen_elg (int algo, unsigned int nbits, KBNODE pub_root, log_info (_("keysize rounded up to %u bits\n"), nbits ); } + /* Note that we use transient-key only if no-protection has also + been enabled. */ snprintf (nbitsstr, sizeof nbitsstr, "%u", nbits); - keyparms = xtryasprintf ("(genkey(%s(nbits %zu:%s)))", + keyparms = xtryasprintf ("(genkey(%s(nbits %zu:%s)%s))", algo == GCRY_PK_ELG_E ? "openpgp-elg" : algo == GCRY_PK_ELG ? "elg" : "x-oops" , - strlen (nbitsstr), nbitsstr); + strlen (nbitsstr), nbitsstr, + ((keygen_flags & KEYGEN_FLAG_TRANSIENT_KEY) + && (keygen_flags & KEYGEN_FLAG_NO_PROTECTION))? + "(transient-key)" : "" ); if (!keyparms) err = gpg_error_from_syserror (); else { err = common_gen (keyparms, algo, "pgy", pub_root, timestamp, expireval, is_subkey, - cache_nonce_addr); + keygen_flags, cache_nonce_addr); xfree (keyparms); } @@ -1240,7 +1251,8 @@ gen_elg (int algo, unsigned int nbits, KBNODE pub_root, */ static gpg_error_t gen_dsa (unsigned int nbits, KBNODE pub_root, - u32 timestamp, u32 expireval, int is_subkey, char **cache_nonce_addr) + u32 timestamp, u32 expireval, int is_subkey, + int keygen_flags, char **cache_nonce_addr) { int err; unsigned int qbits; @@ -1301,16 +1313,19 @@ gen_dsa (unsigned int nbits, KBNODE pub_root, snprintf (nbitsstr, sizeof nbitsstr, "%u", nbits); snprintf (qbitsstr, sizeof qbitsstr, "%u", qbits); - keyparms = xtryasprintf ("(genkey(dsa(nbits %zu:%s)(qbits %zu:%s)))", + keyparms = xtryasprintf ("(genkey(dsa(nbits %zu:%s)(qbits %zu:%s)%s))", strlen (nbitsstr), nbitsstr, - strlen (qbitsstr), qbitsstr); + strlen (qbitsstr), qbitsstr, + ((keygen_flags & KEYGEN_FLAG_TRANSIENT_KEY) + && (keygen_flags & KEYGEN_FLAG_NO_PROTECTION))? + "(transient-key)" : "" ); if (!keyparms) err = gpg_error_from_syserror (); else { err = common_gen (keyparms, PUBKEY_ALGO_DSA, "pqgy", pub_root, timestamp, expireval, is_subkey, - cache_nonce_addr); + keygen_flags, cache_nonce_addr); xfree (keyparms); } @@ -1323,7 +1338,8 @@ gen_dsa (unsigned int nbits, KBNODE pub_root, */ static int gen_rsa (int algo, unsigned int nbits, KBNODE pub_root, - u32 timestamp, u32 expireval, int is_subkey, char **cache_nonce_addr) + u32 timestamp, u32 expireval, int is_subkey, + int keygen_flags, char **cache_nonce_addr) { int err; char *keyparms; @@ -1347,15 +1363,18 @@ gen_rsa (int algo, unsigned int nbits, KBNODE pub_root, } snprintf (nbitsstr, sizeof nbitsstr, "%u", nbits); - keyparms = xtryasprintf ("(genkey(rsa(nbits %zu:%s)))", - strlen (nbitsstr), nbitsstr); + keyparms = xtryasprintf ("(genkey(rsa(nbits %zu:%s)%s))", + strlen (nbitsstr), nbitsstr, + ((keygen_flags & KEYGEN_FLAG_TRANSIENT_KEY) + && (keygen_flags & KEYGEN_FLAG_NO_PROTECTION))? + "(transient-key)" : "" ); if (!keyparms) err = gpg_error_from_syserror (); else { err = common_gen (keyparms, algo, "ne", pub_root, timestamp, expireval, is_subkey, - cache_nonce_addr); + keygen_flags, cache_nonce_addr); xfree (keyparms); } @@ -2153,7 +2172,7 @@ do_ask_passphrase (STRING2KEY **ret_s2k, int mode, int *r_canceled) static int do_create (int algo, unsigned int nbits, KBNODE pub_root, u32 timestamp, u32 expiredate, int is_subkey, - char **cache_nonce_addr) + int keygen_flags, char **cache_nonce_addr) { gpg_error_t err; @@ -2168,13 +2187,13 @@ do_create (int algo, unsigned int nbits, KBNODE pub_root, if (algo == PUBKEY_ALGO_ELGAMAL_E) err = gen_elg (algo, nbits, pub_root, timestamp, expiredate, is_subkey, - cache_nonce_addr); + keygen_flags, cache_nonce_addr); else if (algo == PUBKEY_ALGO_DSA) err = gen_dsa (nbits, pub_root, timestamp, expiredate, is_subkey, - cache_nonce_addr); + keygen_flags, cache_nonce_addr); else if (algo == PUBKEY_ALGO_RSA) err = gen_rsa (algo, nbits, pub_root, timestamp, expiredate, is_subkey, - cache_nonce_addr); + keygen_flags, cache_nonce_addr); else BUG(); @@ -2742,6 +2761,10 @@ read_parameter_file( const char *fname ) outctrl.ask_passphrase = 1; else if( !ascii_strcasecmp( keyword, "%no-ask-passphrase" ) ) outctrl.ask_passphrase = 0; + else if( !ascii_strcasecmp( keyword, "%no-protection" ) ) + outctrl.keygen_flags |= KEYGEN_FLAG_NO_PROTECTION; + else if( !ascii_strcasecmp( keyword, "%transient-key" ) ) + outctrl.keygen_flags |= KEYGEN_FLAG_TRANSIENT_KEY; else if( !ascii_strcasecmp( keyword, "%commit" ) ) { outctrl.lnr = lnr; if (proc_parameter_file( para, fname, &outctrl, 0 )) @@ -3242,7 +3265,8 @@ do_generate_keypair (struct para_data_s *para, get_parameter_uint( para, pKEYLENGTH ), pub_root, timestamp, - get_parameter_u32( para, pKEYEXPIRE ), 0, &cache_nonce); + get_parameter_u32( para, pKEYEXPIRE ), 0, + outctrl->keygen_flags, &cache_nonce); else err = gen_card_key (PUBKEY_ALGO_RSA, 1, 1, pub_root, ×tamp, @@ -3293,7 +3317,7 @@ do_generate_keypair (struct para_data_s *para, pub_root, timestamp, get_parameter_u32 (para, pSUBKEYEXPIRE), 1, - &cache_nonce); + outctrl->keygen_flags, &cache_nonce); /* Get the pointer to the generated public subkey packet. */ if (!err) { @@ -3500,7 +3524,7 @@ generate_subkeypair (KBNODE keyblock) goto leave; } - err = do_create (algo, nbits, keyblock, cur_time, expire, 1, NULL); + err = do_create (algo, nbits, keyblock, cur_time, expire, 1, 0, NULL); if (err) goto leave; diff --git a/tests/openpgp/ChangeLog b/tests/openpgp/ChangeLog index 69869209a..46da4fe33 100644 --- a/tests/openpgp/ChangeLog +++ b/tests/openpgp/ChangeLog @@ -1,3 +1,24 @@ +2010-10-14 Werner Koch + + * genkey1024.test: Use the new no-protection option. + + * decrypt-dsa.test: Do not specify an extra keyring. The keyring + has been loaded into pubring.gpg. + * sigs-dsa.test: Ditto. + * encrypt-dsa.test: Ditto. + * signencrypt-dsa.test: Ditto. + + * decrypt.test: Remove passphrase stuff. + * sigs.test: Ditto. + + * privkeys/: New. + + * Makefile.am: Move most stuff to ... + * version.test: Prepare data files etc. + * finish.test: New. + * defs.inc: Set all envvars. + (usrname1, usrname2, username3): Use full mail address. + 2010-06-07 Werner Koch * Makefile.am (TESTS_ENVIRONMENT): New. Start all scripts under diff --git a/tests/openpgp/Makefile.am b/tests/openpgp/Makefile.am index ba1a65529..9ea2237b9 100644 --- a/tests/openpgp/Makefile.am +++ b/tests/openpgp/Makefile.am @@ -1,4 +1,6 @@ -# Copyright (C) 1998, 1999, 2000, 2001, 2003 Free Software Foundation, Inc. +# Makefile.am - For tests/openpgp +# Copyright (C) 1998, 1999, 2000, 2001, 2003, +# 2010 Free Software Foundation, Inc. # # This file is part of GnuPG. # @@ -16,15 +18,15 @@ # along with this program; if not, see . # Process this file with automake to create Makefile.in -GPG_IMPORT = ../../g10/gpg2 --homedir $(abs_builddir) \ - --quiet --yes --no-permission-warning --import # Programs required before we can run these tests. required_pgms = ../../g10/gpg2 ../../agent/gpg-agent \ - ../../tools/gpg-connect-agent + ../../tools/gpg-connect-agent ../../tools/mk-tdata TESTS_ENVIRONMENT = GNUPGHOME=$(abs_builddir) GPG_AGENT_INFO= LC_ALL=C +# Note: version.test needs to be the first test to run and finish.test +# the last one TESTS = version.test mds.test \ decrypt.test decrypt-dsa.test \ sigs.test sigs-dsa.test \ @@ -36,7 +38,7 @@ TESTS = version.test mds.test \ armdetachm.test detachm.test genkey1024.test \ conventional.test conventional-mdc.test \ multisig.test verify.test armor.test \ - import.test + import.test finish.test TEST_FILES = pubring.asc secring.asc plain-1o.asc plain-2o.asc plain-3o.asc \ @@ -46,73 +48,34 @@ TEST_FILES = pubring.asc secring.asc plain-1o.asc plain-2o.asc plain-3o.asc \ bug537-test.data.asc bug894-test.asc \ bug1223-good.asc bug1223-bogus.asc -DATA_FILES = data-500 data-9000 data-32000 data-80000 plain-large +data_files = data-500 data-9000 data-32000 data-80000 plain-large + +priv_keys = privkeys/50B2D4FA4122C212611048BC5FC31BD44393626E.asc \ + privkeys/7E201E28B6FEB2927B321F443205F4724EBE637E.asc \ + privkeys/13FDB8809B17C5547779F9D205C45F47CE0217CE.asc \ + privkeys/343D8AF79796EE107D645A2787A9D9252F924E6F.asc \ + privkeys/8B5ABF3EF9EB8D96B91A0B8C2C4401C91C834C34.asc \ + privkeys/0D6F6AD4C4C803B25470F9104E9F4E6A4CA64255.asc \ + privkeys/FD692BD59D6640A84C8422573D469F84F3B98E53.asc \ + privkeys/76F7E2B35832976B50A27A282D9B87E44577EB66.asc \ + privkeys/A0747D5F9425E6664F4FFBEED20FBCA79FDED2BD.asc + EXTRA_DIST = defs.inc $(TESTS) $(TEST_FILES) \ - mkdemodirs signdemokey + mkdemodirs signdemokey $(priv_keys) -CLEANFILES = prepared.stamp x y yy z out err $(DATA_FILES) \ +CLEANFILES = prepared.stamp x y yy z out err $(data_files) \ plain-1 plain-2 plain-3 trustdb.gpg *.lock .\#lk* \ *.test.log gpg_dearmor gpg.conf gpg-agent.conf S.gpg-agent \ - pubring.gpg secring.gpg pubring.pkr secring.skr + pubring.gpg secring.gpg pubring.pkr secring.skr \ + gnupg-test.stop DISTCLEANFILES = pubring.gpg~ random_seed - -all-local: prepared.stamp - -distclean-local: - $(srcdir)/mkdemodirs --clean - -prepared.stamp: ./pubring.gpg ./secring.gpg ./plain-1 ./plain-2 ./plain-3 \ - ./pubring.pkr ./secring.skr ./gpg_dearmor $(DATA_FILES) - $(GPG_IMPORT) $(srcdir)/pubdemo.asc - echo timestamp >./prepared.stamp - # We need to depend on a couple of programs so that the tests don't # start before all programs are built. -./gpg_dearmor: $(required_pgms) - echo '#!/bin/sh' >./gpg_dearmor - echo "../../g10/gpg2 --no-options --no-greeting \ - --no-secmem-warning --batch --dearmor" >>./gpg_dearmor - chmod 755 ./gpg_dearmor - -./pubring.gpg: $(srcdir)/pubring.asc $(srcdir)/pubdemo.asc ./gpg_dearmor - ./gpg_dearmor > ./pubring.gpg < $(srcdir)/pubring.asc - -./secring.gpg: $(srcdir)/secring.asc ./gpg_dearmor - ./gpg_dearmor > ./secring.gpg < $(srcdir)/secring.asc +all-local: $(required_pgms) -./pubring.pkr: $(srcdir)/pubring.pkr.asc ./gpg_dearmor - ./gpg_dearmor > ./pubring.pkr < $(srcdir)/pubring.pkr.asc - -./secring.skr: $(srcdir)/secring.skr.asc ./gpg_dearmor - ./gpg_dearmor > ./secring.skr < $(srcdir)/secring.skr.asc - -./plain-1: $(srcdir)/plain-1o.asc ./gpg_dearmor - ./gpg_dearmor > ./plain-1 < $(srcdir)/plain-1o.asc - -./plain-2: $(srcdir)/plain-2o.asc ./gpg_dearmor - ./gpg_dearmor > ./plain-2 < $(srcdir)/plain-2o.asc - -./plain-3: $(srcdir)/plain-3o.asc ./gpg_dearmor - ./gpg_dearmor > ./plain-3 < $(srcdir)/plain-3o.asc - - -data-500: - ../../tools/mk-tdata 500 >data-500 -data-9000: - ../../tools/mk-tdata 9000 >data-9000 -data-32000: - ../../tools/mk-tdata 32000 >data-32000 -data-80000: - ../../tools/mk-tdata 80000 >data-80000 -plain-large: - cat $(srcdir)/../../doc/HACKING \ - $(srcdir)/../../doc/DETAILS \ - $(srcdir)/../../doc/gpg.texi >plain-large - -# To speed up key generation we create a dummy random seed file -random_seed: - ../../tools/mk-tdata 600 +distclean-local: + $(srcdir)/mkdemodirs --clean diff --git a/tests/openpgp/decrypt-dsa.test b/tests/openpgp/decrypt-dsa.test index 7220f8a22..ba83fea07 100755 --- a/tests/openpgp/decrypt-dsa.test +++ b/tests/openpgp/decrypt-dsa.test @@ -12,7 +12,7 @@ #info Checking decryption of supplied DSA encrypted file for i in "plain-1" ; do - $GPG $dsa_keyrings -o y --yes $srcdir/$i-pgp.asc + $GPG -o y --yes $srcdir/$i-pgp.asc cmp $i y || error "$i: mismatch" done diff --git a/tests/openpgp/decrypt.test b/tests/openpgp/decrypt.test index 7b68b25ec..370dc964b 100755 --- a/tests/openpgp/decrypt.test +++ b/tests/openpgp/decrypt.test @@ -12,7 +12,7 @@ #info Checking decryption of supplied files for i in $plain_files ; do - echo "$usrpass1" | $GPG --passphrase-fd 0 -o y --yes $srcdir/$i.asc + $GPG -o y --yes $srcdir/$i.asc cmp $i y || error "$i: mismatch" done diff --git a/tests/openpgp/defs.inc b/tests/openpgp/defs.inc index 1158fb0cd..bc0d76e10 100755 --- a/tests/openpgp/defs.inc +++ b/tests/openpgp/defs.inc @@ -12,22 +12,21 @@ #------ constants --------------- #-------------------------------- -# Note that usrpass1 is also used in Makefile.am -usrname1="one" +usrname1="one@example.com" usrpass1="def" -usrname2="two" +usrname2="two@example.com" usrpass2="" -usrname3="three" +usrname3="three@example.com" usrpass3="" dsa_usrname1="pgp5" -# we use the sub key because we do not yet have the logic to -# to derive the first encryption key from a keyblock (I guess) +# we use the sub key because we do not yet have the logic to to derive +# the first encryption key from a keyblock (I guess) (Well of course +# we have this by now and the notation below will lookup the primary +# first and the search for the encryption subkey.) dsa_usrname2="0xCB879DE9" -dsa_keyrings="--keyring ./pubring.pkr --secret-keyring ./secring.skr" - plain_files="plain-1 plain-2 plain-3" data_files="data-500 data-9000 data-32000 data-80000" @@ -50,6 +49,7 @@ defs_error_seen=no fatal () { echo "$pgmname: fatal:" $* >&2 echo "$pgmname: fatal:" $* >&5 + echo stop >gnupg-test.stop exit 1; } @@ -121,7 +121,7 @@ echo_n () { #} have_pubkey_algo () { - if ../../g10/gpg2 --homedir . --version | grep "Pubkey:.*$1" >/dev/null + if $GPG --version | grep "Pubkey:.*$1" >/dev/null then true else @@ -130,7 +130,7 @@ have_pubkey_algo () { } have_cipher_algo () { - if ../../g10/gpg2 --homedir . --version | grep "Cipher:.*$1" >/dev/null + if $GPG --version | grep "Cipher:.*$1" >/dev/null then true else @@ -139,7 +139,7 @@ have_cipher_algo () { } have_hash_algo () { - if ../../g10/gpg2 --homedir . --version | grep "Hash:.*$1" >/dev/null + if $GPG --version | grep "Hash:.*$1" >/dev/null then true else @@ -148,11 +148,13 @@ have_hash_algo () { } all_cipher_algos () { - ../../g10/gpg2 --homedir . --with-colons --list-config ciphername | sed 's/^cfg:ciphername://; s/;/ /g' + $GPG --with-colons --list-config ciphername \ + | sed 's/^cfg:ciphername://; s/;/ /g' } all_hash_algos () { - ../../g10/gpg2 --homedir . --with-colons --list-config digestname | sed 's/^cfg:digestname://; s/;/ /g' + $GPG --with-colons --list-config digestname \ + | sed 's/^cfg:digestname://; s/;/ /g' } set -e @@ -161,6 +163,16 @@ pgmname=`basename $0` [ -z "$srcdir" ] && fatal "not called from make" +# +if [ -f gnupg-test.stop ]; then + if [ $pgmname = "version.test" ]; then + rm gnupg-test.stop + else + # Skip the rest of the tests. + exit 77 + fi +fi + # Always work in the current directory. We set GNUPGHOME only if it # has not been set already. Usually it is set through the Makefile's # TESTS_ENVIRONMENT macro. @@ -172,21 +184,32 @@ elif [ "$GNUPGHOME" != `/bin/pwd` ]; then exit 1 fi +# We don't use GPG_AGENT_INFO anymore - better reset it. +unset GPG_AGENT_INFO + +# (--no-permission-warning makes only sense on the commandline) +GPG="../../g10/gpg2 --no-permission-warning " +# (We may not use a relative name for gpg-agent.) +GPG_AGENT="$(cd ../../agent && /bin/pwd)/gpg-agent" +GPG_CONNECT_AGENT="../../tools/gpg-connect-agent" +GPGCONF="../../tools/gpgconf" +GPG_PRESET_PASSPHRASE="../../agent/gpg-preset-passphrase" +MKTDATA="../../tools/mk-tdata" + # Make sure we have a valid option files even with VPATH builds. for f in gpg.conf gpg-agent.conf ; do if [ -f ./$f ]; then : elif [ -f $srcdir/$f.tmpl ]; then cat $srcdir/$f.tmpl >$f + if [ "$f" = "gpg.conf" ]; then + echo "agent-program $GPG_AGENT" >>gpg.conf + fi fi done -# (--no-permission-warning makes only sense on the commandline) -GPG="../../g10/gpg2 --no-permission-warning " - echo "Test: $pgmname" > ${pgmname}.log echo "GNUPGHOME=$GNUPGHOME" >> ${pgmname}.log -echo "GPG_AGENT_INFO=$GPG_AGENT_INFO" >> ${pgmname}.log exec 5>&2 2>>${pgmname}.log : diff --git a/tests/openpgp/encrypt-dsa.test b/tests/openpgp/encrypt-dsa.test index 01fe33aa8..ed474d0ed 100755 --- a/tests/openpgp/encrypt-dsa.test +++ b/tests/openpgp/encrypt-dsa.test @@ -12,17 +12,17 @@ #info Checking encryption for i in $plain_files $data_files ; do - $GPG $dsa_keyrings --always-trust -e -o x --yes -r "$dsa_usrname2" $i - $GPG $dsa_keyrings -o y --yes x + $GPG --always-trust -e -o x --yes -r "$dsa_usrname2" $i + $GPG -o y --yes x cmp $i y || error "$i: mismatch" done for ca in `all_cipher_algos` ; do echo_n "$ca " for i in $plain_files $data_files ; do - $GPG $dsa_keyrings --always-trust --cipher-algo $ca -e \ + $GPG --always-trust --cipher-algo $ca -e \ -o x --yes -r "$dsa_usrname2" $i - $GPG $dsa_keyrings -o y --yes x + $GPG -o y --yes x cmp $i y || error "$i: mismatch" done done diff --git a/tests/openpgp/finish.test b/tests/openpgp/finish.test new file mode 100755 index 000000000..fced57036 --- /dev/null +++ b/tests/openpgp/finish.test @@ -0,0 +1,17 @@ +#!/bin/sh +# Copyright 2010 Free Software Foundation, Inc. +# This file is free software; as a special exception the author gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. This file is +# distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY, to the extent permitted by law; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +. $srcdir/defs.inc || exit 3 + +if $GPG_AGENT --quiet; then + $GPG_CONNECT_AGENT killagent /bye >/dev/null +fi + +exit 0 + diff --git a/tests/openpgp/genkey1024.test b/tests/openpgp/genkey1024.test index 1d716d86d..99a0d5d72 100755 --- a/tests/openpgp/genkey1024.test +++ b/tests/openpgp/genkey1024.test @@ -10,10 +10,7 @@ . $srcdir/defs.inc || exit 3 -# FIXME: Skip this test for now -exit 77 - -$GPG --quiet --batch --debug-quick-random --gen-key < + * gpg-connect-agent.c: Add option --agent-program. + * gpg-connect-agent.c (start_agent): Rewrite using the start_new_gpg_agent function. diff --git a/tools/gpg-connect-agent.c b/tools/gpg-connect-agent.c index 652f288c5..8de67bbf0 100644 --- a/tools/gpg-connect-agent.c +++ b/tools/gpg-connect-agent.c @@ -56,6 +56,7 @@ enum cmd_and_opt_values oNoVerbose = 500, oHomedir, + oAgentProgram, oHex, oDecode, oNoExtConnect @@ -85,6 +86,7 @@ static ARGPARSE_OPTS opts[] = { ARGPARSE_s_n (oNoVerbose, "no-verbose", "@"), ARGPARSE_s_s (oHomedir, "homedir", "@" ), + ARGPARSE_s_s (oAgentProgram, "agent-program", "@"), ARGPARSE_end () }; @@ -96,6 +98,7 @@ struct int verbose; /* Verbosity level. */ int quiet; /* Be extra quiet. */ const char *homedir; /* Configuration directory name */ + const char *agent_program; /* Value of --agent-program. */ int hex; /* Print data lines in hex format. */ int decode; /* Decode received data lines. */ const char *raw_socket; /* Name of socket to connect in raw mode. */ @@ -1186,6 +1189,7 @@ main (int argc, char **argv) case oVerbose: opt.verbose++; break; case oNoVerbose: opt.verbose = 0; break; case oHomedir: opt.homedir = pargs.r.ret_str; break; + case oAgentProgram: opt.agent_program = pargs.r.ret_str; break; case oHex: opt.hex = 1; break; case oDecode: opt.decode = 1; break; case oRawSocket: opt.raw_socket = pargs.r.ret_str; break; @@ -2168,7 +2172,7 @@ start_agent (void) err = start_new_gpg_agent (&ctx, GPG_ERR_SOURCE_DEFAULT, opt.homedir, - NULL, + opt.agent_program, NULL, NULL, session_env, !opt.quiet, 0, -- cgit v1.2.3