See ChangeLog: Wed Sep 15 16:22:17 CEST 1999 Werner Koch
[gnupg.git] / g10 / keylist.c
index 1462dbb..91a13af 100644 (file)
@@ -152,6 +152,20 @@ list_one( STRLIST names, int secret )
     }
 }
 
+static void
+print_key_data( PKT_public_key *pk, u32 *keyid )
+{
+    int n = pubkey_get_npkey( pk->pubkey_algo );
+    int i;
+
+    for(i=0; i < n; i++ ) {
+       printf("pkd:%d:%u:", i, mpi_get_nbits( pk->pkey[i] ) );
+       mpi_print(stdout, pk->pkey[i], 1 );
+       putchar(':');
+       putchar('\n');
+    }
+}
+
 
 static void
 list_keyblock( KBNODE keyblock, int secret )
@@ -164,6 +178,7 @@ list_keyblock( KBNODE keyblock, int secret )
     u32 keyid[2];
     int any=0;
     int trustletter = 0;
+    int ulti_hack = 0;
 
     /* get the keyid from the keyblock */
     node = find_kbnode( keyblock, secret? PKT_SECRET_KEY : PKT_PUBLIC_KEY );
@@ -178,7 +193,7 @@ list_keyblock( KBNODE keyblock, int secret )
        sk = node->pkt->pkt.secret_key;
        keyid_from_sk( sk, keyid );
        if( opt.with_colons )
-           printf("sec::%u:%d:%08lX%08lX:%s:%s:::",
+           printf("sec:u:%u:%d:%08lX%08lX:%s:%s:::",
                    nbits_from_sk( sk ),
                    sk->pubkey_algo,
                    (ulong)keyid[0],(ulong)keyid[1],
@@ -197,6 +212,8 @@ list_keyblock( KBNODE keyblock, int secret )
        keyid_from_pk( pk, keyid );
        if( opt.with_colons ) {
            trustletter = query_trust_info( pk, NULL );
+           if( trustletter == 'u' )
+               ulti_hack = 1;
            printf("pub:%c:%u:%d:%08lX%08lX:%s:%s:",
                    trustletter,
                    nbits_from_pk( pk ),
@@ -225,23 +242,34 @@ list_keyblock( KBNODE keyblock, int secret )
                if( opt.with_colons ) {
                    byte namehash[20];
 
-                   rmd160_hash_buffer( namehash,
+                   if( pk && !ulti_hack ) {
+                       rmd160_hash_buffer( namehash,
                                        node->pkt->pkt.user_id->name,
                                        node->pkt->pkt.user_id->len  );
-                   trustletter = query_trust_info( pk, namehash );
+                       trustletter = query_trust_info( pk, namehash );
+                   }
+                   else
+                       trustletter = 'u';
                    printf("uid:%c::::::::", trustletter);
                }
                else
                    printf("uid%*s", 28, "");
            }
-           print_string( stdout,  node->pkt->pkt.user_id->name,
-                         node->pkt->pkt.user_id->len, opt.with_colons );
-           if( opt.with_colons )
+           if( opt.with_colons ) {
+               print_string( stdout,  node->pkt->pkt.user_id->name,
+                             node->pkt->pkt.user_id->len, ':' );
                putchar(':');
+           }
+           else
+               print_utf8_string( stdout,  node->pkt->pkt.user_id->name,
+                                  node->pkt->pkt.user_id->len );
+
            putchar('\n');
            if( !any ) {
                if( opt.fingerprint )
                    fingerprint( pk, sk );
+               if( opt.with_key_data )
+                   print_key_data( pk, keyid );
                any = 1;
            }
        }
@@ -282,6 +310,8 @@ list_keyblock( KBNODE keyblock, int secret )
                                           datestr_from_pk( pk2 ) );
            if( opt.fingerprint > 1 )
                fingerprint( pk2, NULL );
+           if( opt.with_key_data )
+               print_key_data( pk2, keyid2 );
        }
        else if( node->pkt->pkttype == PKT_SECRET_SUBKEY ) {
            u32 keyid2[2];
@@ -322,6 +352,8 @@ list_keyblock( KBNODE keyblock, int secret )
                    puts("[revoked]");
                else if( sig->sig_class == 0x18 )
                    puts("[key binding]");
+               else if( sig->sig_class == 0x28 )
+                   puts("[subkey revoked]");
                else
                    putchar('\n');
                if( opt.fingerprint )
@@ -329,7 +361,8 @@ list_keyblock( KBNODE keyblock, int secret )
                any=1;
            }
 
-           if( sig->sig_class == 0x20 || sig->sig_class == 0x30 )
+           if( sig->sig_class == 0x20 || sig->sig_class == 0x28
+                                      || sig->sig_class == 0x30 )
                fputs("rev", stdout);
            else if( (sig->sig_class&~3) == 0x10 )
                fputs("sig", stdout);
@@ -374,7 +407,10 @@ list_keyblock( KBNODE keyblock, int secret )
            else {
                size_t n;
                char *p = get_user_id( sig->keyid, &n );
-               print_string( stdout, p, n, opt.with_colons );
+               if( opt.with_colons )
+                   print_string( stdout, p, n, ':' );
+               else
+                   print_utf8_string( stdout, p, n );
                m_free(p);
            }
            if( opt.with_colons )