passing u2f usbhid test
This commit is contained in:
parent
898a7a303c
commit
80842dab29
@ -223,7 +223,6 @@ static int buffer_packet(CTAPHID_PACKET * pkt)
|
|||||||
|
|
||||||
static void buffer_reset()
|
static void buffer_reset()
|
||||||
{
|
{
|
||||||
|
|
||||||
ctap_buffer_bcnt = 0;
|
ctap_buffer_bcnt = 0;
|
||||||
ctap_buffer_offset = 0;
|
ctap_buffer_offset = 0;
|
||||||
ctap_packet_seq = 0;
|
ctap_packet_seq = 0;
|
||||||
@ -363,7 +362,12 @@ void ctaphid_check_timeouts()
|
|||||||
{
|
{
|
||||||
printf1(TAG_HID, "TIMEOUT CID: %08x\n", CIDS[i].cid);
|
printf1(TAG_HID, "TIMEOUT CID: %08x\n", CIDS[i].cid);
|
||||||
ctaphid_send_error(CIDS[i].cid, CTAP1_ERR_TIMEOUT);
|
ctaphid_send_error(CIDS[i].cid, CTAP1_ERR_TIMEOUT);
|
||||||
memset(CIDS + i, 0, sizeof(struct CID));
|
CIDS[i].busy = 0;
|
||||||
|
if (CIDS[i].cid == buffer_cid())
|
||||||
|
{
|
||||||
|
buffer_reset();
|
||||||
|
}
|
||||||
|
// memset(CIDS + i, 0, sizeof(struct CID));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -447,12 +451,20 @@ static int ctaphid_buffer_packet(uint8_t * pkt_raw, uint8_t * cmd, uint32_t * ci
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Check if matches existing CID
|
|
||||||
if (pkt->cid == CTAPHID_BROADCAST_CID)
|
if (pkt->cid == CTAPHID_BROADCAST_CID)
|
||||||
{
|
{
|
||||||
*cmd = CTAP1_ERR_INVALID_CHANNEL;
|
*cmd = CTAP1_ERR_INVALID_CHANNEL;
|
||||||
return HID_ERROR;
|
return HID_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (! cid_exists(pkt->cid) && ! is_cont_pkt(pkt))
|
||||||
|
{
|
||||||
|
if (buffer_status() == EMPTY)
|
||||||
|
{
|
||||||
|
add_cid(pkt->cid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (cid_exists(pkt->cid))
|
if (cid_exists(pkt->cid))
|
||||||
{
|
{
|
||||||
if (buffer_status() == BUFFERING)
|
if (buffer_status() == BUFFERING)
|
||||||
@ -465,11 +477,19 @@ static int ctaphid_buffer_packet(uint8_t * pkt_raw, uint8_t * cmd, uint32_t * ci
|
|||||||
return HID_ERROR;
|
return HID_ERROR;
|
||||||
}
|
}
|
||||||
else if (pkt->cid != buffer_cid())
|
else if (pkt->cid != buffer_cid())
|
||||||
|
{
|
||||||
|
if (! is_cont_pkt(pkt))
|
||||||
{
|
{
|
||||||
printf2(TAG_ERR,"BUSY with %08x\n", buffer_cid());
|
printf2(TAG_ERR,"BUSY with %08x\n", buffer_cid());
|
||||||
*cmd = CTAP1_ERR_CHANNEL_BUSY;
|
*cmd = CTAP1_ERR_CHANNEL_BUSY;
|
||||||
return HID_ERROR;
|
return HID_ERROR;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf2(TAG_ERR,"ignoring random cont packet from %04x\n",pkt->cid);
|
||||||
|
return HID_IGNORE;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (! is_cont_pkt(pkt))
|
if (! is_cont_pkt(pkt))
|
||||||
{
|
{
|
||||||
@ -484,10 +504,11 @@ static int ctaphid_buffer_packet(uint8_t * pkt_raw, uint8_t * cmd, uint32_t * ci
|
|||||||
{
|
{
|
||||||
if (buffer_status() == EMPTY || pkt->cid != buffer_cid())
|
if (buffer_status() == EMPTY || pkt->cid != buffer_cid())
|
||||||
{
|
{
|
||||||
printf2(TAG_ERR,"ignoring random cont packet\n");
|
printf2(TAG_ERR,"ignoring random cont packet from %04x\n",pkt->cid);
|
||||||
return HID_IGNORE;
|
return HID_IGNORE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buffer_packet(pkt) == SEQUENCE_ERROR)
|
if (buffer_packet(pkt) == SEQUENCE_ERROR)
|
||||||
{
|
{
|
||||||
printf2(TAG_ERR,"Buffering sequence error\n");
|
printf2(TAG_ERR,"Buffering sequence error\n");
|
||||||
@ -544,7 +565,10 @@ uint8_t ctaphid_handle_packet(uint8_t * pkt_raw)
|
|||||||
if (bufstatus == HID_ERROR)
|
if (bufstatus == HID_ERROR)
|
||||||
{
|
{
|
||||||
cid_del(cid);
|
cid_del(cid);
|
||||||
|
if (cmd == CTAP1_ERR_INVALID_SEQ)
|
||||||
|
{
|
||||||
buffer_reset();
|
buffer_reset();
|
||||||
|
}
|
||||||
ctaphid_send_error(cid, cmd);
|
ctaphid_send_error(cid, cmd);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@
|
|||||||
#define HID_DESCRIPTOR_TYPE 0x21U
|
#define HID_DESCRIPTOR_TYPE 0x21U
|
||||||
#define HID_REPORT_DESC 0x22U
|
#define HID_REPORT_DESC 0x22U
|
||||||
|
|
||||||
#define HID_BINTERVAL 10
|
#define HID_BINTERVAL 5
|
||||||
|
|
||||||
#define HID_REQ_SET_PROTOCOL 0x0BU
|
#define HID_REQ_SET_PROTOCOL 0x0BU
|
||||||
#define HID_REQ_GET_PROTOCOL 0x03U
|
#define HID_REQ_GET_PROTOCOL 0x03U
|
||||||
|
@ -68,7 +68,7 @@ void crypto_load_master_secret(uint8_t * key)
|
|||||||
void crypto_reset_master_secret()
|
void crypto_reset_master_secret()
|
||||||
{
|
{
|
||||||
memset(master_secret, 0, 64);
|
memset(master_secret, 0, 64);
|
||||||
memset(transport_secret, 0, 64);
|
memset(transport_secret, 0, 32);
|
||||||
ctap_generate_rng(master_secret, 64);
|
ctap_generate_rng(master_secret, 64);
|
||||||
ctap_generate_rng(transport_secret, 32);
|
ctap_generate_rng(transport_secret, 32);
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ void TIM6_DAC_IRQHandler()
|
|||||||
// timer is only 16 bits, so roll it over here
|
// timer is only 16 bits, so roll it over here
|
||||||
TIM6->SR = 0;
|
TIM6->SR = 0;
|
||||||
__90_ms += 1;
|
__90_ms += 1;
|
||||||
if ((millis() - __last_update) > 5)
|
if ((millis() - __last_update) > 8)
|
||||||
{
|
{
|
||||||
if (__device_status != CTAPHID_STATUS_IDLE)
|
if (__device_status != CTAPHID_STATUS_IDLE)
|
||||||
{
|
{
|
||||||
@ -376,8 +376,6 @@ do
|
|||||||
{
|
{
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
if (! IS_BUTTON_PRESSED())
|
|
||||||
continue;
|
|
||||||
delay(1);
|
delay(1);
|
||||||
ret = handle_packets();
|
ret = handle_packets();
|
||||||
if (ret) return ret;
|
if (ret) return ret;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user