aboutsummaryrefslogtreecommitdiffstats
path: root/agent/genkey.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2020-08-17 12:21:00 +0000
committerWerner Koch <[email protected]>2020-08-17 13:05:49 +0000
commit0da923a1240ac78d60c92cdd8488c4e405c3243b (patch)
tree106ce6faa60a206478752cb21096cc29b4e90d15 /agent/genkey.c
parentAdd --chuid to gpg, gpg-card, and gpg-connect-agent. (diff)
downloadgnupg-0da923a1240ac78d60c92cdd8488c4e405c3243b.tar.gz
gnupg-0da923a1240ac78d60c92cdd8488c4e405c3243b.zip
agent: Allow to pass a timestamp to genkey and import.
* agent/command.c (cmd_genkey): Add option --timestamp. (cmd_import_key): Ditto. * agent/genkey.c (store_key): Add arg timestamp and change callers. (agent_genkey): Ditto. * agent/findkey.c (write_extended_private_key): Add args timestamp and new key to write a Created line. (agent_write_private_key): Add arg timestamp. (agent_write_shadow_key): Ditto. agent/protect-tool.c (agent_write_private_key): Ditto as dummy arg. Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to 'agent/genkey.c')
-rw-r--r--agent/genkey.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/agent/genkey.c b/agent/genkey.c
index 970876ba1..9b47f0fac 100644
--- a/agent/genkey.c
+++ b/agent/genkey.c
@@ -32,7 +32,7 @@
static int
store_key (gcry_sexp_t private, const char *passphrase, int force,
- unsigned long s2k_count)
+ unsigned long s2k_count, time_t timestamp)
{
int rc;
unsigned char *buf;
@@ -67,7 +67,7 @@ store_key (gcry_sexp_t private, const char *passphrase, int force,
buf = p;
}
- rc = agent_write_private_key (grip, buf, len, force, NULL, NULL);
+ rc = agent_write_private_key (grip, buf, len, force, NULL, NULL, timestamp);
xfree (buf);
return rc;
}
@@ -423,9 +423,11 @@ agent_ask_new_passphrase (ctrl_t ctrl, const char *prompt,
KEYPARAM. If CACHE_NONCE is given first try to lookup a passphrase
using the cache nonce. If NO_PROTECTION is true the key will not
be protected by a passphrase. If OVERRIDE_PASSPHRASE is true that
- passphrase will be used for the new key. */
+ passphrase will be used for the new key. If TIMESTAMP is not zero
+ it will be recorded as creation date of the key (unless extended
+ format is disabled) . */
int
-agent_genkey (ctrl_t ctrl, const char *cache_nonce,
+agent_genkey (ctrl_t ctrl, const char *cache_nonce, time_t timestamp,
const char *keyparam, size_t keyparamlen, int no_protection,
const char *override_passphrase, int preset, membuf_t *outbuf)
{
@@ -499,7 +501,7 @@ agent_genkey (ctrl_t ctrl, const char *cache_nonce,
/* store the secret key */
if (DBG_CRYPTO)
log_debug ("storing private key\n");
- rc = store_key (s_private, passphrase, 0, ctrl->s2k_count);
+ rc = store_key (s_private, passphrase, 0, ctrl->s2k_count, timestamp);
if (!rc)
{
if (!cache_nonce)
@@ -573,7 +575,7 @@ agent_protect_and_store (ctrl_t ctrl, gcry_sexp_t s_skey,
{
/* Take an empty string as request not to protect the key. */
err = store_key (s_skey, **passphrase_addr? *passphrase_addr:NULL, 1,
- ctrl->s2k_count);
+ ctrl->s2k_count, 0);
}
else
{
@@ -588,7 +590,7 @@ agent_protect_and_store (ctrl_t ctrl, gcry_sexp_t s_skey,
L_("Please enter the new passphrase"),
&pass);
if (!err)
- err = store_key (s_skey, pass, 1, ctrl->s2k_count);
+ err = store_key (s_skey, pass, 1, ctrl->s2k_count, 0);
if (!err && passphrase_addr)
*passphrase_addr = pass;
else