diff options
author | Werner Koch <wk@gnupg.org> | 2020-04-02 11:54:01 +0200 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2020-04-02 11:54:01 +0200 |
commit | 5b7b42e2b2b7ba7b88f89ff4b4ee7baf0eef2a04 (patch) | |
tree | 627c06b4e84307688672d53ce8c0a3dd4263e414 /scd | |
parent | scd: New command DEVINFO. (diff) | |
download | gnupg2-5b7b42e2b2b7ba7b88f89ff4b4ee7baf0eef2a04.tar.xz gnupg2-5b7b42e2b2b7ba7b88f89ff4b4ee7baf0eef2a04.zip |
scd: Use Gcrypt usage constants for the do_with_keygrip capabilities.
* scd/command.c (cmd_keyinfo): Use Gcrypt constants for CAP.
* scd/app-openpgp.c (do_with_keygrip): Adjust for them.
* scd/app-piv.c (do_with_keygrip): Ditto.
--
That makes it easier to read. An open question is whether we should
allow several capabilities and whether they are the ORed or ANDed.
Signed-off-by: Werner Koch <wk@gnupg.org>
Diffstat (limited to 'scd')
-rw-r--r-- | scd/app-openpgp.c | 13 | ||||
-rw-r--r-- | scd/app-piv.c | 6 | ||||
-rw-r--r-- | scd/command.c | 6 |
3 files changed, 17 insertions, 8 deletions
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; |