See ChangeLog: Wed Sep 15 16:22:17 CEST 1999 Werner Koch
[gnupg.git] / g10 / keylist.c
index a5456d5..91a13af 100644 (file)
@@ -132,7 +132,7 @@ list_one( STRLIST names, int secret )
        }
        do {
            merge_keys_and_selfsig( keyblock );
-           list_keyblock( keyblock, 0 );
+           list_keyblock( keyblock, 1 );
            release_kbnode( keyblock );
        } while( !get_seckey_next( ctx, NULL, &keyblock ) );
        get_seckey_end( ctx );
@@ -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],
@@ -196,7 +211,9 @@ list_keyblock( KBNODE keyblock, int secret )
        sk = NULL;
        keyid_from_pk( pk, keyid );
        if( opt.with_colons ) {
-           trustletter = query_trust_info( pk );
+           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 ),
@@ -222,19 +239,37 @@ list_keyblock( KBNODE keyblock, int secret )
     for( kbctx=NULL; (node=walk_kbnode( keyblock, &kbctx, 0)) ; ) {
        if( node->pkt->pkttype == PKT_USER_ID ) {
            if( any ) {
-               if( opt.with_colons )
-                   printf("uid:::::::::");
+               if( opt.with_colons ) {
+                   byte namehash[20];
+
+                   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 );
+                   }
+                   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;
            }
        }
@@ -275,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];
@@ -315,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 )
@@ -322,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);
@@ -367,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 )