mirror of
https://github.com/polhenarejos/pico-keys-sdk
synced 2026-06-09 11:33:42 +02:00
Fix curious bug when FIDO+OpenPGP+CCID connection is used in some circumstances.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
@@ -44,7 +44,7 @@ typedef struct cmd {
|
|||||||
} cmd_t;
|
} cmd_t;
|
||||||
|
|
||||||
extern uint8_t num_apps;
|
extern uint8_t num_apps;
|
||||||
extern app_t apps[8];
|
extern app_t apps[16];
|
||||||
extern app_t *current_app;
|
extern app_t *current_app;
|
||||||
|
|
||||||
PACK(struct apdu {
|
PACK(struct apdu {
|
||||||
|
|||||||
11
src/main.c
11
src/main.c
@@ -49,7 +49,7 @@ extern void do_flash();
|
|||||||
extern void low_flash_init();
|
extern void low_flash_init();
|
||||||
extern void init_otp_files();
|
extern void init_otp_files();
|
||||||
|
|
||||||
app_t apps[8];
|
app_t apps[16];
|
||||||
uint8_t num_apps = 0;
|
uint8_t num_apps = 0;
|
||||||
|
|
||||||
app_t *current_app = NULL;
|
app_t *current_app = NULL;
|
||||||
@@ -57,11 +57,8 @@ app_t *current_app = NULL;
|
|||||||
const uint8_t *ccid_atr = NULL;
|
const uint8_t *ccid_atr = NULL;
|
||||||
|
|
||||||
bool app_exists(const uint8_t *aid, size_t aid_len) {
|
bool app_exists(const uint8_t *aid, size_t aid_len) {
|
||||||
if (current_app && current_app->aid && (current_app->aid + 1 == aid || !memcmp(current_app->aid + 1, aid, aid_len))) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
for (int a = 0; a < num_apps; a++) {
|
for (int a = 0; a < num_apps; a++) {
|
||||||
if (!memcmp(apps[a].aid + 1, aid, MIN(aid_len, apps[a].aid[0]))) {
|
if (apps[a].aid[0] == aid_len && !memcmp(apps[a].aid + 1, aid, MIN(aid_len, apps[a].aid[0]))) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -82,12 +79,12 @@ int register_app(int (*select_aid)(app_t *, uint8_t), const uint8_t *aid) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int select_app(const uint8_t *aid, size_t aid_len) {
|
int select_app(const uint8_t *aid, size_t aid_len) {
|
||||||
if (current_app && current_app->aid && (current_app->aid + 1 == aid || !memcmp(current_app->aid + 1, aid, MIN(current_app->aid[0], aid_len)))) {
|
if (current_app && current_app->aid && current_app->aid[0] == aid_len && (current_app->aid + 1 == aid || !memcmp(current_app->aid + 1, aid, MIN(current_app->aid[0], aid_len)))) {
|
||||||
current_app->select_aid(current_app, 0);
|
current_app->select_aid(current_app, 0);
|
||||||
return PICOKEY_OK;
|
return PICOKEY_OK;
|
||||||
}
|
}
|
||||||
for (int a = 0; a < num_apps; a++) {
|
for (int a = 0; a < num_apps; a++) {
|
||||||
if (!memcmp(apps[a].aid + 1, aid, MIN(aid_len, apps[a].aid[0]))) {
|
if (apps[a].aid[0] == aid_len && !memcmp(apps[a].aid + 1, aid, MIN(aid_len, apps[a].aid[0]))) {
|
||||||
if (current_app) {
|
if (current_app) {
|
||||||
if (current_app->aid && !memcmp(current_app->aid + 1, aid, MIN(current_app->aid[0], aid_len))) {
|
if (current_app->aid && !memcmp(current_app->aid + 1, aid, MIN(current_app->aid[0], aid_len))) {
|
||||||
current_app->select_aid(current_app, 1);
|
current_app->select_aid(current_app, 1);
|
||||||
|
|||||||
Reference in New Issue
Block a user