mirror of
https://github.com/polhenarejos/pico-keys-sdk
synced 2026-06-08 15:43:34 +02:00
Adding support for specific vendor HID command (0x41).
It is a self implementation, based on CBOR command. data[0] conveys the command and the contents mapped in CBOR encoding. The map uses the authConfig template, where the fist item in the map is the subcommand (enable/disable at this moment), the second is a map of the parameters, the third and fourth are the pinUvParam and pinUvProtocol. With this format only a single vendor HID command is necessary (0x41), which will be used for all my own commands, by using the command id in data[0] like with CBOR. Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
@@ -91,7 +91,6 @@ typedef struct {
|
|||||||
#define CTAPHID_ERROR (TYPE_INIT | 0x3F) // Error response
|
#define CTAPHID_ERROR (TYPE_INIT | 0x3F) // Error response
|
||||||
|
|
||||||
#define CTAPHID_VENDOR_FIRST (TYPE_INIT | 0x40) // First vendor defined command
|
#define CTAPHID_VENDOR_FIRST (TYPE_INIT | 0x40) // First vendor defined command
|
||||||
#define CTAPHID_VD_PROTECT (TYPE_INIT | 0x41) //
|
|
||||||
#define CTAPHID_VENDOR_LAST (TYPE_INIT | 0x7F) // Last vendor defined command
|
#define CTAPHID_VENDOR_LAST (TYPE_INIT | 0x7F) // Last vendor defined command
|
||||||
|
|
||||||
// CTAP_KEEPALIVE command defines
|
// CTAP_KEEPALIVE command defines
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
#include "bsp/board.h"
|
#include "bsp/board.h"
|
||||||
|
|
||||||
static bool mounted = false;
|
static bool mounted = false;
|
||||||
extern int cbor_process(const uint8_t *, size_t);
|
extern int cbor_process(uint8_t, const uint8_t *, size_t);
|
||||||
extern void init_fido(bool);
|
extern void init_fido(bool);
|
||||||
|
|
||||||
typedef struct msg_packet {
|
typedef struct msg_packet {
|
||||||
@@ -293,15 +293,15 @@ int driver_process_usb_packet(uint16_t read) {
|
|||||||
msg_packet.len = msg_packet.current_len = 0;
|
msg_packet.len = msg_packet.current_len = 0;
|
||||||
last_packet_time = 0;
|
last_packet_time = 0;
|
||||||
}
|
}
|
||||||
else if (last_cmd == CTAPHID_CBOR && (msg_packet.len == 0 || (msg_packet.len == msg_packet.current_len && msg_packet.len > 0))) {
|
else if ((last_cmd == CTAPHID_CBOR || (last_cmd >= CTAPHID_VENDOR_FIRST && last_cmd <= CTAPHID_VENDOR_LAST)) && (msg_packet.len == 0 || (msg_packet.len == msg_packet.current_len && msg_packet.len > 0))) {
|
||||||
|
|
||||||
if (thread_type != 2)
|
if (thread_type != 2)
|
||||||
card_start(cbor_thread);
|
card_start(cbor_thread);
|
||||||
thread_type = 2;
|
thread_type = 2;
|
||||||
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(msg_packet.data, msg_packet.len);
|
apdu_sent = cbor_process(last_cmd, msg_packet.data, msg_packet.len);
|
||||||
else
|
else
|
||||||
apdu_sent = cbor_process(ctap_req->init.data, MSG_LEN(ctap_req));
|
apdu_sent = cbor_process(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;
|
||||||
if (apdu_sent < 0)
|
if (apdu_sent < 0)
|
||||||
|
|||||||
Reference in New Issue
Block a user