mirror of
git://git.gnupg.org/gnupg.git
synced 2024-12-22 10:19:57 +01:00
scd:openpgp: Send a KEY-TIME status with READKEY
* scd/app-openpgp.c (retrieve_fprtime_from_card): New. (do_readkey): Send a KEY_TIME status. -- It might be easier to fold this into KEYPAIRINFO but for backward compatibility using a separate status line is safer. Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
6bc7318ef5
commit
77ea916533
@ -1291,6 +1291,36 @@ retrieve_fpr_from_card (app_t app, int keyno, char *fpr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Retrieve the creation time of the fingerprint for key KEYNO from
|
||||||
|
* the card inserted in the slot of APP and store it at R_FPRTIME.
|
||||||
|
* Returns 0 on success or an error code. */
|
||||||
|
static gpg_error_t
|
||||||
|
retrieve_fprtime_from_card (app_t app, int keyno, u32 *r_fprtime)
|
||||||
|
{
|
||||||
|
gpg_error_t err = 0;
|
||||||
|
void *relptr;
|
||||||
|
unsigned char *value;
|
||||||
|
size_t valuelen;
|
||||||
|
u32 fprtime;
|
||||||
|
|
||||||
|
log_assert (keyno >=0 && keyno <= 2);
|
||||||
|
|
||||||
|
relptr = get_one_do (app, 0x00CD, &value, &valuelen, NULL);
|
||||||
|
if (relptr && valuelen >= 4*(keyno+1))
|
||||||
|
{
|
||||||
|
fprtime = buf32_to_u32 (value + 4*keyno);
|
||||||
|
if (!fprtime)
|
||||||
|
err = gpg_error (GPG_ERR_NOT_FOUND);
|
||||||
|
else
|
||||||
|
*r_fprtime = fprtime;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
err = gpg_error (GPG_ERR_NOT_FOUND);
|
||||||
|
xfree (relptr);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Retrieve the public key material for the RSA key, whose fingerprint
|
/* Retrieve the public key material for the RSA key, whose fingerprint
|
||||||
is FPR, from gpg output, which can be read through the stream FP.
|
is FPR, from gpg output, which can be read through the stream FP.
|
||||||
The RSA modulus will be stored at the address of M and MLEN, the
|
The RSA modulus will be stored at the address of M and MLEN, the
|
||||||
@ -1938,6 +1968,7 @@ do_readkey (app_t app, ctrl_t ctrl, const char *keyid, unsigned int flags,
|
|||||||
gpg_error_t err;
|
gpg_error_t err;
|
||||||
int keyno;
|
int keyno;
|
||||||
unsigned char *buf;
|
unsigned char *buf;
|
||||||
|
u32 fprtime;
|
||||||
|
|
||||||
if (strlen (keyid) == 40)
|
if (strlen (keyid) == 40)
|
||||||
{
|
{
|
||||||
@ -1975,6 +2006,13 @@ do_readkey (app_t app, ctrl_t ctrl, const char *keyid, unsigned int flags,
|
|||||||
err = send_keypair_info (app, ctrl, keyno+1);
|
err = send_keypair_info (app, ctrl, keyno+1);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
if (!retrieve_fprtime_from_card (app, keyno, &fprtime))
|
||||||
|
{
|
||||||
|
err = send_status_printf (ctrl, "KEY-TIME", "OPENPGP.%d %lu",
|
||||||
|
keyno+1, (unsigned long)fprtime);
|
||||||
|
if (err)
|
||||||
|
return err;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pk && pklen)
|
if (pk && pklen)
|
||||||
|
@ -2368,7 +2368,7 @@ send_status_direct (ctrl_t ctrl, const char *keyword, const char *args)
|
|||||||
|
|
||||||
|
|
||||||
/* This status functions expects a printf style format string. No
|
/* This status functions expects a printf style format string. No
|
||||||
* filtering of the data is done instead the orintf formatted data is
|
* filtering of the data is done instead the printf formatted data is
|
||||||
* send using assuan_send_status. */
|
* send using assuan_send_status. */
|
||||||
gpg_error_t
|
gpg_error_t
|
||||||
send_status_printf (ctrl_t ctrl, const char *keyword, const char *format, ...)
|
send_status_printf (ctrl_t ctrl, const char *keyword, const char *format, ...)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user