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:
parent
e6c0227996
commit
ed848d005f
2 changed files with 5 additions and 8 deletions
|
|
@ -44,7 +44,7 @@ typedef struct cmd {
|
|||
} cmd_t;
|
||||
|
||||
extern uint8_t num_apps;
|
||||
extern app_t apps[8];
|
||||
extern app_t apps[16];
|
||||
extern app_t *current_app;
|
||||
|
||||
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 init_otp_files();
|
||||
|
||||
app_t apps[8];
|
||||
app_t apps[16];
|
||||
uint8_t num_apps = 0;
|
||||
|
||||
app_t *current_app = NULL;
|
||||
|
|
@ -57,11 +57,8 @@ app_t *current_app = NULL;
|
|||
const uint8_t *ccid_atr = NULL;
|
||||
|
||||
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++) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
@ -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) {
|
||||
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);
|
||||
return PICOKEY_OK;
|
||||
}
|
||||
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->aid && !memcmp(current_app->aid + 1, aid, MIN(current_app->aid[0], aid_len))) {
|
||||
current_app->select_aid(current_app, 1);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue