diff --git a/scd/app-openpgp.c b/scd/app-openpgp.c index ec2c04756..5f1ba2f5a 100644 --- a/scd/app-openpgp.c +++ b/scd/app-openpgp.c @@ -5454,8 +5454,16 @@ do_with_keygrip (app_t app, ctrl_t ctrl, int action, const char *keygrip_str, } else { - i = capability - 1; - send_keyinfo_if_available (app, ctrl, buf, data, i); + if (capability == GCRY_PK_USAGE_SIGN) + i = 0; + else if (capability == GCRY_PK_USAGE_ENCR) + i = 1; + else if (capability == GCRY_PK_USAGE_AUTH) + i = 2; + else + i = -1; + if (i >= 0) + send_keyinfo_if_available (app, ctrl, buf, data, i); } /* Return an error so that the dispatcher keeps on looping @@ -5477,6 +5485,7 @@ do_with_keygrip (app_t app, ctrl_t ctrl, int action, const char *keygrip_str, return gpg_error (GPG_ERR_NOT_FOUND); } + /* Show information about card capabilities. */ static void show_caps (struct app_local_s *s) diff --git a/scd/app-piv.c b/scd/app-piv.c index cd53c175f..8a3ba1e1b 100644 --- a/scd/app-piv.c +++ b/scd/app-piv.c @@ -3513,17 +3513,17 @@ do_with_keygrip (app_t app, ctrl_t ctrl, int action, } else if (!want_keygripstr || !strcmp (keygripstr, want_keygripstr)) { - if (capability == 1) + if (capability == GCRY_PK_USAGE_SIGN) { if (strcmp (data_objects[i].keyref, "9C")) continue; } - if (capability == 2) + if (capability == GCRY_PK_USAGE_ENCR) { if (strcmp (data_objects[i].keyref, "9D")) continue; } - if (capability == 3) + if (capability == GCRY_PK_USAGE_AUTH) { if (strcmp (data_objects[i].keyref, "9A")) continue; diff --git a/scd/command.c b/scd/command.c index 159c6f2dc..98095f259 100644 --- a/scd/command.c +++ b/scd/command.c @@ -2077,11 +2077,11 @@ cmd_keyinfo (assuan_context_t ctx, char *line) if (has_option (line, "--list")) cap = 0; else if (has_option (line, "--list=sign")) - cap = 1; + cap = GCRY_PK_USAGE_SIGN; else if (has_option (line, "--list=encr")) - cap = 2; + cap = GCRY_PK_USAGE_ENCR; else if (has_option (line, "--list=auth")) - cap = 3; + cap = GCRY_PK_USAGE_AUTH; else keygrip_str = line;