aboutsummaryrefslogtreecommitdiffstats
path: root/tests/run-verify.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2016-05-21 08:29:49 +0000
committerWerner Koch <[email protected]>2016-05-21 08:32:51 +0000
commit10df06ee8f9192309bf124872438f7c32457e1c6 (patch)
treefa06a7511fea47cf784f9ac0e003bf04ecb0c27c /tests/run-verify.c
parentapi: Add new context flag "raw-description". (diff)
downloadgpgme-10df06ee8f9192309bf124872438f7c32457e1c6.tar.gz
gpgme-10df06ee8f9192309bf124872438f7c32457e1c6.zip
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 <[email protected]>
Diffstat (limited to 'tests/run-verify.c')
-rw-r--r--tests/run-verify.c39
1 files changed, 39 insertions, 0 deletions
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
@@ -94,9 +94,23 @@ 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)