* trustdb.h, trustdb.c (register_trusted_keyid): New. Adds a keyid to the
authorDavid Shaw <dshaw@jabberwocky.com>
Sat, 1 Nov 2003 01:13:16 +0000 (01:13 +0000)
committerDavid Shaw <dshaw@jabberwocky.com>
Sat, 1 Nov 2003 01:13:16 +0000 (01:13 +0000)
list of ultimately trusted keys.

* keygen.c (do_generate_keypair): Use it here so that the ultimate
ownertrust happens before the trustdb (might be) rebuilt.  Also fix an
error where the newly generated pk is thought to be a subkey by the
trustdb.

* g10.c (main): Fix --export-all do actually do something different than
--export.

* pkclist.c (build_pk_list): Show all recipients rather than showing each
recipient as they are added.

* mainproc.c (proc_symkey_enc, proc_encrypted): Keep a count of the number
of passphrases that can decrypt a symmetric or mixed symmetric/pk message
and include it in the list of keys shown to the user.

g10/ChangeLog
g10/g10.c
g10/keygen.c
g10/mainproc.c
g10/pkclist.c
g10/trustdb.c
g10/trustdb.h

index b7ffc15..4c9f29f 100644 (file)
@@ -1,3 +1,24 @@
+2003-10-31  David Shaw  <dshaw@jabberwocky.com>
+
+       * trustdb.h, trustdb.c (register_trusted_keyid): New.  Adds a
+       keyid to the list of ultimately trusted keys.
+
+       * keygen.c (do_generate_keypair): Use it here so that the ultimate
+       ownertrust happens before the trustdb (might be) rebuilt.  Also
+       fix an error where the newly generated pk is thought to be a
+       subkey by the trustdb.
+
+       * g10.c (main): Fix --export-all do actually do something
+       different than --export.
+
+       * pkclist.c (build_pk_list): Show all recipients rather than
+       showing each recipient as they are added.
+
+       * mainproc.c (proc_symkey_enc, proc_encrypted): Keep a count of
+       the number of passphrases that can decrypt a symmetric or mixed
+       symmetric/pk message and include it in the list of keys shown to
+       the user.
+
 2003-10-30  David Shaw  <dshaw@jabberwocky.com>
 
        * misc.c (compress_algo_to_string, string_to_compress_algo,
index 28ebc8d..d0ef9e5 100644 (file)
--- a/g10/g10.c
+++ b/g10/g10.c
@@ -1,5 +1,6 @@
 /* g10.c - The GnuPG utility (main for gpg)
- * Copyright (C) 1998,1999,2000,2001,2002,2003 Free Software Foundation, Inc.
+ * Copyright (C) 1998, 1999, 2000, 2001, 2002,
+ *               2003 Free Software Foundation, Inc.
  *
  * This file is part of GnuPG.
  *
@@ -1399,7 +1400,10 @@ main( int argc, char **argv )
          case aSearchKeys: set_cmd( &cmd, aSearchKeys); break;
          case aRefreshKeys: set_cmd( &cmd, aRefreshKeys); break;
          case aExport: set_cmd( &cmd, aExport); break;
-         case aExportAll: set_cmd( &cmd, aExportAll); break;
+         case aExportAll:
+           opt.export_options|=EXPORT_INCLUDE_NON_RFC;
+           set_cmd(&cmd,aExport);
+           break;
          case aListKeys: set_cmd( &cmd, aListKeys); break;
          case aListSigs: set_cmd( &cmd, aListSigs); break;
          case aExportSecret: set_cmd( &cmd, aExportSecret); break;
@@ -2708,7 +2712,6 @@ main( int argc, char **argv )
        break;
 
       case aExport:
-      case aExportAll:
       case aSendKeys:
       case aRecvKeys:
        sl = NULL;
@@ -2736,7 +2739,6 @@ main( int argc, char **argv )
        sl = NULL;
        for( ; argc; argc--, argv++ )
          append_to_strlist2( &sl, *argv, utf8_strings );
-
        rc=keyserver_search( sl );
        if(rc)
          log_error(_("keyserver search failed: %s\n"),g10_errstr(rc));
index b57206f..51354af 100644 (file)
@@ -2489,14 +2489,16 @@ do_generate_keypair( struct para_data_s *para,
                 && !(get_parameter_uint( para,pKEYUSAGE) & PUBKEY_USAGE_ENC);
             PKT_public_key *pk = find_kbnode (pub_root, 
                                     PKT_PUBLIC_KEY)->pkt->pkt.public_key;
-            
-            update_ownertrust (pk,
-                               ((get_ownertrust (pk) & ~TRUST_MASK)
-                                | TRUST_ULTIMATE ));
+
+           keyid_from_pk(pk,pk->main_keyid);
+           register_trusted_keyid(pk->main_keyid);
+
+           update_ownertrust (pk,
+                              ((get_ownertrust (pk) & ~TRUST_MASK)
+                               | TRUST_ULTIMATE ));
 
            if (!opt.batch) {
                 tty_printf(_("public and secret key created and signed.\n") );
-                tty_printf(_("key marked as ultimately trusted.\n") );
                tty_printf("\n");
                list_keyblock(pub_root,0,1,NULL);
             }
index aefaad6..6fb4596 100644 (file)
@@ -50,7 +50,6 @@ struct kidlist_item {
 };
 
 
-
 /****************
  * Structure to hold the context
  */
@@ -72,6 +71,7 @@ struct mainproc_context {
     IOBUF iobuf;    /* used to get the filename etc. */
     int trustletter; /* temp usage in list_node */
     ulong local_id;    /* ditto */
+    ulong symkeys;
     struct kidlist_item *pkenc_list;   /* list of encryption packets */
     struct {
         int op;
@@ -327,7 +327,9 @@ proc_symkey_enc( CTX c, PACKET *pkt )
              c->dek->algo_info_printed = 1;
          }
       }
+
  leave:
+    c->symkeys++;
     free_packet(pkt);
 }
 
