Added CBOR processing.

Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
Pol Henarejos 2022-09-08 20:37:21 +02:00
parent 7aeac46eef
commit abd52c34ba
No known key found for this signature in database
GPG key ID: C0095B7870A4CCD3
2 changed files with 30 additions and 0 deletions

View file

@ -93,6 +93,15 @@ typedef struct {
#define CTAPHID_VENDOR_FIRST (TYPE_INIT | 0x40) // First vendor defined command
#define CTAPHID_VENDOR_LAST (TYPE_INIT | 0x7F) // Last vendor defined command
// CTAP CBOR commands
#define CTAP_MAKE_CREDENTIAL 0x01
#define CTAP_GET_ASSERTION 0x02
#define CTAP_GET_INFO 0x04
#define CTAP_CLIENT_PIN 0x06
#define CTAP_RESET 0x07
#define CTAP_GET_NEXT_ASSERTION 0x08
// CTAP_KEEPALIVE command defines
#define KEEPALIVE_STATUS_PROCESSING 0x1

View file

@ -142,6 +142,18 @@ uint8_t last_seq = 0;
CTAPHID_FRAME last_req = { 0 };
uint32_t lock = 0;
int cbor_make_credential(const uint8_t *data, size_t len) {
return 0;
}
int cbor_process(const uint8_t *data, size_t len) {
if (len == 0)
return -ERR_INVALID_LEN;
if (data[0] == CTAP_MAKE_CREDENTIAL)
return cbor_make_credential(data + 1, len - 1);
return 0;
}
int driver_process_usb_packet(uint16_t read) {
int apdu_sent = 0;
if (read >= 5)
@ -239,6 +251,15 @@ int driver_process_usb_packet(uint16_t read) {
DEBUG_PAYLOAD(apdu.data, (int)apdu.nc);
msg_packet.len = msg_packet.current_len = 0; //Reset the transaction
}
else if ((ctap_req->init.cmd == CTAPHID_CBOR && msg_packet.len == 0) || (msg_packet.len == msg_packet.current_len && msg_packet.len > 0)) {
if (msg_packet.current_len == msg_packet.len && msg_packet.len > 0)
apdu_sent = cbor_process(msg_packet.data, msg_packet.len);
else
apdu_sent = cbor_process(ctap_req->init.data, MSG_LEN(ctap_req));
msg_packet.len = msg_packet.current_len = 0; //Reset the transaction
if (apdu_sent < 0)
return ctap_error(-apdu_sent);
}
else {
if (msg_packet.len == 0)
return ctap_error(ERR_INVALID_CMD);