diff --git a/g10/ChangeLog b/g10/ChangeLog index fba2677f3..b707d49fb 100644 --- a/g10/ChangeLog +++ b/g10/ChangeLog @@ -1,3 +1,12 @@ +2003-07-04 David Shaw + + * misc.c (pct_expando): Minor performance tweak. Don't bother to + re-fetch the primary key if the key making the signature is the + primary key. + + * parse-packet.c (parse_signature): No need to reserve 8 bytes for + the unhashed signature cache any longer. + 2003-07-01 David Shaw * misc.c (pct_expando): Add two new expandos - signer's diff --git a/g10/misc.c b/g10/misc.c index 464697ddf..67ec5cc2b 100644 --- a/g10/misc.c +++ b/g10/misc.c @@ -391,16 +391,23 @@ pct_expando(const char *string,struct expando_args *args) size_t len; int i; - if((*(ch+1))=='p' && args->sk - && (args->sk->main_keyid[0] || args->sk->main_keyid[1])) + if((*(ch+1))=='p' && args->sk) { - PKT_public_key *pk=m_alloc_clear(sizeof(PKT_public_key)); + if(args->sk->is_primary) + fingerprint_from_sk(args->sk,array,&len); + else if(args->sk->main_keyid[0] || args->sk->main_keyid[1]) + { + PKT_public_key *pk= + m_alloc_clear(sizeof(PKT_public_key)); - if(get_pubkey_fast(pk,args->sk->main_keyid)==0) - fingerprint_from_pk(pk,array,&len); + if(get_pubkey_fast(pk,args->sk->main_keyid)==0) + fingerprint_from_pk(pk,array,&len); + else + memset(array,0,(len=MAX_FINGERPRINT_LEN)); + free_public_key(pk); + } else memset(array,0,(len=MAX_FINGERPRINT_LEN)); - free_public_key(pk); } else if((*(ch+1))=='f' && args->pk) fingerprint_from_pk(args->pk,array,&len); diff --git a/g10/parse-packet.c b/g10/parse-packet.c index 8e165ef25..f966eb31e 100644 --- a/g10/parse-packet.c +++ b/g10/parse-packet.c @@ -1238,11 +1238,8 @@ parse_signature( IOBUF inp, int pkttype, unsigned long pktlen, goto leave; } if( n ) { - /* we add 8 extra bytes so that we have space for the signature - * status cache. Well we are wastin this if there is a cache - * packet already, but in the other case it avoids an realloc */ - sig->unhashed = m_alloc (sizeof(*sig->unhashed) + n + 8 - 1 ); - sig->unhashed->size = n + 8; + sig->unhashed = m_alloc (sizeof(*sig->unhashed) + n - 1 ); + sig->unhashed->size = n; sig->unhashed->len = n; if( iobuf_read(inp, sig->unhashed->data, n ) != n ) { log_error("premature eof while reading "