diff --git a/agent/ChangeLog b/agent/ChangeLog index d4cea792c..21cd0c4ff 100644 --- a/agent/ChangeLog +++ b/agent/ChangeLog @@ -1,15 +1,18 @@ -2011-04-10 Ben Kibbey +2011-04-12 Werner Koch - * command.c: (cmd_passwd): Add option --preset. + * agent.h (CACHE_TTL_NONCE, CACHE_TTL_OPT_PRESET): New. + * command.c (cmd_passwd, cmd_import_key): Use new macros. + * genkey.c (agent_genkey): Ditto. 2011-04-10 Ben Kibbey - * command.c: (cmd_genkey): Add option --preset. - * genkey.c: (agent_genkey): Add parameter preset. + * command.c (cmd_passwd): Add option --preset. + * command.c (cmd_genkey): Add option --preset. + * genkey.c (agent_genkey): Add parameter preset. 2011-04-06 Ben Kibbey - * command.c: (do_one_keyinfo): Add protection type field. + * command.c (do_one_keyinfo): Add protection type field. 2011-03-10 Werner Koch diff --git a/agent/agent.h b/agent/agent.h index d5aaec8b7..20a617f78 100644 --- a/agent/agent.h +++ b/agent/agent.h @@ -217,6 +217,12 @@ typedef enum } cache_mode_t; +/* The TTL is seconds used for adding a new nonce mode cache item. */ +#define CACHE_TTL_NONCE 120 + +/* The TTL in seconds used by the --preset option of some commands. */ +#define CACHE_TTL_OPT_PRESET 900 + /* The type of a function to lookup a TTL by a keygrip. */ typedef int (*lookup_ttl_t)(const char *hexgrip); diff --git a/agent/command.c b/agent/command.c index 8655c9998..e5243ed34 100644 --- a/agent/command.c +++ b/agent/command.c @@ -1411,7 +1411,7 @@ cmd_learn (assuan_context_t ctx, char *line) static const char hlp_passwd[] = - "PASSWD [--cache-nonce=] [--passwd-nonce=] [--preset] \n" + "PASSWD [--cache-nonce=] [--passwd-nonce=] [--preset] \n" "\n" "Change the passphrase/PIN for the key identified by keygrip in LINE. When\n" "--preset is used then the new passphrase will be added to the cache.\n"; @@ -1501,7 +1501,7 @@ cmd_passwd (assuan_context_t ctx, char *line) } if (cache_nonce && !agent_put_cache (cache_nonce, CACHE_MODE_NONCE, - passphrase, 120 /*seconds*/)) + passphrase, CACHE_TTL_NONCE)) { assuan_write_status (ctx, "CACHE_NONCE", cache_nonce); xfree (ctrl->server_local->last_cache_nonce); @@ -1521,7 +1521,7 @@ cmd_passwd (assuan_context_t ctx, char *line) } if (passwd_nonce && !agent_put_cache (passwd_nonce, CACHE_MODE_NONCE, - newpass, 120 /*seconds*/)) + newpass, CACHE_TTL_NONCE)) { assuan_write_status (ctx, "PASSWD_NONCE", passwd_nonce); xfree (ctrl->server_local->last_passwd_nonce); @@ -1532,7 +1532,8 @@ cmd_passwd (assuan_context_t ctx, char *line) { char hexgrip[40+1]; bin2hex(grip, 20, hexgrip); - err = agent_put_cache (hexgrip, CACHE_MODE_ANY, newpass, 900); + err = agent_put_cache (hexgrip, CACHE_MODE_ANY, newpass, + CACHE_TTL_OPT_PRESET); } } } @@ -1844,7 +1845,7 @@ cmd_import_key (assuan_context_t ctx, char *line) } if (cache_nonce && !agent_put_cache (cache_nonce, CACHE_MODE_NONCE, - passphrase, 120 /*seconds*/)) + passphrase, CACHE_TTL_NONCE)) assuan_write_status (ctx, "CACHE_NONCE", cache_nonce); } } diff --git a/agent/genkey.c b/agent/genkey.c index 95e0a64ce..30e698f77 100644 --- a/agent/genkey.c +++ b/agent/genkey.c @@ -432,7 +432,7 @@ agent_genkey (ctrl_t ctrl, const char *cache_nonce, if (cache_nonce && !no_protection && !agent_put_cache (cache_nonce, CACHE_MODE_NONCE, - passphrase, 900 /*seconds*/)) + passphrase, CACHE_TTL_OPT_PRESET)) agent_write_status (ctrl, "CACHE_NONCE", cache_nonce, NULL); if (preset && !no_protection) { @@ -441,7 +441,8 @@ agent_genkey (ctrl_t ctrl, const char *cache_nonce, if (gcry_pk_get_keygrip (s_private, grip)) { bin2hex(grip, 20, hexgrip); - rc = agent_put_cache (hexgrip, CACHE_MODE_ANY, passphrase, 900); + rc = agent_put_cache (hexgrip, CACHE_MODE_ANY, passphrase, + CACHE_TTL_OPT_PRESET); } } }