From 9f839ac9371db0253466dc5bea51471ba0b4a1c4 Mon Sep 17 00:00:00 2001 From: David Shaw Date: Mon, 21 Jul 2003 14:55:00 +0000 Subject: [PATCH] * sig-check.c (signature_check, signature_check2, check_key_signature, check_key_signature2): Allow passing NULLs for unused parameters in the x2 form of each function to avoid the need for dummy variables. getkey.c, mainproc.c: Change all callers. --- g10/ChangeLog | 8 ++++++++ g10/getkey.c | 4 +--- g10/mainproc.c | 5 ++--- g10/sig-check.c | 26 +++++++++++++------------- 4 files changed, 24 insertions(+), 19 deletions(-) diff --git a/g10/ChangeLog b/g10/ChangeLog index 8e7626609..4760dd138 100644 --- a/g10/ChangeLog +++ b/g10/ChangeLog @@ -1,3 +1,11 @@ +2003-07-21 David Shaw + + * sig-check.c (signature_check, signature_check2, + check_key_signature, check_key_signature2): Allow passing NULLs + for unused parameters in the x2 form of each function to avoid the + need for dummy variables. getkey.c, mainproc.c: Change all + callers. + 2003-07-15 David Shaw * keygen.c (do_add_key_flags): Don't set the certify flag for diff --git a/g10/getkey.c b/g10/getkey.c index cebaa4c5a..d8516c689 100644 --- a/g10/getkey.c +++ b/g10/getkey.c @@ -1595,8 +1595,6 @@ merge_selfsigs_main( KBNODE keyblock, int *r_revoked ) else if ( k->pkt->pkttype == PKT_SIGNATURE && uidnode ) { PKT_signature *sig = k->pkt->pkt.signature; - u32 dummy; - int dum2; if(sig->keyid[0] != kid[0] || sig->keyid[1]!=kid[1]) { @@ -1606,7 +1604,7 @@ merge_selfsigs_main( KBNODE keyblock, int *r_revoked ) if(get_pubkey_fast(ultimate_pk,sig->keyid)==0 && check_key_signature2(keyblock,k,ultimate_pk, - NULL,&dummy,&dum2)==0 + NULL,NULL,NULL)==0 && get_ownertrust(ultimate_pk)==TRUST_ULTIMATE) { free_public_key(ultimate_pk); diff --git a/g10/mainproc.c b/g10/mainproc.c index 5241fa551..67ec159b6 100644 --- a/g10/mainproc.c +++ b/g10/mainproc.c @@ -665,7 +665,6 @@ do_check_sig( CTX c, KBNODE node, int *is_selfsig, int *is_expkey ) PKT_signature *sig; MD_HANDLE md = NULL, md2 = NULL; int algo, rc, dum2; - u32 dummy; if(!is_expkey) is_expkey=&dum2; @@ -722,9 +721,9 @@ do_check_sig( CTX c, KBNODE node, int *is_selfsig, int *is_expkey ) } else return G10ERR_SIG_CLASS; - rc = signature_check2( sig, md, &dummy, is_expkey ); + rc = signature_check2( sig, md, NULL, is_expkey ); if( rc == G10ERR_BAD_SIGN && md2 ) - rc = signature_check2( sig, md2, &dummy, is_expkey ); + rc = signature_check2( sig, md2, NULL, is_expkey ); md_close(md); md_close(md2); diff --git a/g10/sig-check.c b/g10/sig-check.c index 8385f5cbf..0af51a826 100644 --- a/g10/sig-check.c +++ b/g10/sig-check.c @@ -50,9 +50,7 @@ static int do_check( PKT_public_key *pk, PKT_signature *sig, int signature_check( PKT_signature *sig, MD_HANDLE digest ) { - u32 dummy; - int dum2; - return signature_check2( sig, digest, &dummy, &dum2 ); + return signature_check2( sig, digest, NULL, NULL ); } int @@ -62,8 +60,6 @@ signature_check2( PKT_signature *sig, MD_HANDLE digest, PKT_public_key *pk = m_alloc_clear( sizeof *pk ); int rc=0; - *r_expiredate = 0; - /* Sanity check that the md has a context for the hash that the sig is expecting. This can happen if a onepass sig header does not match the actual sig, and also if the clearsign "Hash:" @@ -79,7 +75,8 @@ signature_check2( PKT_signature *sig, MD_HANDLE digest, rc=G10ERR_BAD_PUBKEY; /* you cannot have a good sig from an invalid subkey */ else { - *r_expiredate = pk->expiredate; + if(r_expiredate) + *r_expiredate = pk->expiredate; rc = do_check( pk, sig, digest, r_expired ); } @@ -208,7 +205,8 @@ do_check_messages( PKT_public_key *pk, PKT_signature *sig, int *r_expired ) { u32 cur_time; - *r_expired = 0; + if(r_expired) + *r_expired = 0; if( pk->version == 4 && pk->pubkey_algo == PUBKEY_ALGO_ELGAMAL_E ) { log_info(_("key %08lX: this is a PGP generated " "ElGamal key which is NOT secure for signatures!\n"), @@ -251,7 +249,8 @@ do_check_messages( PKT_public_key *pk, PKT_signature *sig, int *r_expired ) sprintf(buf,"%lu",(ulong)pk->expiredate); write_status_text(STATUS_KEYEXPIRED,buf); write_status(STATUS_SIGEXPIRED); - *r_expired = 1; + if(r_expired) + *r_expired = 1; } return 0; @@ -473,9 +472,7 @@ check_revocation_keys(PKT_public_key *pk,PKT_signature *sig) int check_key_signature( KBNODE root, KBNODE node, int *is_selfsig ) { - u32 dummy; - int dum2; - return check_key_signature2(root, node, NULL, is_selfsig, &dummy, &dum2 ); + return check_key_signature2(root, node, NULL, is_selfsig, NULL, NULL ); } /* If check_pk is set, then use it to check the signature in node @@ -492,8 +489,10 @@ check_key_signature2( KBNODE root, KBNODE node, PKT_public_key *check_pk, if( is_selfsig ) *is_selfsig = 0; - *r_expiredate = 0; - *r_expired = 0; + if( r_expiredate ) + *r_expiredate = 0; + if( r_expired ) + *r_expired = 0; assert( node->pkt->pkttype == PKT_SIGNATURE ); assert( root->pkt->pkttype == PKT_PUBLIC_KEY ); @@ -511,6 +510,7 @@ check_key_signature2( KBNODE root, KBNODE node, PKT_public_key *check_pk, if( keyid[0] == sig->keyid[0] && keyid[1] == sig->keyid[1] ) *is_selfsig = 1; } + /* TODO: should set r_expiredate here as well */ if((rc=do_check_messages(pk,sig,r_expired))) return rc; return sig->flags.valid? 0 : G10ERR_BAD_SIGN;