From 2687db38df84bfe64e03862ba0c2d4257d766fac Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Fri, 9 Nov 2001 09:36:22 +0000 Subject: [PATCH] * export.c (do_export_stream): Put all given names into a search description and change the loop so that all matching names are returned. --- g10/ChangeLog | 6 ++++++ g10/export.c | 60 +++++++++++++++++++++++++++------------------------ g10/keylist.c | 2 +- g10/sign.c | 2 +- 4 files changed, 40 insertions(+), 30 deletions(-) diff --git a/g10/ChangeLog b/g10/ChangeLog index 96e783f76..015b78a65 100644 --- a/g10/ChangeLog +++ b/g10/ChangeLog @@ -1,3 +1,9 @@ +2001-11-09 Werner Koch + + * export.c (do_export_stream): Put all given names into a search + description and change the loop so that all matching names are + returned. + 2001-11-08 Werner Koch * pubkey-enc.c (get_it): To reduce the number of questions on the diff --git a/g10/export.c b/g10/export.c index 078bfe189..1d2aaf314 100644 --- a/g10/export.c +++ b/g10/export.c @@ -115,42 +115,46 @@ do_export_stream( IOBUF out, STRLIST users, int secret, int onlyrfc, int *any ) PACKET pkt; KBNODE keyblock = NULL; KBNODE kbctx, node; + int ndesc; + KEYDB_SEARCH_DESC *desc; KEYDB_HANDLE kdbhd; STRLIST sl; - int all = !users; - int all_first = 1; *any = 0; init_packet( &pkt ); - kdbhd = keydb_new (secret); - /* use the correct sequence. strlist_last,prev do work correctly with - * NULL pointers :-) */ - for( sl=strlist_last(users); sl || all ; sl=strlist_prev( users, sl )) { - if( all ) { /* get the next user */ - rc = all_first ? keydb_search_first (kdbhd) - : keydb_search_next (kdbhd); - all_first = 0; - if( rc == -1 ) /* EOF */ - break; - if( rc ) { - log_error ("error searching key: %s\n", g10_errstr(rc)); - break; - } - } - else { - KEYDB_SEARCH_DESC desc; - - classify_user_id (sl->d, &desc); - rc = desc.mode? keydb_search (kdbhd, &desc, 1):G10ERR_INV_USER_ID; - if( rc ) { + if (!users) { + ndesc = 1; + desc = m_alloc_clear ( ndesc * sizeof *desc); + desc[0].mode = KEYDB_SEARCH_MODE_FIRST; + } + else { + for (ndesc=0, sl=users; sl; sl = sl->next, ndesc++) + ; + desc = m_alloc ( ndesc * sizeof *desc); + + for (ndesc=0, sl=users; sl; sl = sl->next) { + classify_user_id (sl->d, desc+ndesc); + if (desc->mode) + ndesc++; + else log_error (_("key `%s' not found: %s\n"), - sl->d, g10_errstr (rc)); - rc = 0; - continue; - } - } + sl->d, g10_errstr (G10ERR_INV_USER_ID)); + } + + /* it would be nice to see which of the given users did + actually match one in the keyring. To implement this we + need to have a found flag for each entry in desc and to set + this we must check all those entries after a match to mark + all matched one - currently we stop at the first match. To + do this we need an extra flag to enable this feature so */ + } + + + while (!(rc = keydb_search (kdbhd, desc, ndesc))) { + if (!users) + desc[0].mode = KEYDB_SEARCH_MODE_NEXT; /* read the keyblock */ rc = keydb_get_keyblock (kdbhd, &keyblock ); diff --git a/g10/keylist.c b/g10/keylist.c index dc79a7afd..79e60262e 100644 --- a/g10/keylist.c +++ b/g10/keylist.c @@ -122,7 +122,7 @@ list_one( STRLIST names, int secret ) GETKEY_CTX ctx; /* fixme: using the bynames function has the disadvantage that we - * don't knowether one of the names given was not found. OTOH, + * don't know wether one of the names given was not found. OTOH, * this function has the advantage to list the names in the * sequence as defined by the keyDB and does not duplicate * outputs. A solution could be do test whether all given have diff --git a/g10/sign.c b/g10/sign.c index 5da8073b3..a3e0595c6 100644 --- a/g10/sign.c +++ b/g10/sign.c @@ -1002,7 +1002,7 @@ make_keysig_packet( PKT_signature **ret_sig, PKT_public_key *pk, break; case PUBKEY_ALGO_RSA_S: case PUBKEY_ALGO_RSA: - if (opt.force_v4_sigs || sk->version > 3) + if (opt.force_v4_certs || sk->version > 3) digest_algo = DIGEST_ALGO_SHA1; else digest_algo = DIGEST_ALGO_MD5;