u2f auth works

This commit is contained in:
merlokk
2019-01-28 00:04:17 +02:00
parent f24058d2e8
commit cce25b2a1c
2 changed files with 16 additions and 7 deletions

View File

@ -31,7 +31,7 @@
// void u2f_response_writeback(uint8_t * buf, uint8_t len); // void u2f_response_writeback(uint8_t * buf, uint8_t len);
static int16_t u2f_register(struct u2f_register_request * req, bool fromNFC); static int16_t u2f_register(struct u2f_register_request * req, bool fromNFC);
static int16_t u2f_authenticate(struct u2f_authenticate_request * req, uint8_t control); static int16_t u2f_authenticate(struct u2f_authenticate_request * req, uint8_t control, bool fromNFC);
int8_t u2f_response_writeback(const uint8_t * buf, uint16_t len); int8_t u2f_response_writeback(const uint8_t * buf, uint16_t len);
void u2f_reset_response(); void u2f_reset_response();
@ -78,7 +78,7 @@ void u2f_request_ex(APDU_HEADER *req, uint8_t *payload, uint32_t len, CTAP_RESPO
case U2F_AUTHENTICATE: case U2F_AUTHENTICATE:
printf1(TAG_U2F, "U2F_AUTHENTICATE\n"); printf1(TAG_U2F, "U2F_AUTHENTICATE\n");
t1 = millis(); t1 = millis();
rcode = u2f_authenticate((struct u2f_authenticate_request*)payload, req->p1); rcode = u2f_authenticate((struct u2f_authenticate_request*)payload, req->p1, fromNFC);
t2 = millis(); t2 = millis();
printf1(TAG_TIME,"u2f_authenticate time: %d ms\n", t2-t1); printf1(TAG_TIME,"u2f_authenticate time: %d ms\n", t2-t1);
break; break;
@ -213,7 +213,7 @@ static int8_t u2f_appid_eq(struct u2f_key_handle * kh, uint8_t * appid)
static int16_t u2f_authenticate(struct u2f_authenticate_request * req, uint8_t control) static int16_t u2f_authenticate(struct u2f_authenticate_request * req, uint8_t control, bool fromNFC)
{ {
uint8_t up = 1; uint8_t up = 1;
@ -245,10 +245,13 @@ static int16_t u2f_authenticate(struct u2f_authenticate_request * req, uint8_t c
if(!fromNFC)
{
if (ctap_user_presence_test() == 0) if (ctap_user_presence_test() == 0)
{ {
return U2F_SW_CONDITIONS_NOT_SATISFIED; return U2F_SW_CONDITIONS_NOT_SATISFIED;
} }
}
count = ctap_atomic_count(0); count = ctap_atomic_count(0);

View File

@ -356,7 +356,13 @@ void nfc_process_iblock(uint8_t * buf, int len)
return; return;
} }
t1 = millis();
u2f_request_nfc(&buf[1], len, &ctap_resp); u2f_request_nfc(&buf[1], len, &ctap_resp);
printf1(TAG_NFC, "U2F resp len: %d\r\n", ctap_resp.length);
printf1(TAG_NFC,"U2F Authenticate processing %d (took %d)\r\n", millis(), millis() - t1);
nfc_write_response_chaining(buf[0], ctap_resp.data, ctap_resp.length);
printf1(TAG_NFC,"U2F Authenticate answered %d (took %d)\r\n", millis(), millis() - t1);
break; break;
case APDU_FIDO_NFCCTAP_MSG: case APDU_FIDO_NFCCTAP_MSG: