aboutsummaryrefslogtreecommitdiffstats
path: root/agent/call-pinentry.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2015-04-14 16:41:05 +0000
committerWerner Koch <[email protected]>2015-04-14 16:41:05 +0000
commit2180845959839705200e3172dbafc94b70b9007f (patch)
tree0eb486b7b07af489c51efb72b54bde991cadbc4e /agent/call-pinentry.c
parentscd: better handling of extended APDU. (diff)
downloadgnupg-2180845959839705200e3172dbafc94b70b9007f.tar.gz
gnupg-2180845959839705200e3172dbafc94b70b9007f.zip
agent: Send the new SETKEYINFO command to the Pinentry.
* agent/call-pinentry.c (agent_askpin): Add args keyinfo and cache_mode. Change all callers to pass (NULL,0) for them. Send SETKEYINFO command. * agent/findkey.c (unprotect): Pass the keygrip and the cache_mode for the new args. Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to 'agent/call-pinentry.c')
-rw-r--r--agent/call-pinentry.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/agent/call-pinentry.c b/agent/call-pinentry.c
index 6db429c47..d3a0547aa 100644
--- a/agent/call-pinentry.c
+++ b/agent/call-pinentry.c
@@ -737,12 +737,14 @@ close_button_status_cb (void *opaque, const char *line)
/* Call the Entry and ask for the PIN. We do check for a valid PIN
number here and repeat it as long as we have invalid formed
- numbers. */
+ numbers. KEYINFO and CACHEMODE are used to tell pinentry something
+ about the key. */
int
agent_askpin (ctrl_t ctrl,
const char *desc_text, const char *prompt_text,
const char *initial_errtext,
- struct pin_entry_info_s *pininfo)
+ struct pin_entry_info_s *pininfo,
+ const char *keyinfo, cache_mode_t cache_mode)
{
int rc;
char line[ASSUAN_LINELENGTH];
@@ -802,6 +804,24 @@ agent_askpin (ctrl_t ctrl,
if (rc)
return rc;
+ /* If we have a KYEINFO string and are normal, user, or ssh cache
+ mode, we tell that the Pinentry so it may use it for own caching
+ purposes. Most pinentries won't have this implemented and thus
+ we do not error out in this case. */
+ if (keyinfo && (cache_mode == CACHE_MODE_NORMAL
+ || cache_mode == CACHE_MODE_USER
+ || cache_mode == CACHE_MODE_SSH))
+ {
+ snprintf (line, DIM(line)-1, "SETKEYINFO %c/%s",
+ cache_mode == CACHE_MODE_USER? 'u' :
+ cache_mode == CACHE_MODE_SSH? 's' : 'n',
+ keyinfo);
+ rc = assuan_transact (entry_ctx, line,
+ NULL, NULL, NULL, NULL, NULL, NULL);
+ if (rc && gpg_err_code (rc) != GPG_ERR_ASS_UNKNOWN_CMD)
+ return unlock_pinentry (rc);
+ }
+
snprintf (line, DIM(line)-1, "SETDESC %s", desc_text);
line[DIM(line)-1] = 0;
rc = assuan_transact (entry_ctx, line, NULL, NULL, NULL, NULL, NULL, NULL);