scd:p15: Fix last commit and improve D-TRUST detection.

* scd/app-p15.c (read_p15_info): Improve D-TRUST card detection.
(do_getattr): Fix faulty code for the last commit.  Append the product
name to MANUFACTURER.

Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
Werner Koch 2021-04-25 16:35:36 +02:00
parent 21e3f750bd
commit cc5aa68b63
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B
2 changed files with 19 additions and 8 deletions

View File

@ -1248,7 +1248,9 @@ pkd:0:1024:B665B1435F4C2 .... FF26ABB:
This status returns the Manufactorer ID as the unsigned number N.
For OpenPGP this is well defined; for other cards this is 0. The
name of the manufacturer is also given as <string>; spaces are not
escaped. For PKCS#15 cards <string> is TokenInfo.manufactorerID.
escaped. For PKCS#15 cards <string> is TokenInfo.manufactorerID;
a string in brackets describing GnuPG's own card product name may
be appended to <string>.
*** KEY-STATUS <keyref> <status>
This is the response from scdaemon on GETATTR KEY-STATUS for

View File

@ -3703,7 +3703,7 @@ read_p15_info (app_t app)
}
if (!app->app_local->card_product
&& app->app_local->token_label
&& !strcmp (app->app_local->token_label, "D-TRUST Card V3")
&& !strncmp (app->app_local->token_label, "D-TRUST Card V3", 15)
&& app->app_local->card_type == CARD_TYPE_CARDOS_50)
{
app->app_local->card_product = CARD_PRODUCT_DTRUST;
@ -4546,6 +4546,8 @@ do_getattr (app_t app, ctrl_t ctrl, const char *name)
}
else
{
char *sn;
/* We use the first private key object which has a serial
* number set. If none was found, we parse the first
* object and see whether this has then a serial number. */
@ -4560,11 +4562,12 @@ do_getattr (app_t app, ctrl_t ctrl, const char *name)
if (!prkdf->serial_number)
prkdf = NULL;
}
if (prkdf)
sn = get_dispserialno (app, prkdf);
/* Unless there is a bogus S/N in the cert, or the product
* has a different strategy for the display-s/n, we should
* have a suitable one from the cert now. */
if (sn)
{
char *sn = get_dispserialno (app, prkdf);
/* Unless there is a bogus S/N in the cert we should
* have a suitable one from the cert here now. */
err = send_status_printf (ctrl, name, "%s", sn);
xfree (sn);
return err;
@ -4574,7 +4577,13 @@ do_getattr (app_t app, ctrl_t ctrl, const char *name)
}
else if (!strcmp (name, "MANUFACTURER"))
{
if (app->app_local->manufacturer_id)
if (app->app_local->manufacturer_id
&& (app->app_local->card_product
|| strchr (app->app_local->manufacturer_id, '[')))
return send_status_printf (ctrl, "MANUFACTURER", "0 %s [%s]",
app->app_local->manufacturer_id,
cardproduct2str (app->app_local->card_product));
else if (app->app_local->manufacturer_id)
return send_status_printf (ctrl, "MANUFACTURER", "0 %s",
app->app_local->manufacturer_id);
else
@ -4902,7 +4911,7 @@ get_dispserialno (app_t app, prkdf_object_t prkdf)
* prompts) or has any control character. */
if (app->app_local->card_product == CARD_PRODUCT_RSCS)
{
/* We use only the rigght 8 hex digits. */
/* We use only the right 8 hex digits. */
serial = app_get_serialno (app);
if (serial && (n=strlen (serial)) > 8)
memmove (serial, serial + n - 8, 9);