mirror of
git://git.gnupg.org/gnupg.git
synced 2024-12-22 10:19:57 +01:00
scd: Minor tweak for easier backporting
* scd/app-common.h (APP_CARD): New. Use it in app-*.c to access app->card. -- This should help to make backporting to 2.2 easier.
This commit is contained in:
parent
8d5a9c858d
commit
6d4280b13d
@ -215,6 +215,12 @@ app_get_slot (app_t app)
|
||||
}
|
||||
|
||||
|
||||
/* Macro to access members in app->card. We use this macro because in
|
||||
* 2.2 many members are stored directly in app_t and this way we can
|
||||
* easier backport stuff. */
|
||||
#define APP_CARD(a) ((a)->card)
|
||||
|
||||
|
||||
/*-- app-help.c --*/
|
||||
unsigned int app_help_count_bits (const unsigned char *a, size_t len);
|
||||
gpg_error_t app_help_get_keygrip_string_pk (const void *pk, size_t pklen,
|
||||
|
@ -1284,7 +1284,7 @@ do_getattr (app_t app, ctrl_t ctrl, const char *name)
|
||||
if (opt.verbose)
|
||||
log_info ("Yubikey bug: length %zu != %zu", valuelen, len);
|
||||
|
||||
if (app->card->cardtype != CARDTYPE_YUBIKEY)
|
||||
if (APP_CARD(app)->cardtype != CARDTYPE_YUBIKEY)
|
||||
return gpg_error (GPG_ERR_INV_OBJ);
|
||||
}
|
||||
}
|
||||
@ -1918,7 +1918,7 @@ get_public_key (app_t app, int keyno)
|
||||
if (err)
|
||||
{
|
||||
/* Yubikey returns wrong code. Fix it up. */
|
||||
if (app->card->cardtype == CARDTYPE_YUBIKEY)
|
||||
if (APP_CARD(app)->cardtype == CARDTYPE_YUBIKEY)
|
||||
err = gpg_error (GPG_ERR_NO_OBJ);
|
||||
/* Yubikey NEO (!CARDTYPE_YUBIKEY) also returns wrong code. Fix it up. */
|
||||
else if (gpg_err_code (err) == GPG_ERR_CARD)
|
||||
@ -2464,7 +2464,7 @@ cache_pin (app_t app, ctrl_t ctrl, int chvno, const char *pin)
|
||||
|
||||
if (!keyref)
|
||||
return;
|
||||
switch (app->card->cardtype)
|
||||
switch (APP_CARD(app)->cardtype)
|
||||
{
|
||||
case CARDTYPE_YUBIKEY: break;
|
||||
default: return;
|
||||
@ -2495,7 +2495,7 @@ pin_from_cache (app_t app, ctrl_t ctrl, int chvno, char **r_pin)
|
||||
|
||||
if (!keyref)
|
||||
return 0;
|
||||
switch (app->card->cardtype)
|
||||
switch (APP_CARD(app)->cardtype)
|
||||
{
|
||||
case CARDTYPE_YUBIKEY: break;
|
||||
default: return 0;
|
||||
@ -2951,15 +2951,15 @@ do_setattr (app_t app, ctrl_t ctrl, const char *name,
|
||||
|
||||
if (table[idx].special == 4)
|
||||
{
|
||||
if (app->card->cardtype == CARDTYPE_YUBIKEY
|
||||
|| app->card->cardtype == CARDTYPE_GNUK)
|
||||
if (APP_CARD(app)->cardtype == CARDTYPE_YUBIKEY
|
||||
|| APP_CARD(app)->cardtype == CARDTYPE_GNUK)
|
||||
{
|
||||
rc = verify_chv3 (app, ctrl, pincb, pincb_arg);
|
||||
if (rc)
|
||||
return rc;
|
||||
|
||||
if (valuelen == 3
|
||||
&& app->card->cardtype == CARDTYPE_GNUK)
|
||||
&& APP_CARD(app)->cardtype == CARDTYPE_GNUK)
|
||||
{
|
||||
value = NULL;
|
||||
valuelen = 0;
|
||||
@ -6022,7 +6022,7 @@ do_reselect (app_t app, ctrl_t ctrl)
|
||||
/* An extra check which should not be necessary because the caller
|
||||
* should have made sure that a re-select is only called for
|
||||
* appropriate cards. */
|
||||
if (app->card->cardtype != CARDTYPE_YUBIKEY)
|
||||
if (APP_CARD(app)->cardtype != CARDTYPE_YUBIKEY)
|
||||
return gpg_error (GPG_ERR_NOT_SUPPORTED);
|
||||
|
||||
/* Note that the card can't cope with P2=0xCO, thus we need to pass
|
||||
@ -6092,13 +6092,13 @@ app_select_openpgp (app_t app)
|
||||
* work anymore and need to be modified. Recall that our
|
||||
* architecture requires exactly one serilano per card.
|
||||
*/
|
||||
if (app->card->cardtype == CARDTYPE_YUBIKEY)
|
||||
if (APP_CARD(app)->cardtype == CARDTYPE_YUBIKEY)
|
||||
xfree (buffer);
|
||||
else
|
||||
{
|
||||
xfree (app->card->serialno);
|
||||
app->card->serialno = buffer;
|
||||
app->card->serialnolen = buflen;
|
||||
xfree (APP_CARD(app)->serialno);
|
||||
APP_CARD(app)->serialno = buffer;
|
||||
APP_CARD(app)->serialnolen = buflen;
|
||||
}
|
||||
|
||||
buffer = NULL;
|
||||
|
@ -3124,13 +3124,13 @@ read_p15_info (app_t app)
|
||||
{
|
||||
/* If we don't have a serial number yet but the TokenInfo provides
|
||||
one, use that. */
|
||||
if (!app->card->serialno && app->app_local->serialno)
|
||||
if (!APP_CARD(app)->serialno && app->app_local->serialno)
|
||||
{
|
||||
app->card->serialno = app->app_local->serialno;
|
||||
app->card->serialnolen = app->app_local->serialnolen;
|
||||
APP_CARD(app)->serialno = app->app_local->serialno;
|
||||
APP_CARD(app)->serialnolen = app->app_local->serialnolen;
|
||||
app->app_local->serialno = NULL;
|
||||
app->app_local->serialnolen = 0;
|
||||
err = app_munge_serialno (app->card);
|
||||
err = app_munge_serialno (APP_CARD(app));
|
||||
if (err)
|
||||
return err;
|
||||
}
|
||||
@ -4917,8 +4917,9 @@ app_select_p15 (app_t app)
|
||||
prototype card right here because we need to access to
|
||||
EF(TokenInfo). We mark such a serial number by the using a
|
||||
prefix of FF0100. */
|
||||
if (app->card->serialnolen == 12
|
||||
&& !memcmp (app->card->serialno, "\xD2\x76\0\0\0\0\0\0\0\0\0\0", 12))
|
||||
if (APP_CARD(app)->serialnolen == 12
|
||||
&& !memcmp (APP_CARD(app)->serialno,
|
||||
"\xD2\x76\0\0\0\0\0\0\0\0\0\0", 12))
|
||||
{
|
||||
/* This is a German card with a silly serial number. Try to get
|
||||
the serial number from the EF(TokenInfo). . */
|
||||
@ -4926,16 +4927,16 @@ app_select_p15 (app_t app)
|
||||
|
||||
/* FIXME: actually get it from EF(TokenInfo). */
|
||||
|
||||
p = xtrymalloc (3 + app->card->serialnolen);
|
||||
p = xtrymalloc (3 + APP_CARD(app)->serialnolen);
|
||||
if (!p)
|
||||
rc = gpg_error (gpg_err_code_from_errno (errno));
|
||||
else
|
||||
{
|
||||
memcpy (p, "\xff\x01", 3);
|
||||
memcpy (p+3, app->card->serialno, app->card->serialnolen);
|
||||
app->card->serialnolen += 3;
|
||||
xfree (app->card->serialno);
|
||||
app->card->serialno = p;
|
||||
memcpy (p+3, APP_CARD(app)->serialno, APP_CARD(app)->serialnolen);
|
||||
APP_CARD(app)->serialnolen += 3;
|
||||
xfree (APP_CARD(app)->serialno);
|
||||
APP_CARD(app)->serialno = p;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user