mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-02 22:46:30 +02:00
agent: Use "Created:" field for creation time.
* agent/agent.h (agent_key_from_file): Change the declaration. * agent/findkey.c (agent_key_from_file): Return timestamp. * agent/pkdecrypt.c (agent_pkdecrypt): Follow the change. * agent/pksign.c (agent_pkdecrypt): Likewise. * agent/command.c (cmd_passwd, cmd_export_key): Likewise. (cmd_keytocard): Use timestamp in private key file in "Created:". -- GnuPG-bug-id: 5538 Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
parent
25d37a0a6a
commit
c795be79c1
5 changed files with 36 additions and 21 deletions
|
@ -2204,7 +2204,7 @@ cmd_passwd (assuan_context_t ctx, char *line)
|
|||
opt_verify? NULL : cache_nonce,
|
||||
ctrl->server_local->keydesc,
|
||||
grip, &shadow_info, CACHE_MODE_IGNORE, NULL,
|
||||
&s_skey, &passphrase);
|
||||
&s_skey, &passphrase, NULL);
|
||||
if (err)
|
||||
;
|
||||
else if (shadow_info)
|
||||
|
@ -2812,7 +2812,7 @@ cmd_export_key (assuan_context_t ctx, char *line)
|
|||
err = agent_key_from_file (ctrl, cache_nonce,
|
||||
ctrl->server_local->keydesc, grip,
|
||||
&shadow_info, CACHE_MODE_IGNORE, NULL, &s_skey,
|
||||
openpgp ? &passphrase : NULL);
|
||||
openpgp ? &passphrase : NULL, NULL);
|
||||
if (err)
|
||||
goto leave;
|
||||
if (shadow_info)
|
||||
|
@ -2979,7 +2979,7 @@ cmd_keytocard (assuan_context_t ctx, char *line)
|
|||
const char *argv[5];
|
||||
int argc;
|
||||
unsigned char grip[20];
|
||||
const char *serialno, *timestamp_str, *keyref;
|
||||
const char *serialno, *keyref;
|
||||
gcry_sexp_t s_skey = NULL;
|
||||
unsigned char *keydata;
|
||||
size_t keydatalen;
|
||||
|
@ -3017,21 +3017,9 @@ cmd_keytocard (assuan_context_t ctx, char *line)
|
|||
|
||||
keyref = argv[2];
|
||||
|
||||
/* FIXME: Default to the creation time as stored in the private
|
||||
* key. The parameter is here so that gpg can make sure that the
|
||||
* timestamp as used for key creation (and thus the openPGP
|
||||
* fingerprint) is used. */
|
||||
timestamp_str = argc > 3? argv[3] : "19700101T000000";
|
||||
|
||||
if ((timestamp = isotime2epoch (timestamp_str)) == (time_t)(-1))
|
||||
{
|
||||
err = gpg_error (GPG_ERR_INV_TIME);
|
||||
goto leave;
|
||||
}
|
||||
|
||||
err = agent_key_from_file (ctrl, NULL, ctrl->server_local->keydesc, grip,
|
||||
&shadow_info, CACHE_MODE_IGNORE, NULL,
|
||||
&s_skey, NULL);
|
||||
&s_skey, NULL, ×tamp);
|
||||
if (err)
|
||||
goto leave;
|
||||
if (shadow_info)
|
||||
|
@ -3041,6 +3029,22 @@ cmd_keytocard (assuan_context_t ctx, char *line)
|
|||
goto leave;
|
||||
}
|
||||
|
||||
if (timestamp == (time_t)(-1))
|
||||
{
|
||||
/* Default to the creation time as stored in the private key. The
|
||||
* parameter is here so that gpg can make sure that the timestamp as
|
||||
* used for key creation (and thus the openPGP fingerprint) is
|
||||
* used. */
|
||||
|
||||
const char *timestamp_str= argc > 3? argv[3] : "19700101T000000";
|
||||
|
||||
if ((timestamp = isotime2epoch (timestamp_str)) == (time_t)(-1))
|
||||
{
|
||||
err = gpg_error (GPG_ERR_INV_TIME);
|
||||
goto leave;
|
||||
}
|
||||
}
|
||||
|
||||
/* Note: We can't use make_canon_sexp because we need to allocate a
|
||||
* few extra bytes for our hack below. */
|
||||
keydatalen = gcry_sexp_sprint (s_skey, GCRYSEXP_FMT_CANON, NULL, 0);
|
||||
|
@ -3277,7 +3281,7 @@ cmd_keytotpm (assuan_context_t ctx, char *line)
|
|||
|
||||
err = agent_key_from_file (ctrl, NULL, ctrl->server_local->keydesc, grip,
|
||||
&shadow_info, CACHE_MODE_IGNORE, NULL,
|
||||
&s_skey, NULL);
|
||||
&s_skey, NULL, NULL);
|
||||
if (err)
|
||||
{
|
||||
xfree (shadow_info);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue