mirror of
https://github.com/polhenarejos/pico-keys-sdk
synced 2026-05-08 22:16:10 +02:00
New format for applet selection.
AID comparison is performed by the kernel. If it is the same as previously loaded, do nothing. If not found, do nothing. If found and is different, unload old and load the new one. All other applets shall be migrated to new format. Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
15
src/apdu.c
15
src/apdu.c
@@ -27,11 +27,18 @@ extern uint32_t timeout;
|
||||
int process_apdu() {
|
||||
led_set_blink(BLINK_PROCESSING);
|
||||
if (INS(apdu) == 0xA4 && P1(apdu) == 0x04 && (P2(apdu) == 0x00 || P2(apdu) == 0x4)) { //select by AID
|
||||
if (current_app && current_app->unload) {
|
||||
current_app->unload();
|
||||
}
|
||||
for (int a = 0; a < num_apps; a++) {
|
||||
if ((current_app = apps[a].select_aid(&apps[a], apdu.data, apdu.nc))) {
|
||||
if (!memcmp(apps[a].aid + 1, apdu.data, MIN(apdu.nc, apps[a].aid[0]))) {
|
||||
if (current_app) {
|
||||
if (current_app->aid && !memcmp(current_app->aid + 1, apdu.data, apdu.nc)) {
|
||||
return set_res_sw(0x90, 0x00);
|
||||
}
|
||||
if (current_app->unload) {
|
||||
current_app->unload();
|
||||
}
|
||||
}
|
||||
current_app = &apps[a];
|
||||
current_app->select_aid(current_app);
|
||||
return set_res_sw(0x90, 0x00);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user