Changeset View
Changeset View
Standalone View
Standalone View
scd/app.c
Context not available. | |||||
} | } | ||||
/* | |||||
* Check external interference before each use of the application on | |||||
* card. Returns -1 when detecting some external interference. | |||||
* Returns 0 if not. | |||||
* | |||||
* Note: This kind of detection can't be perfect. At most, it may be | |||||
* possibly useful kludge, in some limited situations. | |||||
*/ | |||||
static int | |||||
check_external_interference (app_t app, ctrl_t ctrl) | |||||
{ | |||||
/* | |||||
* Only when a user is using Yubikey with pcsc-shared configuration, | |||||
* we need this detection. Otherwise, the card/token is under full | |||||
* control of scdaemon, there's no problem at all. | |||||
*/ | |||||
if (!opt.pcsc_shared) | |||||
return 0; | |||||
if (app->fnc.check_aid) | |||||
{ | |||||
unsigned char *aid; | |||||
size_t aidlen; | |||||
gpg_error_t err; | |||||
int slot = app_get_slot (app); | |||||
err = iso7816_get_data (slot, 0, 0x004F, &aid, &aidlen); | |||||
if (err) | |||||
return -1; | |||||
err = app->fnc.check_aid (app, ctrl, aid, aidlen); | |||||
xfree (aid); | |||||
if (err) | |||||
return -1; | |||||
} | |||||
return 0; | |||||
} | |||||
/* Check that the card has been initialized and whether we need to | /* Check that the card has been initialized and whether we need to | ||||
* switch to another application on the same card. Switching means | * switch to another application on the same card. Switching means | ||||
* that the new active app will be moved to the head of the list at | * that the new active app will be moved to the head of the list at | ||||
Context not available. | |||||
ctrl->current_apptype = card->app->apptype; | ctrl->current_apptype = card->app->apptype; | ||||
return 0; | return 0; | ||||
} | } | ||||
/* This validate for interference before to be able to swith beteween | |||||
apps on the card. If it not possible to reselect the current apps | |||||
on card it's a bad card */ | |||||
if (check_external_interference (card->app, ctrl) != 0) | |||||
{ | |||||
err = run_reselect (ctrl, card, card->app, card->app); | |||||
if (!err) | |||||
return err; | |||||
} | |||||
for (app = card->app; app; app = app->next) | for (app = card->app; app; app = app->next) | ||||
if (app->apptype == ctrl->current_apptype) | if (app->apptype == ctrl->current_apptype) | ||||
break; | break; | ||||
Context not available. |