aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2011-04-12 16:20:46 +0000
committerWerner Koch <[email protected]>2011-04-12 16:20:46 +0000
commitf8c5395fbd24b9811807d7601e22b38af9f5126c (patch)
treeae11a3ad0bb041b5b31f115ec91e16c2c0e383ad
parentAdded PASSWD --preset. (diff)
downloadgnupg-f8c5395fbd24b9811807d7601e22b38af9f5126c.tar.gz
gnupg-f8c5395fbd24b9811807d7601e22b38af9f5126c.zip
Use macros for the 120 and 900s cache TTLs.
Diffstat (limited to '')
-rw-r--r--agent/ChangeLog13
-rw-r--r--agent/agent.h6
-rw-r--r--agent/command.c11
-rw-r--r--agent/genkey.c5
4 files changed, 23 insertions, 12 deletions
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 <[email protected]>
+2011-04-12 Werner Koch <[email protected]>
- * 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 <[email protected]>
- * 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 <[email protected]>
- * command.c: (do_one_keyinfo): Add protection type field.
+ * command.c (do_one_keyinfo): Add protection type field.
2011-03-10 Werner Koch <[email protected]>
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=<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);
}
}
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);
}
}
}