mirror of
https://github.com/polhenarejos/pico-keys-sdk
synced 2026-06-11 12:58:14 +02:00
Move some functions from HID to fido callbacks.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
@@ -26,11 +26,11 @@
|
|||||||
#include "usb.h"
|
#include "usb.h"
|
||||||
|
|
||||||
static bool mounted = false;
|
static bool mounted = false;
|
||||||
extern int cbor_process(uint8_t, const uint8_t *, size_t);
|
void (*init_fido_cb)() = NULL;
|
||||||
extern void init_fido();
|
|
||||||
bool is_nitrokey = false;
|
bool is_nitrokey = false;
|
||||||
uint8_t (*get_version_major)() = NULL;
|
uint8_t (*get_version_major)() = NULL;
|
||||||
uint8_t (*get_version_minor)() = NULL;
|
uint8_t (*get_version_minor)() = NULL;
|
||||||
|
int (*cbor_process_cb)(uint8_t, const uint8_t *, size_t) = NULL;
|
||||||
|
|
||||||
typedef struct msg_packet {
|
typedef struct msg_packet {
|
||||||
uint16_t len;
|
uint16_t len;
|
||||||
@@ -276,7 +276,7 @@ CTAPHID_FRAME last_req = { 0 };
|
|||||||
uint32_t lock = 0;
|
uint32_t lock = 0;
|
||||||
|
|
||||||
uint8_t thread_type = 0; //1 is APDU, 2 is CBOR
|
uint8_t thread_type = 0; //1 is APDU, 2 is CBOR
|
||||||
extern void cbor_thread();
|
void (*cbor_thread_func)() = NULL;
|
||||||
extern bool cancel_button;
|
extern bool cancel_button;
|
||||||
|
|
||||||
int driver_process_usb_nopacket_hid() {
|
int driver_process_usb_nopacket_hid() {
|
||||||
@@ -288,7 +288,7 @@ int driver_process_usb_nopacket_hid() {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern const uint8_t fido_aid[];
|
const uint8_t *fido_aid = NULL;
|
||||||
|
|
||||||
int driver_process_usb_packet_hid(uint16_t read) {
|
int driver_process_usb_packet_hid(uint16_t read) {
|
||||||
int apdu_sent = 0;
|
int apdu_sent = 0;
|
||||||
@@ -352,7 +352,9 @@ int driver_process_usb_packet_hid(uint16_t read) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ctap_req->init.cmd == CTAPHID_INIT) {
|
if (ctap_req->init.cmd == CTAPHID_INIT) {
|
||||||
init_fido();
|
if (init_fido_cb) {
|
||||||
|
init_fido_cb();
|
||||||
|
}
|
||||||
ctap_resp = (CTAPHID_FRAME *) usb_get_tx(ITF_HID);
|
ctap_resp = (CTAPHID_FRAME *) usb_get_tx(ITF_HID);
|
||||||
memset(ctap_resp, 0, 64);
|
memset(ctap_resp, 0, 64);
|
||||||
CTAPHID_INIT_REQ *req = (CTAPHID_INIT_REQ *) ctap_req->init.data;
|
CTAPHID_INIT_REQ *req = (CTAPHID_INIT_REQ *) ctap_req->init.data;
|
||||||
@@ -506,14 +508,16 @@ int driver_process_usb_packet_hid(uint16_t read) {
|
|||||||
|
|
||||||
//if (thread_type != 2)
|
//if (thread_type != 2)
|
||||||
#ifndef ENABLE_EMULATION
|
#ifndef ENABLE_EMULATION
|
||||||
card_start(cbor_thread);
|
card_start(cbor_thread_func);
|
||||||
#endif
|
#endif
|
||||||
thread_type = 2;
|
thread_type = 2;
|
||||||
|
if (cbor_process_cb) {
|
||||||
if (msg_packet.current_len == msg_packet.len && msg_packet.len > 0) {
|
if (msg_packet.current_len == msg_packet.len && msg_packet.len > 0) {
|
||||||
apdu_sent = cbor_process(last_cmd, msg_packet.data, msg_packet.len);
|
apdu_sent = cbor_process_cb(last_cmd, msg_packet.data, msg_packet.len);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
apdu_sent = cbor_process(last_cmd, ctap_req->init.data, MSG_LEN(ctap_req));
|
apdu_sent = cbor_process_cb(last_cmd, ctap_req->init.data, MSG_LEN(ctap_req));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
msg_packet.len = msg_packet.current_len = 0;
|
msg_packet.len = msg_packet.current_len = 0;
|
||||||
last_packet_time = 0;
|
last_packet_time = 0;
|
||||||
|
|||||||
@@ -233,7 +233,9 @@ void card_start(void (*func)(void)) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
multicore_reset_core1();
|
multicore_reset_core1();
|
||||||
|
if (func) {
|
||||||
multicore_launch_core1(func);
|
multicore_launch_core1(func);
|
||||||
|
}
|
||||||
led_set_blink(BLINK_MOUNTED);
|
led_set_blink(BLINK_MOUNTED);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user