From 26fabc31e3487f4ae902cbf66c381de01ac2eb5b Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Tue, 8 Apr 2003 08:42:47 +0000 Subject: [PATCH] Add primary key fingerprint to VALIDSIG status. --- NEWS | 2 ++ doc/ChangeLog | 4 ++++ doc/DETAILS | 5 ++++- g10/ChangeLog | 5 +++++ g10/mainproc.c | 36 ++++++++++++++++++++++++++++-------- 5 files changed, 43 insertions(+), 9 deletions(-) diff --git a/NEWS b/NEWS index c0d14ecd5..b681cc4ab 100644 --- a/NEWS +++ b/NEWS @@ -50,6 +50,8 @@ Noteworthy changes in version 1.3.2 (unreleased) This is a simpler interface to the old method (which still works) of revoking the user ID self-signature. + * Status VALIDSIG does now also print the primary key's fngerprint. + * Add read-only support for the SHA-256 hash, and optional read-only support for the SHA-384 and SHA-512 hashes. diff --git a/doc/ChangeLog b/doc/ChangeLog index 027410926..8a8b1aee4 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -12,6 +12,10 @@ * Makefile.am: Allow CVS version to build without faqprog.pl. +2003-04-01 Werner Koch + + * DETAILS (VALIDSIG): Add primary keys fingerprint. + 2003-01-27 David Shaw * DETAILS: Document trust depth, value, and regexp. diff --git a/doc/DETAILS b/doc/DETAILS index 8da2a0a5f..b5bca781b 100644 --- a/doc/DETAILS +++ b/doc/DETAILS @@ -164,7 +164,7 @@ more arguments in future versions. this signature. sig_class is a 2 byte hex-value. VALIDSIG - + The signature with the keyid is good. This is the same as GOODSIG but has the fingerprint as the argument. Both @@ -172,6 +172,9 @@ more arguments in future versions. sig-timestamp is the signature creation time in seconds after the epoch. expire-timestamp is the signature expiration time in seconds after the epoch (zero means "does not expire"). + PRIMARY-KEY-FPR is the fingerprint of the primary key or + identical to the first argument. This is useful to get back + to the primary key without running gpg again for this purpose. SIG_ID This is emitted only for signatures of class 0 or 1 which diff --git a/g10/ChangeLog b/g10/ChangeLog index ffcd6805a..561125a04 100644 --- a/g10/ChangeLog +++ b/g10/ChangeLog @@ -5,6 +5,11 @@ * sign.c (sign_file, clearsign_file, sign_symencrypt_file): Remove unused code. +2003-04-01 Werner Koch + + * mainproc.c (check_sig_and_print): Add primary key fpr to VALIDSIG + status. + 2003-03-24 David Shaw * keydb.h: Err on the side of making an unknown signature a SIG diff --git a/g10/mainproc.c b/g10/mainproc.c index 978ee9de8..97af59591 100644 --- a/g10/mainproc.c +++ b/g10/mainproc.c @@ -1,5 +1,5 @@ /* mainproc.c - handle packets - * Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. + * Copyright (C) 1998,1999,2000,2001,2002,2003 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -1452,17 +1452,37 @@ check_sig_and_print( CTX c, KBNODE node ) if( !get_pubkey( pk, sig->keyid ) ) { byte array[MAX_FINGERPRINT_LEN], *p; - char buf[MAX_FINGERPRINT_LEN*2+72]; + char buf[MAX_FINGERPRINT_LEN*4+73], *bufp; size_t i, n; + bufp = buf; fingerprint_from_pk( pk, array, &n ); p = array; - for(i=0; i < n ; i++, p++ ) - sprintf(buf+2*i, "%02X", *p ); - sprintf(buf+strlen(buf), " %s %lu %lu", - strtimestamp( sig->timestamp ), - (ulong)sig->timestamp, - (ulong)sig->expiredate ); + for(i=0; i < n ; i++, p++, bufp += 2) + sprintf(bufp, "%02X", *p ); + sprintf(bufp, " %s %lu %lu ", + strtimestamp( sig->timestamp ), + (ulong)sig->timestamp, + (ulong)sig->expiredate ); + bufp = bufp + strlen (bufp); + if (!pk->is_primary) { + u32 akid[2]; + + akid[0] = pk->main_keyid[0]; + akid[1] = pk->main_keyid[1]; + free_public_key (pk); + pk = m_alloc_clear( sizeof *pk ); + if (get_pubkey (pk, akid)) { + /* impossible error, we simply return a zeroed out fpr */ + n = MAX_FINGERPRINT_LEN < 20? MAX_FINGERPRINT_LEN : 20; + memset (array, 0, n); + } + else + fingerprint_from_pk( pk, array, &n ); + } + p = array; + for(i=0; i < n ; i++, p++, bufp += 2) + sprintf(bufp, "%02X", *p ); write_status_text( STATUS_VALIDSIG, buf ); } free_public_key( pk );