@@ -477,10 +479,15 @@ proc_encrypted( CTX c, PACKET *pkt )
 {
     int result = 0;
 
-    if (!opt.quiet) {
+    if (!opt.quiet)
+      {
+       if(c->symkeys>1)
+         log_info(_("encrypted with %lu passphrases\n"),c->symkeys);
+       else if(c->symkeys==1)
+         log_info(_("encrypted with 1 passphrase\n"));
         print_pkenc_list ( c->pkenc_list, 1 );
         print_pkenc_list ( c->pkenc_list, 0 );
-    }
+      }
 
     write_status( STATUS_BEGIN_DECRYPTION );
 
index b11cda5..5f28f5f 100644 (file)
@@ -895,12 +895,41 @@ build_pk_list( STRLIST rcpts, PK_LIST *ret_pk_list, unsigned use )
            else if(backlog) {
              answer=pop_strlist(&backlog);
            }
-           else {
+           else
+             {
+               PK_LIST iter;
+
+               tty_printf("\n");
+               tty_printf(_("Current recipients:\n"));
+               for(iter=pk_list;iter;iter=iter->next)
+                 {
+                   u32 keyid[2];
+
+                   keyid_from_pk(iter->pk,keyid);
+                   tty_printf("%4u%c/%08lX %s \"",
+                              nbits_from_pk(iter->pk),
+                              pubkey_letter(iter->pk->pubkey_algo),
+                              (ulong)keyid[1],
+                              datestr_from_pk(iter->pk));
+
+                   if(iter->pk->user_id)
+                     tty_print_utf8_string(iter->pk->user_id->name,
+                                           iter->pk->user_id->len);
+                   else
+                     {
+                       size_t n;
+                       char *p = get_user_id( keyid, &n );
+                       tty_print_utf8_string( p, n );
+                       m_free(p);
+                     }
+                   tty_printf("\"\n");
+                 }
+
                answer = cpr_get_utf8("pklist.user_id.enter",
                         _("\nEnter the user ID.  End with an empty line: "));
                trim_spaces(answer);
                cpr_kill_prompt();
-           }
+             }
            if( !answer || !*answer ) {
                m_free(answer);
                break;
@@ -947,26 +976,6 @@ build_pk_list( STRLIST rcpts, PK_LIST *ret_pk_list, unsigned use )
                        }
                        else {
                            PK_LIST r;
-                           u32 keyid[2];
-
-                           keyid_from_pk( pk, keyid);
-                           tty_printf("Added %4u%c/%08lX %s \"",
-                                      nbits_from_pk( pk ),
-                                      pubkey_letter( pk->pubkey_algo ),
-                                      (ulong)keyid[1],
-                                      datestr_from_pk( pk ) );
-                           if(pk->user_id)
-                             tty_print_utf8_string(pk->user_id->name,
-                                                   pk->user_id->len);
-                           else
-                             {
-                               size_t n;
-                               char *p = get_user_id( keyid, &n );
-                               tty_print_utf8_string( p, n );
-                               m_free(p);
-                             }
-                           tty_printf("\"\n");
-
                            r = m_alloc( sizeof *r );
                            r->pk = pk; pk = NULL;
                            r->next = pk_list;
index 743d9c7..be88358 100644 (file)
@@ -205,23 +205,31 @@ release_key_array ( struct key_array *keys )
  * FIXME: Should be replaced by a function to add those keys to the trustdb.
  */
 void
-register_trusted_key( const char *string )
+register_trusted_keyid(u32 *keyid)
 {
-  KEYDB_SEARCH_DESC desc;
   struct key_item *k;
 
-  if (classify_user_id (string, &desc) != KEYDB_SEARCH_MODE_LONG_KID ) {
-    log_error(_("`%s' is not a valid long keyID\n"), string );
-    return;
-  }
-
   k = new_key_item ();
-  k->kid[0] = desc.u.kid[0];
-  k->kid[1] = desc.u.kid[1];
+  k->kid[0] = keyid[0];
+  k->kid[1] = keyid[1];
   k->next = user_utk_list;
   user_utk_list = k;
 }
 
+void
+register_trusted_key( const char *string )
+{
+  KEYDB_SEARCH_DESC desc;
+
+  if (classify_user_id (string, &desc) != KEYDB_SEARCH_MODE_LONG_KID )
+    {
+      log_error(_("`%s' is not a valid long keyID\n"), string );
+      return;
+    }
+
+  register_trusted_keyid(desc.u.kid);
+}
+
 /*
  * Helper to add a key to the global list of ultimately trusted keys.
  * Retruns: true = inserted, false = already in in list.
index bd7344b..ad19275 100644 (file)
@@ -39,6 +39,7 @@
 #define TRUST_FLAG_PENDING_CHECK 256 /* a check-trustdb is pending */
 
 /*-- trustdb.c --*/
+void register_trusted_keyid(u32 *keyid);
 void register_trusted_key( const char *string );
 void check_trustdb (void);
 void update_trustdb (void);