1
0
mirror of git://git.gnupg.org/gnupg.git synced 2025-04-17 15:44:34 +02:00

* trustdb.c (mark_usable_uid_certs): Properly handle nonrevocable

signatures that can expire.  In short, the only thing that can override an
unexpired nonrevocable signature is another unexpired nonrevocable
signature.

* getkey.c (finish_lookup): Always use primary signing key for signatures
when --pgp6 is on since pgp6 and 7 do not understand signatures made by
signing subkeys.
This commit is contained in:
David Shaw 2002-04-18 18:23:22 +00:00
parent 37c268ed6a
commit c07113d265
3 changed files with 59 additions and 21 deletions

View File

@ -1,3 +1,14 @@
2002-04-18 David Shaw <dshaw@jabberwocky.com>
* trustdb.c (mark_usable_uid_certs): Properly handle nonrevocable
signatures that can expire. In short, the only thing that can
override an unexpired nonrevocable signature is another unexpired
nonrevocable signature.
* getkey.c (finish_lookup): Always use primary signing key for
signatures when --pgp6 is on since pgp6 and 7 do not understand
signatures made by signing subkeys.
2002-04-18 Werner Koch <wk@gnupg.org> 2002-04-18 Werner Koch <wk@gnupg.org>
* trustdb.c (validate_keys): Never schedule a nextcheck into the * trustdb.c (validate_keys): Never schedule a nextcheck into the

View File

@ -1826,7 +1826,10 @@ finish_lookup (GETKEY_CTX ctx)
PKT_user_id *foundu = NULL; PKT_user_id *foundu = NULL;
#define USAGE_MASK (PUBKEY_USAGE_SIG|PUBKEY_USAGE_ENC) #define USAGE_MASK (PUBKEY_USAGE_SIG|PUBKEY_USAGE_ENC)
unsigned int req_usage = ( ctx->req_usage & USAGE_MASK ); unsigned int req_usage = ( ctx->req_usage & USAGE_MASK );
int req_cert = (ctx->req_usage & PUBKEY_USAGE_CERT); /* Request the primary if we're certifying another key, and also
if --pgp6 is on (since pgp 6 (and 7) do not understand
signatures made by a signing subkey. */
int req_prim = (ctx->req_usage & PUBKEY_USAGE_CERT) | opt.pgp6;
u32 latest_date; u32 latest_date;
KBNODE latest_key; KBNODE latest_key;
u32 curtime = make_timestamp (); u32 curtime = make_timestamp ();
@ -1877,7 +1880,7 @@ finish_lookup (GETKEY_CTX ctx)
latest_date = 0; latest_date = 0;
latest_key = NULL; latest_key = NULL;
/* do not look at subkeys if a certification key is requested */ /* do not look at subkeys if a certification key is requested */
if ((!foundk || foundk->pkt->pkttype == PKT_PUBLIC_SUBKEY) && !req_cert) { if ((!foundk || foundk->pkt->pkttype == PKT_PUBLIC_SUBKEY) && !req_prim) {
KBNODE nextk; KBNODE nextk;
/* either start a loop or check just this one subkey */ /* either start a loop or check just this one subkey */
for (k=foundk?foundk:keyblock; k; k = nextk ) { for (k=foundk?foundk:keyblock; k; k = nextk ) {
@ -1930,9 +1933,9 @@ finish_lookup (GETKEY_CTX ctx)
/* Okay now try the primary key unless we want an exact /* Okay now try the primary key unless we want an exact
* key ID match on a subkey */ * key ID match on a subkey */
if ((!latest_key && !(ctx->exact && foundk != keyblock)) || req_cert) { if ((!latest_key && !(ctx->exact && foundk != keyblock)) || req_prim) {
PKT_public_key *pk; PKT_public_key *pk;
if (DBG_CACHE && !foundk && !req_cert ) if (DBG_CACHE && !foundk && !req_prim )
log_debug( "\tno suitable subkeys found - trying primary\n"); log_debug( "\tno suitable subkeys found - trying primary\n");
pk = keyblock->pkt->pkt.public_key; pk = keyblock->pkt->pkt.public_key;
if ( !pk->is_valid ) { if ( !pk->is_valid ) {

View File

@ -1057,26 +1057,50 @@ mark_usable_uid_certs (KBNODE keyblock, KBNODE uidnode,
continue; continue;
n->flag |= (1<<10); /* mark this node as processed */ n->flag |= (1<<10); /* mark this node as processed */
/* If the current signode is a nonrevocable signature, and /* If signode is nonrevocable and unexpired and n isn't,
we're checking a revocation, then skip. Note that this then take signode (skip). It doesn't matter which is
will let more recent signatures replace the nonrevocable older: if signode was older then we don't want to take n
signature. Is that the proper behavior? */ as signode is nonrevocable. If n was older then we're
automatically fine. */
if(IS_UID_REV(n->pkt->pkt.signature) &&
IS_UID_SIG(signode->pkt->pkt.signature) && if(((IS_UID_SIG(signode->pkt->pkt.signature) &&
!signode->pkt->pkt.signature->flags.revocable) !signode->pkt->pkt.signature->flags.revocable &&
(signode->pkt->pkt.signature->expiredate==0 ||
signode->pkt->pkt.signature->expiredate>curtime))) &&
(!(IS_UID_SIG(n->pkt->pkt.signature) &&
!n->pkt->pkt.signature->flags.revocable &&
(n->pkt->pkt.signature->expiredate==0 ||
n->pkt->pkt.signature->expiredate>curtime))))
continue; continue;
/* A nonrevocable signature n should always replace a /* If n is nonrevocable and unexpired and signode isn't,
revocation in signode. If n is newer, then there is no then take n. Again, it doesn't matter which is older: if
question. If n is older, then it should still replace n was older then we don't want to take signode as n is
signode as the revocation in signode is invalid because n nonrevocable. If signode was older then we're
is nonrevocable. */ automatically fine. */
if((!(IS_UID_SIG(signode->pkt->pkt.signature) &&
!signode->pkt->pkt.signature->flags.revocable &&
(signode->pkt->pkt.signature->expiredate==0 ||
signode->pkt->pkt.signature->expiredate>curtime))) &&
((IS_UID_SIG(n->pkt->pkt.signature) &&
!n->pkt->pkt.signature->flags.revocable &&
(n->pkt->pkt.signature->expiredate==0 ||
n->pkt->pkt.signature->expiredate>curtime))))
{
signode = n;
sigdate = sig->timestamp;
continue;
}
if ((sig->timestamp >= sigdate) || /* At this point, if it's newer, it goes in as the only
(IS_UID_REV(signode->pkt->pkt.signature) && remaining possibilities are signode and n are both either
IS_UID_SIG(n->pkt->pkt.signature) && revocable or expired or both nonrevocable and unexpired.
!n->pkt->pkt.signature->flags.revocable)) If the timestamps are equal take the later ordered
packet, presuming that the key packets are hopefully in
their original order. */
if (sig->timestamp >= sigdate)
{ {
signode = n; signode = n;
sigdate = sig->timestamp; sigdate = sig->timestamp;