From 108702ccae8ff1e5fec3b8e710f06a03637244c7 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Mon, 27 Aug 2018 16:57:04 +0200 Subject: gpg: Prepare for longer card fingerprints. * g10/call-agent.h (agent_card_info_s): Rename the "*valid" fields to "*len". * g10/call-agent.c (unhexify_fpr): Change to take a FPRLEN and to return the actual length. (agent_release_card_info): Adjust for these changes. * g10/card-util.c (print_sha1_fpr): Rename to print_shax_fpr and add arg FPRLEN. Change all callers to pass the length. (print_sha1_fpr_colon): Rename to print_shax_fpr_colon and add arg FPRLEN. Change all callers to pass the length. (fpr_is_zero): Add arg FPRLEN. (fpr_is_ff): Ditto. (show_card_key_info): Use the new functions. * g10/skclist.c (enum_secret_keys): Use MAX_FINGERPRINT_LEN. -- This is not needed right now but we should get rid of all hard coded fingerprint lengths. Thus this change. Signed-off-by: Werner Koch --- g10/skclist.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'g10/skclist.c') diff --git a/g10/skclist.c b/g10/skclist.c index fe24b4a6d..fd747fb2b 100644 --- a/g10/skclist.c +++ b/g10/skclist.c @@ -149,7 +149,8 @@ build_sk_list (ctrl_t ctrl, } err = get_seckey_default_or_card (ctrl, pk, - info.fpr1valid? info.fpr1 : NULL, 20); + info.fpr1len? info.fpr1 : NULL, + info.fpr1len); if (err) { free_public_key (pk); @@ -331,7 +332,7 @@ enum_secret_keys (ctrl_t ctrl, void **context, PKT_public_key *sk) strlist_t sl; strlist_t card_list; char *serialno; - char fpr2[43]; + char fpr2[2 * MAX_FINGERPRINT_LEN + 3 ]; struct agent_card_info_s info; kbnode_t keyblock; kbnode_t node; @@ -419,17 +420,17 @@ enum_secret_keys (ctrl_t ctrl, void **context, PKT_public_key *sk) } xfree (serialno); - c->info.fpr2valid = 0; + c->info.fpr2len = 0; err = agent_scd_getattr ("KEY-FPR", &c->info); if (err) log_error ("error retrieving key fingerprint from card: %s\n", gpg_strerror (err)); - if (c->info.fpr2valid) + if (c->info.fpr2len) { c->fpr2[0] = '0'; c->fpr2[1] = 'x'; - bin2hex (c->info.fpr2, 20, c->fpr2+2); + bin2hex (c->info.fpr2, sizeof c->info.fpr2,c->fpr2+2); name = c->fpr2; } c->sl = c->sl->next; -- cgit v1.2.3