dev
Conor 2016-08-17 01:47:14 -04:00
rodzic 93abc20083
commit 1b7ee4742a
5 zmienionych plików z 45 dodań i 145 usunięć

Wyświetl plik

@ -71,6 +71,9 @@
#define U2F_SW_CLASS_NOT_SUPPORTED 0x6E00
#define U2F_SW_WRONG_PAYLOAD 0x6a80
// Delay in milliseconds to wait for user input
#define U2F_MS_USER_INPUT_WAIT 4850
struct u2f_request_apdu
{
uint8_t cla;

Wyświetl plik

@ -140,8 +140,6 @@ void rgb(uint8_t r, uint8_t g, uint8_t b)
int16_t main(void) {
uint32_t testd;
uint16_t eaddr;
uint16_t ms_heart;
uint16_t ms_wink;
uint16_t ms_grad;
@ -175,19 +173,6 @@ int16_t main(void) {
rgb_hex(0);
dump_hex(0xf800);
// void eeprom_read(uint16_t addr, uint8_t * buf, uint8_t len);
for(eaddr = 0xf800; eaddr < 0xfbbf+1; eaddr+=4)
{
eeprom_read(eaddr, &testd, 4);
u2f_putx((uint32_t) *((uint8_t*)&testd));
u2f_putx((uint32_t) *((uint8_t*)&testd+1));
u2f_putx((uint32_t) *((uint8_t*)&testd+2));
u2f_putx((uint32_t) *((uint8_t*)&testd+3));
}
while (1) {
watchdog();
@ -232,11 +217,11 @@ int16_t main(void) {
break;
case APP_HID_MSG:
// HID msg received, pass to protocols
// if (custom_command(hid_msg))
// {
//
// }
// else
if (custom_command(hid_msg))
{
}
else
{
u2f_hid_request(hid_msg);
}
@ -244,35 +229,35 @@ int16_t main(void) {
if (state == APP_HID_MSG)
state = APP_NOTHING;
break;
// case APP_WINK:
// // Do wink pattern for USB HID wink request
// rgb_hex(winkc);
// light = 1;
// ms_wink = get_ms();
// state = _APP_WINK;
// break;
// case _APP_WINK:
//
// if (ms_since(ms_wink,150))
// {
// if (light)
// {
// light = 0;
// rgb_hex(winkc);
// }
// else
// {
// light = 1;
// rgb_hex(0);
// }
// winks++;
// }
// if (winks == 5)
// {
// winks = 0;
// state = APP_NOTHING;
// }
// break;
case APP_WINK:
// Do wink pattern for USB HID wink request
rgb_hex(winkc);
light = 1;
ms_wink = get_ms();
state = _APP_WINK;
break;
case _APP_WINK:
if (ms_since(ms_wink,150))
{
if (light)
{
light = 0;
rgb_hex(winkc);
}
else
{
light = 1;
rgb_hex(0);
}
winks++;
}
if (winks == 5)
{
winks = 0;
state = APP_NOTHING;
}
break;
}
if (error)

Wyświetl plik

@ -52,9 +52,6 @@ void u2f_request(struct u2f_request_apdu * req)
uint16_t * rcode = (uint16_t *)req;
uint32_t len = ((req->LC3) | ((uint32_t)req->LC2 << 8) | ((uint32_t)req->LC1 << 16));
u2f_printlx("len:",1,len);
dump_hex(req,20);
u2f_response_start();
if (req->cla != 0)

Wyświetl plik

@ -219,7 +219,7 @@ int8_t u2f_get_user_feedback()
{ // yellow
rgb_hex(U2F_DEFAULT_COLOR_INPUT);
}
if (get_ms() - t > 4000)
if (get_ms() - t > U2F_MS_USER_INPUT_WAIT)
break;
watchdog();
}

Wyświetl plik

@ -80,7 +80,7 @@ static struct hid_layer_param
// total length of response in bytes
uint16_t res_len;
#define BUFFER_SIZE 210
#define BUFFER_SIZE 270
uint8_t buffer[BUFFER_SIZE];
} hid_layer;
@ -472,10 +472,8 @@ void u2f_hid_check_timeouts()
uint8_t i;
for(i = 0; i < CID_MAX; i++)
{
if (CIDS[i].busy && ((get_ms() - CIDS[i].last_used) >= 500))
if (CIDS[i].busy && ((get_ms() - CIDS[i].last_used) >= 750))
{
u2f_printlx("timeout cid ",2,CIDS[i].cid,get_ms());
stamp_error(CIDS[i].cid, ERR_MSG_TIMEOUT);
del_cid(CIDS[i].cid);
@ -488,13 +486,9 @@ void u2f_hid_check_timeouts()
void u2f_hid_request(struct u2f_hid_msg* req)
{
uint8_t* payload;
static int8_t last_seq;
struct CID* cid = NULL;
restart:
payload = req->pkt.init.payload;
cid = get_cid(req->cid);
// Error checking
@ -511,15 +505,12 @@ void u2f_hid_request(struct u2f_hid_msg* req)
return;
}
}
else
else if (cid == NULL || !cid->busy)
{
// do i need this?..
if (U2FHID_LEN(req) <= U2FHID_INIT_PAYLOAD_SIZE)
{
return;
}
// ignore random cont packets
return;
}
if (!req->cid)
{
stamp_error(req->cid, ERR_SYNC_FAIL);
@ -548,11 +539,7 @@ void u2f_hid_request(struct u2f_hid_msg* req)
}
cid->busy = 0;
}
else if (cid == NULL)
{
// ignore random cont packets
return;
}
@ -561,22 +548,13 @@ void u2f_hid_request(struct u2f_hid_msg* req)
{
cid->busy = 0;
}
else
{
}
u2f_printlx("got cid ",1,req->cid);
hid_layer.current_cid = req->cid;
hid_layer.last_buffered = get_ms();
cid->last_used = get_ms();
// ignore if we locked to a different cid
if(hid_is_locked() && req->pkt.init.cmd != U2FHID_INIT)
{
@ -614,69 +592,6 @@ void u2f_hid_request(struct u2f_hid_msg* req)
cid->busy = hid_u2f_parse(req);
// hid_layer.state = (u2f_hid_busy()) ? HID_BUSY : HID_READY;
//
// switch(hid_layer.state)
// {
// case HID_READY:
// if (req->pkt.init.cmd & TYPE_INIT)
// {
// if (U2FHID_LEN(req) > U2FHID_MAX_PAYLOAD_SIZE)
// {
// //u2f_prints("length too big\r\n");
// stamp_error(req->cid, ERR_INVALID_LEN);
// return;
// }
// u2f_hid_reset_packet();
// hid_layer.current_cid = req->cid;
// hid_layer.current_cmd = req->pkt.init.cmd;
// hid_layer.last_buffered = get_ms();
// last_seq = -1;
//
// }
// break;
// case HID_BUSY:
//
//
//
//
// // buffer long requests
// if (req->cid == hid_layer.current_cid)
// {
// if (req->pkt.init.cmd & TYPE_INIT)
// {
// u2f_hid_reset_packet();
// goto restart;
// }
//
//
//
//
//
// }
//// else if (U2FHID_TIMEOUT(&hid_layer))
//// {
//// // return timeout error for old channel and run again for new channel
//// //u2f_prints("timeout, switching\r\n");
//// hid_layer.state = HID_READY;
//// u2f_hid_reset_packet();
//// stamp_error(hid_layer.current_cid, ERR_MSG_TIMEOUT);
//// goto restart;
//// }
// else
// {
// // Current application may not be interrupted
// stamp_error(req->cid, ERR_CHANNEL_BUSY);
// return;
// }
// break;
//
// }
// hid_u2f_parse(req);
// return;
}
#endif