2002-10-18 Timo Schulz <ts@winpt.org>
authorTimo Schulz <twoaday@freakmail.de>
Fri, 18 Oct 2002 15:41:33 +0000 (15:41 +0000)
committerTimo Schulz <twoaday@freakmail.de>
Fri, 18 Oct 2002 15:41:33 +0000 (15:41 +0000)
        * keylist.c: (print_pubkey_info): New.
        (print_seckey_info): New.
        * main.h: Prototypes for the new functions.
        * delkey.c (do_delete_key): Use it here.
        * revoke.c (gen_desig_revoke): Ditto.

g10/ChangeLog
g10/delkey.c
g10/keylist.c
g10/main.h
g10/revoke.c

index d4221d1..88ce90c 100644 (file)
@@ -1,3 +1,11 @@
+2002-10-18  Timo Schulz  <ts@winpt.org>
+
+       * keylist.c: (print_pubkey_info): New.
+       (print_seckey_info): New.
+       * main.h: Prototypes for the new functions.       
+       * delkey.c (do_delete_key): Use it here.
+       * revoke.c (gen_desig_revoke): Ditto.
+       
 2002-10-17  Werner Koch  <wk@gnupg.org>
 
        * pkclist.c (do_edit_ownertrust): Show all user IDs.  This should
index ca578a5..e4cada3 100644 (file)
@@ -127,23 +127,11 @@ do_delete_key( const char *username, int secret, int *r_sec_avail )
         log_info (_("(unless you specify the key by fingerprint)\n"));
       }
     else {
-       char *p;
-       size_t n;
-
-       if( secret )
-           tty_printf("sec  %4u%c/%08lX %s   ",
-                     nbits_from_sk( sk ),
-                     pubkey_letter( sk->pubkey_algo ),
-                     (ulong)keyid[1], datestr_from_sk(sk) );
-       else
-           tty_printf("pub  %4u%c/%08lX %s   ",
-                     nbits_from_pk( pk ),
-                     pubkey_letter( pk->pubkey_algo ),
-                     (ulong)keyid[1], datestr_from_pk(pk) );
-       p = get_user_id( keyid, &n );
-       tty_print_utf8_string( p, n );
-       m_free(p);
-       tty_printf("\n\n");
+        if( secret )
+            print_seckey_info( sk );
+        else
+            print_pubkey_info( pk );
+       tty_printf( "\n" );
 
        yes = cpr_get_answer_is_yes( secret? "delete_key.secret.okay"
                                           : "delete_key.okay",
index a1a0e4c..e33f000 100644 (file)
@@ -73,6 +73,48 @@ secret_key_list( STRLIST list )
 }
 
 void
+print_seckey_info (PKT_secret_key *sk)
+{
+    u32 sk_keyid[2];
+    size_t n;
+    char *p;
+
+    keyid_from_sk (sk, sk_keyid);
+    tty_printf ("\nsec  %4u%c/%08lX %s   ",
+                nbits_from_sk (sk),
+                pubkey_letter (sk->pubkey_algo),
+                (ulong)sk_keyid[1], datestr_from_sk (sk));
+    
+    p = get_user_id (sk_keyid, &n);
+    tty_print_utf8_string (p, n);
+    m_free (p);
+
+    tty_printf ("\n");   
+}
+
+void
+print_pubkey_info (PKT_public_key *pk)
+{
+  u32 pk_keyid[2];
+  size_t n;
+  char *p;
+
+  keyid_from_pk (pk, pk_keyid);
+  tty_printf ("\npub  %4u%c/%08lX %s   ",
+              nbits_from_pk (pk),
+              pubkey_letter (pk->pubkey_algo),
+              (ulong)pk_keyid[1], datestr_from_pk (pk));
+
+
+  p = get_user_id (pk_keyid, &n);
+  tty_print_utf8_string (p, n);
+  m_free (p);
+  
+  tty_printf ("\n\n"); 
+}
+
+
+void
 show_policy_url(PKT_signature *sig,int indent)
 {
   const byte *p;
index f16355b..15e67dd 100644 (file)
@@ -198,6 +198,8 @@ void print_fingerprint (PKT_public_key *pk, PKT_secret_key *sk, int mode);
 void show_policy_url(PKT_signature *sig,int indent);
 void show_notation(PKT_signature *sig,int indent);
 void set_attrib_fd(int fd);
+void print_seckey_info (PKT_secret_key *sk);
+void print_pubkey_info (PKT_public_key *pk);
 
 /*-- verify.c --*/
 void print_file_status( int status, const char *name, int what );
index b6e9e63..6624879 100644 (file)
@@ -260,35 +260,16 @@ gen_desig_revoke( const char *uname )
        /* We have the revocation key */
        if(!rc)
          {
-           size_t n;
-           char *p;
-           u32 sk_keyid[2];
-           PKT_signature *revkey=NULL;
-
-           any=1;
-           keyid_from_sk(sk,sk_keyid);
-
-           tty_printf("\npub  %4u%c/%08lX %s   ",
-                      nbits_from_pk( pk ),
-                      pubkey_letter( pk->pubkey_algo ),
-                      (ulong)keyid[1], datestr_from_pk(pk) );
-
-           p = get_user_id( keyid, &n );
-           tty_print_utf8_string( p, n );
-           m_free(p);
-           tty_printf("\n\n");
-
-           tty_printf(_("To be revoked by:\n"));
-
-           tty_printf("\nsec  %4u%c/%08lX %s   ",
-                      nbits_from_sk( sk ),
-                      pubkey_letter( sk->pubkey_algo ),
-                      (ulong)sk_keyid[1], datestr_from_sk(sk) );
-
-           p = get_user_id( sk_keyid, &n );
-           tty_print_utf8_string( p, n );
-           m_free(p);
-           tty_printf("\n");
+           PKT_signature *revkey = NULL;
+
+           any = 1;
+
+            print_pubkey_info (pk);
+           tty_printf ("\n");
+
+           tty_printf (_("To be revoked by:\n"));
+            print_seckey_info (sk);
+
            if(pk->revkey[i].class&0x40)
              tty_printf(_("(This is a sensitive revocation key)\n"));
            tty_printf("\n");
@@ -464,17 +445,8 @@ gen_revoke( const char *uname )
      * it's used all over the source */
     sk = node->pkt->pkt.secret_key;
     keyid_from_sk( sk, sk_keyid );
-    tty_printf("\nsec  %4u%c/%08lX %s   ",
-             nbits_from_sk( sk ),
-             pubkey_letter( sk->pubkey_algo ),
-             (ulong)sk_keyid[1], datestr_from_sk(sk) );
-    {
-       size_t n;
-       char *p = get_user_id( sk_keyid, &n );
-       tty_print_utf8_string( p, n );
-       m_free(p);
-       tty_printf("\n");
-    }
+    print_seckey_info (sk);
+
     pk = m_alloc_clear( sizeof *pk );
 
     /* FIXME: We should get the public key direct from the secret one */