From 10df06ee8f9192309bf124872438f7c32457e1c6 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Sat, 21 May 2016 10:29:49 +0200 Subject: api: Return Tofu info for signatures. * src/gpgme.h.in (gpgme_tofu_policy_t): New. (gpgme_status_code_t): Add status codes for TOFU. (struct _gpgme_tofu_info, gpgme_tofu_info_t): New. (struct _gpgme_signature): Add field 'tofu'. * src/status-table.c (status_table): Add new codes. * src/verify.c: Include limits.h. (release_tofu_info): New. (release_op_data): Call that. (parse_tofu_user): New. (parse_tofu_stats): New. (parse_tofu_stats_long): New. (_gpgme_verify_status_handler): Handle TOFU status lines. * tests/run-verify.c (print_description): New. (print_result): print tofu info. Signed-off-by: Werner Koch --- tests/run-verify.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'tests/run-verify.c') diff --git a/tests/run-verify.c b/tests/run-verify.c index b7be3203..df8cbf65 100644 --- a/tests/run-verify.c +++ b/tests/run-verify.c @@ -93,10 +93,24 @@ print_validity (gpgme_validity_t val) } +static void +print_description (const char *text, int indent) +{ + for (; *text; text++) + { + putchar (*text); + if (*text == '\n') + printf ("%*s", indent, ""); + } + putchar ('\n'); +} + + static void print_result (gpgme_verify_result_t result) { gpgme_signature_t sig; + gpgme_tofu_info_t ti; int count = 0; printf ("Original file name: %s\n", nonnull(result->file_name)); @@ -126,6 +140,30 @@ print_result (gpgme_verify_result_t result) ); printf (" notations .: %s\n", sig->notations? "yes":"no"); + for (ti = sig->tofu; ti; ti = ti->next) + { + printf (" tofu addr .: %s\n", ti->address); + if (!sig->fpr || strcmp (sig->fpr, ti->fpr)) + printf (" WARNING .: fpr mismatch (%s)\n", ti->fpr); + printf (" validity : %u (%s)\n", ti->validity, + ti->validity == 0? "conflict" : + ti->validity == 1? "no history" : + ti->validity == 2? "little history" : + ti->validity == 3? "enough history" : + ti->validity == 4? "lot of history" : "?"); + printf (" policy ..: %u (%s)\n", ti->policy, + ti->policy == GPGME_TOFU_POLICY_NONE? "none" : + ti->policy == GPGME_TOFU_POLICY_AUTO? "auto" : + ti->policy == GPGME_TOFU_POLICY_GOOD? "good" : + ti->policy == GPGME_TOFU_POLICY_UNKNOWN? "unknown" : + ti->policy == GPGME_TOFU_POLICY_BAD? "bad" : + ti->policy == GPGME_TOFU_POLICY_ASK? "ask" : "?"); + printf (" sigcount : %hu\n", ti->signcount); + printf (" firstseen: %u\n", ti->firstseen); + printf (" lastseen : %u\n", ti->lastseen); + printf (" desc ....: "); + print_description (nonnull (ti->description), 15); + } } } @@ -230,6 +268,7 @@ main (int argc, char **argv) gpgme_set_status_cb (ctx, status_cb, NULL); gpgme_set_ctx_flag (ctx, "full-status", "1"); } + /* gpgme_set_ctx_flag (ctx, "raw-description", "1"); */ err = gpgme_data_new_from_stream (&sig, fp_sig); if (err) -- cgit v1.2.3