From 120b14783c0312d782dc08ce4949a6209d5ccc7b Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Wed, 7 Sep 2016 09:26:11 +0200 Subject: core,cpp: Extend the TOFU information. * src/gpgme.h.in (struct _gpeme_tofu_info): Rename FIRSTSEEN to SIGNFIRST and LASTSEEN to SIGNLAST. Add ENCRFIST and ENCRLAST. * src/keylist.c (parse_tfs_record): Parse to ENCRFIRST and ENCRLAST. * src/verify.c (parse_tofu_stats): Ditto. * tests/run-keylist.c (main): Adjust and print encrypt stats. * tests/run-verify.c (print_result): Ditto. * lang/cpp/src/tofuinfo.h (TofuInfo): Rename firstSeen to signFirst and lastSeen to signLast. Add encrCount, encrFirst and encrLast. * lang/cpp/src/tofuinfo.cpp (encrCount, encrFirst, encrLast): New. -- The latest GnuPG commits have the needed changes but we also allow the use of currently released GnuPG version. Signed-off-by: Werner Koch --- src/verify.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'src/verify.c') diff --git a/src/verify.c b/src/verify.c index 92eb3334..5ac937d9 100644 --- a/src/verify.c +++ b/src/verify.c @@ -755,20 +755,21 @@ parse_tofu_user (gpgme_signature_t sig, char *args, gpgme_protocol_t protocol) /* Parse a TOFU_STATS line and store it in the last tofu info of SIG. * - * TOFU_STATS [ [ ]] + * TOFU_STATS \ + * [ [ ]] */ static gpgme_error_t parse_tofu_stats (gpgme_signature_t sig, char *args) { gpgme_error_t err; gpgme_tofu_info_t ti; - char *field[6]; + char *field[8]; int nfields; unsigned long uval; if (!sig->key || !sig->key->_last_uid || !(ti = sig->key->_last_uid->tofu)) return trace_gpg_error (GPG_ERR_INV_ENGINE); /* No TOFU_USER seen. */ - if (ti->firstseen || ti->signcount || ti->validity || ti->policy) + if (ti->signfirst || ti->signcount || ti->validity || ti->policy) return trace_gpg_error (GPG_ERR_INV_ENGINE); /* Already set. */ nfields = _gpgme_split_fields (args, field, DIM (field)); @@ -824,11 +825,24 @@ parse_tofu_stats (gpgme_signature_t sig, char *args) err = _gpgme_strtoul_field (field[4], &uval); if (err) return trace_gpg_error (GPG_ERR_INV_ENGINE); - ti->firstseen = uval; + ti->signfirst = uval; err = _gpgme_strtoul_field (field[5], &uval); if (err) return trace_gpg_error (GPG_ERR_INV_ENGINE); - ti->lastseen = uval; + ti->signlast = uval; + if (nfields > 7) + { + /* This condition is only to allow for gpg 2.1.15 - can + * eventually be removed. */ + err = _gpgme_strtoul_field (field[6], &uval); + if (err) + return trace_gpg_error (GPG_ERR_INV_ENGINE); + ti->encrfirst = uval; + err = _gpgme_strtoul_field (field[7], &uval); + if (err) + return trace_gpg_error (GPG_ERR_INV_ENGINE); + ti->encrlast = uval; + } return 0; } -- cgit v1.2.3