mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-02 22:46:30 +02:00
gpg,gpgsm: Record the creation time of a private key.
* sm/call-agent.c (gpgsm_agent_genkey): Pass --timestamp option.
(gpgsm_agent_import_key): Ditto.
* g10/call-agent.c (agent_genkey): Add arg timestamp and pass it on.
(agent_import_key): Ditto.
* g10/import.c (transfer_secret_keys): Pass the creation date to the
agent.
* g10/keygen.c (common_gen): Ditto.
--
Having the creation time in the private key file makes it a lot easier
to re-create an OpenPGP public keyblock in case it was accidentally
lost.
Signed-off-by: Werner Koch <wk@gnupg.org>
Cherry-picked-from-master: 4031c42bfd
This commit is contained in:
parent
051830d7b4
commit
5ac0cf1b81
5 changed files with 43 additions and 12 deletions
|
@ -565,7 +565,7 @@ inq_genkey_parms (void *opaque, const char *line)
|
|||
|
||||
|
||||
|
||||
/* Call the agent to generate a newkey */
|
||||
/* Call the agent to generate a new key */
|
||||
int
|
||||
gpgsm_agent_genkey (ctrl_t ctrl,
|
||||
ksba_const_sexp_t keyparms, ksba_sexp_t *r_pubkey)
|
||||
|
@ -575,6 +575,8 @@ gpgsm_agent_genkey (ctrl_t ctrl,
|
|||
membuf_t data;
|
||||
size_t len;
|
||||
unsigned char *buf;
|
||||
gnupg_isotime_t timebuf;
|
||||
char line[ASSUAN_LINELENGTH];
|
||||
|
||||
*r_pubkey = NULL;
|
||||
rc = start_agent (ctrl);
|
||||
|
@ -592,7 +594,9 @@ gpgsm_agent_genkey (ctrl_t ctrl,
|
|||
gk_parm.sexplen = gcry_sexp_canon_len (keyparms, 0, NULL, NULL);
|
||||
if (!gk_parm.sexplen)
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
rc = assuan_transact (agent_ctx, "GENKEY",
|
||||
gnupg_get_isotime (timebuf);
|
||||
snprintf (line, sizeof line, "GENKEY --timestamp=%s", timebuf);
|
||||
rc = assuan_transact (agent_ctx, line,
|
||||
put_membuf_cb, &data,
|
||||
inq_genkey_parms, &gk_parm, NULL, NULL);
|
||||
if (rc)
|
||||
|
@ -1344,6 +1348,8 @@ gpgsm_agent_import_key (ctrl_t ctrl, const void *key, size_t keylen)
|
|||
{
|
||||
gpg_error_t err;
|
||||
struct import_key_parm_s parm;
|
||||
gnupg_isotime_t timebuf;
|
||||
char line[ASSUAN_LINELENGTH];
|
||||
|
||||
err = start_agent (ctrl);
|
||||
if (err)
|
||||
|
@ -1354,7 +1360,9 @@ gpgsm_agent_import_key (ctrl_t ctrl, const void *key, size_t keylen)
|
|||
parm.key = key;
|
||||
parm.keylen = keylen;
|
||||
|
||||
err = assuan_transact (agent_ctx, "IMPORT_KEY",
|
||||
gnupg_get_isotime (timebuf);
|
||||
snprintf (line, sizeof line, "IMPORT_KEY --timestamp=%s", timebuf);
|
||||
err = assuan_transact (agent_ctx, line,
|
||||
NULL, NULL, inq_import_key_parms, &parm, NULL, NULL);
|
||||
return err;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue