u2f register works
This commit is contained in:
parent
a662a9a619
commit
3eddfbf8a9
@ -670,7 +670,7 @@ uint8_t ctaphid_handle_packet(uint8_t * pkt_raw)
|
|||||||
}
|
}
|
||||||
is_busy = 1;
|
is_busy = 1;
|
||||||
ctap_response_init(&ctap_resp);
|
ctap_response_init(&ctap_resp);
|
||||||
u2f_request((struct u2f_request_apdu*)ctap_buffer, &ctap_resp);
|
u2f_request((struct u2f_request_apdu*)ctap_buffer, &ctap_resp, false);
|
||||||
|
|
||||||
ctaphid_write_buffer_init(&wb);
|
ctaphid_write_buffer_init(&wb);
|
||||||
wb.cid = cid;
|
wb.cid = cid;
|
||||||
|
19
fido2/u2f.c
19
fido2/u2f.c
@ -29,7 +29,7 @@
|
|||||||
#include APP_CONFIG
|
#include APP_CONFIG
|
||||||
|
|
||||||
// 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);
|
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);
|
||||||
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();
|
||||||
@ -37,7 +37,7 @@ void u2f_reset_response();
|
|||||||
|
|
||||||
static CTAP_RESPONSE * _u2f_resp = NULL;
|
static CTAP_RESPONSE * _u2f_resp = NULL;
|
||||||
|
|
||||||
void u2f_request(struct u2f_request_apdu* req, CTAP_RESPONSE * resp)
|
void u2f_request(struct u2f_request_apdu* req, CTAP_RESPONSE * resp, bool fromNFC)
|
||||||
{
|
{
|
||||||
uint16_t rcode = 0;
|
uint16_t rcode = 0;
|
||||||
uint64_t t1,t2;
|
uint64_t t1,t2;
|
||||||
@ -69,7 +69,7 @@ void u2f_request(struct u2f_request_apdu* req, CTAP_RESPONSE * resp)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
t1 = millis();
|
t1 = millis();
|
||||||
rcode = u2f_register((struct u2f_register_request*)req->payload);
|
rcode = u2f_register((struct u2f_register_request*)req->payload, fromNFC);
|
||||||
t2 = millis();
|
t2 = millis();
|
||||||
printf1(TAG_TIME,"u2f_register time: %d ms\n", t2-t1);
|
printf1(TAG_TIME,"u2f_register time: %d ms\n", t2-t1);
|
||||||
}
|
}
|
||||||
@ -254,7 +254,7 @@ static int16_t u2f_authenticate(struct u2f_authenticate_request * req, uint8_t c
|
|||||||
return U2F_SW_NO_ERROR;
|
return U2F_SW_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int16_t u2f_register(struct u2f_register_request * req)
|
static int16_t u2f_register(struct u2f_register_request * req, bool fromNFC)
|
||||||
{
|
{
|
||||||
uint8_t i[] = {0x0,U2F_EC_FMT_UNCOMPRESSED};
|
uint8_t i[] = {0x0,U2F_EC_FMT_UNCOMPRESSED};
|
||||||
|
|
||||||
@ -266,10 +266,13 @@ static int16_t u2f_register(struct u2f_register_request * req)
|
|||||||
|
|
||||||
const uint16_t attest_size = attestation_cert_der_size;
|
const uint16_t attest_size = attestation_cert_der_size;
|
||||||
|
|
||||||
if ( ! ctap_user_presence_test())
|
if(!fromNFC)
|
||||||
{
|
{
|
||||||
return U2F_SW_CONDITIONS_NOT_SATISFIED;
|
if ( ! ctap_user_presence_test())
|
||||||
}
|
{
|
||||||
|
return U2F_SW_CONDITIONS_NOT_SATISFIED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( u2f_new_keypair(&key_handle, req->app, pubkey) == -1)
|
if ( u2f_new_keypair(&key_handle, req->app, pubkey) == -1)
|
||||||
{
|
{
|
||||||
|
@ -111,7 +111,7 @@ struct u2f_authenticate_request
|
|||||||
|
|
||||||
// u2f_request send a U2F message to U2F protocol
|
// u2f_request send a U2F message to U2F protocol
|
||||||
// @req U2F message
|
// @req U2F message
|
||||||
void u2f_request(struct u2f_request_apdu* req, CTAP_RESPONSE * resp);
|
void u2f_request(struct u2f_request_apdu* req, CTAP_RESPONSE * resp, 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);
|
||||||
|
@ -340,7 +340,7 @@ void nfc_process_iblock(uint8_t * buf, int len)
|
|||||||
memcpy(&u2fbuffer[6], &buf[5], plen + 1);
|
memcpy(&u2fbuffer[6], &buf[5], plen + 1);
|
||||||
|
|
||||||
ctap_response_init(&ctap_resp);
|
ctap_response_init(&ctap_resp);
|
||||||
u2f_request((struct u2f_request_apdu *)u2fbuffer, &ctap_resp);
|
u2f_request((struct u2f_request_apdu *)u2fbuffer, &ctap_resp, true);
|
||||||
|
|
||||||
printf1(TAG_NFC, "U2F resp len: %d\r\n", ctap_resp.length);
|
printf1(TAG_NFC, "U2F resp len: %d\r\n", ctap_resp.length);
|
||||||
nfc_write_response_chaining(buf[0], ctap_resp.data, ctap_resp.length);
|
nfc_write_response_chaining(buf[0], ctap_resp.data, ctap_resp.length);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user