diff options
| author | NIIBE Yutaka <[email protected]> | 2022-03-25 05:10:46 +0000 |
|---|---|---|
| committer | NIIBE Yutaka <[email protected]> | 2022-03-25 05:10:46 +0000 |
| commit | c795be79c14fac01b984bdc2e2041d2141f27612 (patch) | |
| tree | f423a9809af54d41ecef4690e7e2aa4ca8de41c5 /agent/command.c | |
| parent | dirmngr: Suppress error message on trial reading as PEM format. (diff) | |
| download | gnupg-c795be79c14fac01b984bdc2e2041d2141f27612.tar.gz gnupg-c795be79c14fac01b984bdc2e2041d2141f27612.zip | |
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 <[email protected]>
Diffstat (limited to 'agent/command.c')
| -rw-r--r-- | agent/command.c | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/agent/command.c b/agent/command.c index 3e074443a..2fb916ee9 100644 --- a/agent/command.c +++ b/agent/command.c @@ -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); |
