Enable U2F applet selection.

Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
Pol Henarejos 2023-04-02 00:00:09 +02:00
parent d87c1530c7
commit 415c1b2e9c
No known key found for this signature in database
GPG Key ID: C0095B7870A4CCD3
2 changed files with 50 additions and 7 deletions

View File

@ -23,6 +23,32 @@
#include "files.h"
#include "hid/ctap_hid.h"
const uint8_t u2f_aid[] = {
7,
0xA0, 0x00, 0x00, 0x05, 0x27, 0x10, 0x02
};
int u2f_unload();
int u2f_process_apdu();
app_t *u2f_select(app_t *a, const uint8_t *aid, uint8_t aid_len) {
if (!memcmp(aid, u2f_aid + 1, MIN(aid_len, u2f_aid[0]))) {
a->aid = u2f_aid;
a->process_apdu = u2f_process_apdu;
a->unload = u2f_unload;
return a;
}
return NULL;
}
void __attribute__((constructor)) u2f_ctor() {
register_app(u2f_select);
}
int u2f_unload() {
return CCID_OK;
}
const uint8_t *bogus_firefox =
(const uint8_t *)
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00";
@ -110,3 +136,27 @@ int cmd_register() {
ef_certdev_size + olen;
return SW_OK();
}
extern int cmd_register();
extern int cmd_authenticate();
extern int cmd_version();
static const cmd_t cmds[] = {
{ CTAP_REGISTER, cmd_register },
{ CTAP_AUTHENTICATE, cmd_authenticate },
{ CTAP_VERSION, cmd_version },
{ 0x00, 0x0 }
};
int u2f_process_apdu() {
if (CLA(apdu) != 0x00) {
return SW_CLA_NOT_SUPPORTED();
}
for (const cmd_t *cmd = cmds; cmd->ins != 0x00; cmd++) {
if (cmd->ins == INS(apdu)) {
int r = cmd->cmd_handler();
return r;
}
}
return SW_INS_NOT_SUPPORTED();
}

View File

@ -400,14 +400,7 @@ void set_opts(uint8_t opts) {
low_flash_available();
}
extern int cmd_register();
extern int cmd_authenticate();
extern int cmd_version();
static const cmd_t cmds[] = {
{ CTAP_REGISTER, cmd_register },
{ CTAP_AUTHENTICATE, cmd_authenticate },
{ CTAP_VERSION, cmd_version },
{ 0x00, 0x0 }
};