aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNIIBE Yutaka <[email protected]>2022-03-28 00:08:08 +0000
committerNIIBE Yutaka <[email protected]>2022-03-28 00:08:08 +0000
commitf0a1c79f60ce22b99ec75c2fd0de579fe976b48f (patch)
tree549694520f244b0e0430bbdebd573a43707163f9
parentdirmngr: Workaround for a certain broken LDAP URL (diff)
downloadgnupg-f0a1c79f60ce22b99ec75c2fd0de579fe976b48f.tar.gz
gnupg-f0a1c79f60ce22b99ec75c2fd0de579fe976b48f.zip
agent: KEYTOCARD prefers to specified time.
* agent/command.c (cmd_keytocard): Timestamp at "Created:" field is only used when time is not specified. -- Fixes-commit: c795be79c14fac01b984bdc2e2041d2141f27612 Signed-off-by: NIIBE Yutaka <[email protected]>
-rw-r--r--agent/command.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/agent/command.c b/agent/command.c
index 2fb916ee9..a021eef26 100644
--- a/agent/command.c
+++ b/agent/command.c
@@ -3029,20 +3029,19 @@ cmd_keytocard (assuan_context_t ctx, char *line)
goto leave;
}
+ /* 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. */
+ if (argc > 3)
+ timestamp = isotime2epoch (argv[3]);
+ else if (timestamp == (time_t)(-1))
+ timestamp = isotime2epoch ("19700101T000000");
+
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;
- }
+ err = gpg_error (GPG_ERR_INV_TIME);
+ goto leave;
}
/* Note: We can't use make_canon_sexp because we need to allocate a