Use macros for the 120 and 900s cache TTLs.

This commit is contained in:
Werner Koch 2011-04-12 18:20:46 +02:00
parent a9edbfb3a3
commit f8c5395fbd
4 changed files with 23 additions and 12 deletions

View File

@ -1,15 +1,18 @@
2011-04-10 Ben Kibbey <bjk@luxsci.net>
2011-04-12 Werner Koch <wk@g10code.com>
* 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 <bjk@luxsci.net>
* 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 <bjk@luxsci.net>
* command.c: (do_one_keyinfo): Add protection type field.
* command.c (do_one_keyinfo): Add protection type field.
2011-03-10 Werner Koch <wk@g10code.com>

View File

@ -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);

View File

@ -1411,7 +1411,7 @@ cmd_learn (assuan_context_t ctx, char *line)
static const char hlp_passwd[] =
"PASSWD [--cache-nonce=<c>] [--passwd-nonce=<s>] [--preset] <hexstring_with_keygrip>\n"
"PASSWD [--cache-nonce=<c>] [--passwd-nonce=<s>] [--preset] <hexkeygrip>\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);
}
}

View File

@ -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);
}
}
}