void u2fhid_msg(const APDU *a, uint32_t len) { if ((APDU_LEN(*a) + sizeof(APDU)) > len) { debugLog(0, "", "BAD APDU LENGTH"); debugInt(APDU_LEN(*a)); debugInt(len); return; } if (a->cla != 0) { send_u2f_error(U2F_SW_CLA_NOT_SUPPORTED); return; } switch (a->ins) { case U2F_REGISTER: u2f_register(a); break; case U2F_AUTHENTICATE: u2f_authenticate(a); break; case U2F_VERSION: u2f_version(a); break; default: debugLog(0, "", "u2f unknown cmd"); send_u2f_error(U2F_SW_INS_NOT_SUPPORTED); } }
void u2f_request(struct u2f_request_apdu * req) { uint16_t * rcode = (uint16_t *)req; u2f_response_start(); switch(req->ins) { case U2F_REGISTER: *rcode = u2f_register((struct u2f_register_request*)req->payload); break; case U2F_AUTHENTICATE: *rcode = u2f_authenticate((struct u2f_authenticate_request*)req->payload, req->p1); break; case U2F_VERSION: *rcode = u2f_version(); break; case U2F_VENDOR_FIRST: break; case U2F_VENDOR_LAST: break; default: break; } u2f_response_writeback((uint8_t*)rcode + 1, 1); u2f_response_writeback((uint8_t*)rcode, 1); u2f_response_flush(); }