Inadvertently left out of the 2003-06-01 checkin
[gnupg.git] / g10 / mainproc.c
index d2acdea..ec812d7 100644 (file)
@@ -757,52 +757,6 @@ print_userid( PACKET *pkt )
 }
 
 
-static void
-print_notation_data( PKT_signature *sig )
-{
-    size_t n, n1, n2;
-    const byte *p;
-    int seq = 0;
-
-    while((p=enum_sig_subpkt(sig->hashed,SIGSUBPKT_NOTATION,&n,&seq,NULL))) {
-       if( n < 8 ) {
-           log_info(_("WARNING: invalid notation data found\n"));
-           return;
-       }
-       if( !(*p & 0x80) )
-           return; /* not human readable */
-       n1 = (p[4] << 8) | p[5];
-       n2 = (p[6] << 8) | p[7];
-       p += 8;
-       if( 8+n1+n2 != n ) {
-           log_info(_("WARNING: invalid notation data found\n"));
-           return;
-       }
-       log_info(_("Notation: ") );
-       print_string( log_stream(), p, n1, 0 );
-       putc( '=', log_stream() );
-       print_string( log_stream(), p+n1, n2, 0 );
-       putc( '\n', log_stream() );
-        write_status_buffer ( STATUS_NOTATION_NAME, p   , n1, 0 );
-        write_status_buffer ( STATUS_NOTATION_DATA, p+n1, n2, 50 );
-    }
-
-    seq=0;
-
-    while((p=enum_sig_subpkt(sig->hashed,SIGSUBPKT_POLICY,&n,&seq,NULL))) {
-       log_info(_("Policy: ") );
-       print_string( log_stream(), p, n, 0 );
-       putc( '\n', log_stream() );
-        write_status_buffer ( STATUS_POLICY_URL, p, n, 0 );
-    }
-
-    /* Now check whether the key of this signature has some
-     * notation data */
-
-    /* TODO */
-}
-
-
 /****************
  * List the certificate in a user friendly way
  */
@@ -1313,8 +1267,6 @@ check_sig_and_print( CTX c, KBNODE node )
             }
         }
     }
-    
-
 
     tstr = asctimestamp(sig->timestamp);
     astr = pubkey_algo_to_string( sig->pubkey_algo );
@@ -1431,9 +1383,14 @@ check_sig_and_print( CTX c, KBNODE node )
                     !un->pkt->pkt.user_id->attrib_data )
                    continue;
 
-               if(opt.show_photos && un->pkt->pkt.user_id->attrib_data)
-                 show_photos(un->pkt->pkt.user_id->attribs,
-                             un->pkt->pkt.user_id->numattribs,pk,NULL);
+               if(un->pkt->pkt.user_id->attrib_data)
+                 {
+                   dump_attribs(un->pkt->pkt.user_id,pk,NULL);
+
+                   if(opt.verify_options&VERIFY_SHOW_PHOTOS)
+                     show_photos(un->pkt->pkt.user_id->attribs,
+                                 un->pkt->pkt.user_id->numattribs,pk,NULL);
+                 }
 
                log_info(    _("                aka \""));
                 print_utf8_string( log_stream(), un->pkt->pkt.user_id->name,
@@ -1444,7 +1401,17 @@ check_sig_and_print( CTX c, KBNODE node )
        release_kbnode( keyblock );
 
        if( !rc )
-           print_notation_data( sig );
+         {
+           if(opt.verify_options&VERIFY_SHOW_POLICY)
+             show_policy_url(sig,0,1);
+           else
+             show_policy_url(sig,0,2);
+
+           if(opt.verify_options&VERIFY_SHOW_NOTATION)
+             show_notation(sig,0,1);
+           else
+             show_notation(sig,0,2);
+         }
 
        if( !rc && is_status_enabled() ) {
            /* print a status response with the fingerprint */
@@ -1622,6 +1589,30 @@ proc_tree( CTX c, KBNODE node )
     }
     else if( node->pkt->pkttype == PKT_SIGNATURE ) {
        PKT_signature *sig = node->pkt->pkt.signature;
+       int multiple_ok=1;
+
+       n1=find_next_kbnode(node, PKT_SIGNATURE);
+       if(n1)
+         {
+           byte class=sig->sig_class;
+           byte hash=sig->digest_algo;
+
+           for(; n1; (n1 = find_next_kbnode(n1, PKT_SIGNATURE)))
+             {
+               /* We can't currently handle multiple signatures of
+                  different classes or digests (we'd pretty much have
+                  to run a different hash context for each), but if
+                  they are all the same, make an exception. */
+               if(n1->pkt->pkt.signature->sig_class!=class
+                  || n1->pkt->pkt.signature->digest_algo!=hash)
+                 {
+                   multiple_ok=0;
+                   log_info(_("WARNING: multiple signatures detected.  "
+                              "Only the first will be checked.\n"));
+                   break;
+                 }
+             }
+         }
 
        if( sig->sig_class != 0x00 && sig->sig_class != 0x01 )
            log_info(_("standalone signature of class 0x%02x\n"),
@@ -1644,7 +1635,7 @@ proc_tree( CTX c, KBNODE node )
                 * signature has been created in textmode */
                c->mfx.md2 = md_open( sig->digest_algo, 0 );
            }
-         #if 0 /* workaround disabled */
+#if 0 /* workaround disabled */
            /* Here we have another hack to work around a pgp 2 bug
             * It works by not using the textmode for detached signatures;
             * this will let the first signature check (on md) fail
@@ -1653,7 +1644,7 @@ proc_tree( CTX c, KBNODE node )
             * hack but it may help in some cases (and break others)
             */
                    /*  c->mfx.md2? 0 :(sig->sig_class == 0x01) */
-         #endif
+#endif
             if ( DBG_HASHING ) {
                 md_start_debug( c->mfx.md, "verify" );
                 if ( c->mfx.md2  )
@@ -1683,8 +1674,11 @@ proc_tree( CTX c, KBNODE node )
        else if (!opt.quiet)
            log_info(_("old style (PGP 2.x) signature\n"));
 
-       for( n1 = node; n1; (n1 = find_next_kbnode(n1, PKT_SIGNATURE )) )
+       if(multiple_ok)
+         for( n1 = node; n1; (n1 = find_next_kbnode(n1, PKT_SIGNATURE )) )
            check_sig_and_print( c, n1 );
+       else
+         check_sig_and_print( c, node );
     }
     else {
         dump_kbnode (c->list);
@@ -1692,7 +1686,3 @@ proc_tree( CTX c, KBNODE node )
         dump_kbnode (node);
     }
 }
-
-
-
-