diff options
author | Werner Koch <[email protected]> | 2018-05-13 11:29:40 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2018-05-13 11:29:40 +0000 |
commit | 7b7576637ddfb6e426e77a86b05af6d828e585d5 (patch) | |
tree | 21919eed435194f8db1dac8150b581a731a66e26 /g10/mainproc.c | |
parent | doc: Include release info from 2.2.6 (diff) | |
parent | doc: Fix URL in NEWS. (diff) | |
download | gnupg-7b7576637ddfb6e426e77a86b05af6d828e585d5.tar.gz gnupg-7b7576637ddfb6e426e77a86b05af6d828e585d5.zip |
Merge branch 'STABLE-BRANCH-2-2' into master
--
Resolved Conflicts:
NEWS - removed
configure.ac - removed
Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to 'g10/mainproc.c')
-rw-r--r-- | g10/mainproc.c | 63 |
1 files changed, 42 insertions, 21 deletions
diff --git a/g10/mainproc.c b/g10/mainproc.c index 1af89c501..69de865e7 100644 --- a/g10/mainproc.c +++ b/g10/mainproc.c @@ -1307,7 +1307,7 @@ list_node (CTX c, kbnode_t node) } else if (!opt.fast_list_mode) { - p = get_user_id (c->ctrl, sig->keyid, &n); + p = get_user_id (c->ctrl, sig->keyid, &n, NULL); es_write_sanitized (es_stdout, p, n, opt.with_colons?":":NULL, NULL ); xfree (p); @@ -1710,21 +1710,40 @@ akl_has_wkd_method (void) } -/* Return the ISSUER fingerprint string in human readbale format if - * available. Caller must release the string. */ -static char * -issuer_fpr_string (PKT_signature *sig) +/* Return the ISSUER fingerprint buffer and its lenbgth at R_LEN. + * Returns NULL if not available. The returned buffer is valid as + * long as SIG is not modified. */ +static const byte * +issuer_fpr_raw (PKT_signature *sig, size_t *r_len) { const byte *p; size_t n; p = parse_sig_subpkt (sig->hashed, SIGSUBPKT_ISSUER_FPR, &n); if (p && n == 21 && p[0] == 4) - return bin2hex (p+1, n-1, NULL); + { + *r_len = n - 1; + return p+1; + } + *r_len = 0; return NULL; } +/* Return the ISSUER fingerprint string in human readbale format if + * available. Caller must release the string. */ +/* FIXME: Move to another file. */ +char * +issuer_fpr_string (PKT_signature *sig) +{ + const byte *p; + size_t n; + + p = issuer_fpr_raw (sig, &n); + return p? bin2hex (p, n, NULL) : NULL; +} + + static void print_good_bad_signature (int statno, const char *keyid_str, kbnode_t un, PKT_signature *sig, int rc) @@ -1761,7 +1780,7 @@ check_sig_and_print (CTX c, kbnode_t node) int rc; int is_expkey = 0; int is_revkey = 0; - char *issuer_fpr; + char *issuer_fpr = NULL; PKT_public_key *pk = NULL; /* The public key for the signature or NULL. */ int tried_ks_by_fpr; @@ -1888,13 +1907,14 @@ check_sig_and_print (CTX c, kbnode_t node) write_status_text (STATUS_NEWSIG, NULL); astr = openpgp_pk_algo_name ( sig->pubkey_algo ); - if ((issuer_fpr = issuer_fpr_string (sig))) + issuer_fpr = issuer_fpr_string (sig); + + if (issuer_fpr) { log_info (_("Signature made %s\n"), asctimestamp(sig->timestamp)); log_info (_(" using %s key %s\n"), astr? astr: "?", issuer_fpr); - xfree (issuer_fpr); } else if (!keystrlen () || keystrlen () > 8) { @@ -2001,14 +2021,14 @@ check_sig_and_print (CTX c, kbnode_t node) const byte *p; size_t n; - p = parse_sig_subpkt (sig->hashed, SIGSUBPKT_ISSUER_FPR, &n); - if (p && n == 21 && p[0] == 4) + p = issuer_fpr_raw (sig, &n); + if (p) { /* v4 packet with a SHA-1 fingerprint. */ free_public_key (pk); pk = NULL; glo_ctrl.in_auto_key_retrieve++; - res = keyserver_import_fprint (c->ctrl, p+1, n-1, opt.keyserver, 1); + res = keyserver_import_fprint (c->ctrl, p, n, opt.keyserver, 1); tried_ks_by_fpr = 1; glo_ctrl.in_auto_key_retrieve--; if (!res) @@ -2375,22 +2395,23 @@ check_sig_and_print (CTX c, kbnode_t node) } else { - char buf[50]; - - snprintf (buf, sizeof buf, "%08lX%08lX %d %d %02x %lu %d", - (ulong)sig->keyid[0], (ulong)sig->keyid[1], - sig->pubkey_algo, sig->digest_algo, - sig->sig_class, (ulong)sig->timestamp, gpg_err_code (rc)); - write_status_text (STATUS_ERRSIG, buf); + write_status_printf (STATUS_ERRSIG, "%08lX%08lX %d %d %02x %lu %d %s", + (ulong)sig->keyid[0], (ulong)sig->keyid[1], + sig->pubkey_algo, sig->digest_algo, + sig->sig_class, (ulong)sig->timestamp, + gpg_err_code (rc), + issuer_fpr? issuer_fpr:"-"); if (gpg_err_code (rc) == GPG_ERR_NO_PUBKEY) { - buf[16] = 0; - write_status_text (STATUS_NO_PUBKEY, buf); + write_status_printf (STATUS_NO_PUBKEY, "%08lX%08lX", + (ulong)sig->keyid[0], (ulong)sig->keyid[1]); } if (gpg_err_code (rc) != GPG_ERR_NOT_PROCESSED) log_error (_("Can't check signature: %s\n"), gpg_strerror (rc)); } + free_public_key (pk); + xfree (issuer_fpr); return rc; } |