From b37facc5939cf7bd262c543aad9008d6147ea128 Mon Sep 17 00:00:00 2001 From: David Shaw Date: Thu, 30 Dec 2004 03:26:57 +0000 Subject: [PATCH] * packet.h, getkey.c (merge_selfsigs_main, sig_to_revoke_info), keyid.c (revokestr_from_pk), keyedit.c (show_key_with_all_names): Show who revoked a key (either the same key or a designated revoker) and when. --- g10/ChangeLog | 7 +++++++ g10/getkey.c | 26 ++++++++++++++++++-------- g10/keyedit.c | 9 +++++++++ g10/keyid.c | 4 ++-- g10/packet.h | 11 ++++++++++- 5 files changed, 46 insertions(+), 11 deletions(-) diff --git a/g10/ChangeLog b/g10/ChangeLog index 0a3473b1a..b6ba5462e 100644 --- a/g10/ChangeLog +++ b/g10/ChangeLog @@ -1,3 +1,10 @@ +2004-12-29 David Shaw + + * packet.h, getkey.c (merge_selfsigs_main, sig_to_revoke_info), + keyid.c (revokestr_from_pk), keyedit.c (show_key_with_all_names): + Show who revoked a key (either the same key or a designated + revoker) and when. + 2004-12-28 Werner Koch * ccid-driver.c (find_endpoint): New. diff --git a/g10/getkey.c b/g10/getkey.c index 86c1cfba2..9cc0cbb7d 100644 --- a/g10/getkey.c +++ b/g10/getkey.c @@ -1387,7 +1387,16 @@ fixup_uidnode ( KBNODE uidnode, KBNODE signode, u32 keycreated ) } static void -merge_selfsigs_main( KBNODE keyblock, int *r_revoked, u32 *r_revokedate ) +sig_to_revoke_info(PKT_signature *sig,struct revoke_info *rinfo) +{ + rinfo->date = sig->timestamp; + rinfo->algo = sig->pubkey_algo; + rinfo->keyid[0] = sig->keyid[0]; + rinfo->keyid[1] = sig->keyid[1]; +} + +static void +merge_selfsigs_main(KBNODE keyblock, int *r_revoked, struct revoke_info *rinfo) { PKT_public_key *pk = NULL; KBNODE k; @@ -1402,7 +1411,8 @@ merge_selfsigs_main( KBNODE keyblock, int *r_revoked, u32 *r_revokedate ) byte sigversion = 0; *r_revoked = 0; - *r_revokedate = 0; + memset(rinfo,0,sizeof(*rinfo)); + if ( keyblock->pkt->pkttype != PKT_PUBLIC_KEY ) BUG (); pk = keyblock->pkt->pkt.public_key; @@ -1448,7 +1458,7 @@ merge_selfsigs_main( KBNODE keyblock, int *r_revoked, u32 *r_revokedate ) * that key. */ *r_revoked = 1; - *r_revokedate = sig->timestamp; + sig_to_revoke_info(sig,rinfo); } else if ( IS_KEY_SIG (sig) ) { /* Add any revocation keys onto the pk. This is @@ -1558,7 +1568,7 @@ merge_selfsigs_main( KBNODE keyblock, int *r_revoked, u32 *r_revokedate ) if(rc==0) { *r_revoked=2; - *r_revokedate=sig->timestamp; + sig_to_revoke_info(sig,rinfo); /* don't continue checking since we can't be any more revoked than this */ break; @@ -1894,7 +1904,7 @@ merge_selfsigs_subkey( KBNODE keyblock, KBNODE subnode ) problem is in the distribution. Plus, PGP (7) does this the same way. */ subpk->is_revoked = 1; - subpk->revokedate = sig->timestamp; + sig_to_revoke_info(sig,&subpk->revoked); /* although we could stop now, we continue to * figure out other information like the old expiration * time */ @@ -2011,7 +2021,7 @@ merge_selfsigs( KBNODE keyblock ) { KBNODE k; int revoked; - u32 revokedate; + struct revoke_info rinfo; PKT_public_key *main_pk; prefitem_t *prefs; int mdc_feature; @@ -2028,7 +2038,7 @@ merge_selfsigs( KBNODE keyblock ) BUG (); } - merge_selfsigs_main ( keyblock, &revoked, &revokedate ); + merge_selfsigs_main ( keyblock, &revoked, &rinfo ); /* now merge in the data from each of the subkeys */ for(k=keyblock; k; k = k->next ) { @@ -2051,7 +2061,7 @@ merge_selfsigs( KBNODE keyblock ) if(revoked && !pk->is_revoked) { pk->is_revoked = revoked; - pk->revokedate = revokedate; + memcpy(&pk->revoked,&rinfo,sizeof(rinfo)); } if(main_pk->has_expired) pk->has_expired = main_pk->has_expired; diff --git a/g10/keyedit.c b/g10/keyedit.c index 28e153f1f..badac86c9 100644 --- a/g10/keyedit.c +++ b/g10/keyedit.c @@ -2317,6 +2317,15 @@ show_key_with_all_names( KBNODE keyblock, int only_marked, int with_revoker, primary=pk; } + if(pk->is_revoked) + { + char *user=get_user_id_string_native(pk->revoked.keyid); + const char *algo=pubkey_algo_to_string(pk->revoked.algo); + tty_printf(_("This key was revoked on %s by %s key %s\n"), + revokestr_from_pk(pk),algo?algo:"?",user); + m_free(user); + } + if(with_revoker) { if( !pk->revkey && pk->numrevkeys ) diff --git a/g10/keyid.c b/g10/keyid.c index 9c5138605..25d51e3b8 100644 --- a/g10/keyid.c +++ b/g10/keyid.c @@ -529,9 +529,9 @@ revokestr_from_pk( PKT_public_key *pk ) static char buffer[11+5]; time_t atime; - if(!pk->revokedate) + if(!pk->revoked.date) return _("never "); - atime=pk->revokedate; + atime=pk->revoked.date; return mk_datestr (buffer, atime); } diff --git a/g10/packet.h b/g10/packet.h index 0449c7d5f..549e8cc83 100644 --- a/g10/packet.h +++ b/g10/packet.h @@ -186,6 +186,15 @@ typedef struct { char name[1]; } PKT_user_id; +struct revoke_info +{ + /* revoked at this date */ + u32 date; + /* the keyid of the revoking key (selfsig or designated revoker) */ + u32 keyid[2]; + /* the algo of the revoking key */ + byte algo; +}; /**************** * Note about the pkey/skey elements: We assume that the secret keys @@ -197,7 +206,7 @@ typedef struct { u32 timestamp; /* key made */ u32 expiredate; /* expires at this date or 0 if not at all */ u32 max_expiredate; /* must not expire past this date */ - u32 revokedate; /* revoked at this date */ + struct revoke_info revoked; byte hdrbytes; /* number of header bytes */ byte version; byte selfsigversion; /* highest version of all of the self-sigs */