replace macros with DEBUG_LEVEL aware timestamp function
This commit is contained in:
parent
e7e83820a9
commit
831976f3a2
21
fido2/ctap.c
21
fido2/ctap.c
@ -1359,9 +1359,6 @@ uint8_t ctap_request(uint8_t * pkt_raw, int length, CTAP_RESPONSE * resp)
|
|||||||
CborEncoder encoder;
|
CborEncoder encoder;
|
||||||
uint8_t status = 0;
|
uint8_t status = 0;
|
||||||
uint8_t cmd = *pkt_raw;
|
uint8_t cmd = *pkt_raw;
|
||||||
#if DEBUG_LEVEL > 0
|
|
||||||
uint64_t t1,t2;
|
|
||||||
#endif
|
|
||||||
pkt_raw++;
|
pkt_raw++;
|
||||||
length--;
|
length--;
|
||||||
|
|
||||||
@ -1394,14 +1391,9 @@ uint8_t ctap_request(uint8_t * pkt_raw, int length, CTAP_RESPONSE * resp)
|
|||||||
case CTAP_MAKE_CREDENTIAL:
|
case CTAP_MAKE_CREDENTIAL:
|
||||||
device_set_status(CTAPHID_STATUS_PROCESSING);
|
device_set_status(CTAPHID_STATUS_PROCESSING);
|
||||||
printf1(TAG_CTAP,"CTAP_MAKE_CREDENTIAL\n");
|
printf1(TAG_CTAP,"CTAP_MAKE_CREDENTIAL\n");
|
||||||
#if DEBUG_LEVEL > 0
|
timestamp();
|
||||||
t1 = millis();
|
|
||||||
#endif
|
|
||||||
status = ctap_make_credential(&encoder, pkt_raw, length);
|
status = ctap_make_credential(&encoder, pkt_raw, length);
|
||||||
#if DEBUG_LEVEL > 0
|
printf1(TAG_TIME,"make_credential time: %d ms\n", timestamp());
|
||||||
t2 = millis();
|
|
||||||
printf1(TAG_TIME,"make_credential time: %d ms\n", t2-t1);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
resp->length = cbor_encoder_get_buffer_size(&encoder, buf);
|
resp->length = cbor_encoder_get_buffer_size(&encoder, buf);
|
||||||
dump_hex1(TAG_DUMP, buf, resp->length);
|
dump_hex1(TAG_DUMP, buf, resp->length);
|
||||||
@ -1410,14 +1402,9 @@ uint8_t ctap_request(uint8_t * pkt_raw, int length, CTAP_RESPONSE * resp)
|
|||||||
case CTAP_GET_ASSERTION:
|
case CTAP_GET_ASSERTION:
|
||||||
device_set_status(CTAPHID_STATUS_PROCESSING);
|
device_set_status(CTAPHID_STATUS_PROCESSING);
|
||||||
printf1(TAG_CTAP,"CTAP_GET_ASSERTION\n");
|
printf1(TAG_CTAP,"CTAP_GET_ASSERTION\n");
|
||||||
#if DEBUG_LEVEL > 0
|
timestamp();
|
||||||
t1 = millis();
|
|
||||||
#endif
|
|
||||||
status = ctap_get_assertion(&encoder, pkt_raw, length);
|
status = ctap_get_assertion(&encoder, pkt_raw, length);
|
||||||
#if DEBUG_LEVEL > 0
|
printf1(TAG_TIME,"get_assertion time: %d ms\n", timestamp());
|
||||||
t2 = millis();
|
|
||||||
printf1(TAG_TIME,"get_assertion time: %d ms\n", t2-t1);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
resp->length = cbor_encoder_get_buffer_size(&encoder, buf);
|
resp->length = cbor_encoder_get_buffer_size(&encoder, buf);
|
||||||
|
|
||||||
|
@ -541,14 +541,6 @@ uint8_t ctaphid_handle_packet(uint8_t * pkt_raw)
|
|||||||
static CTAPHID_WRITE_BUFFER wb;
|
static CTAPHID_WRITE_BUFFER wb;
|
||||||
CTAP_RESPONSE ctap_resp;
|
CTAP_RESPONSE ctap_resp;
|
||||||
|
|
||||||
#ifndef DISABLE_CTAPHID_PING
|
|
||||||
#ifndef DISABLE_CTAPHID_CBOR
|
|
||||||
#if DEBUG_LEVEL > 0
|
|
||||||
uint32_t t1,t2;
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int bufstatus = ctaphid_buffer_packet(pkt_raw, &cmd, &cid, &len);
|
int bufstatus = ctaphid_buffer_packet(pkt_raw, &cmd, &cid, &len);
|
||||||
|
|
||||||
if (bufstatus == HID_IGNORE)
|
if (bufstatus == HID_IGNORE)
|
||||||
@ -589,15 +581,11 @@ uint8_t ctaphid_handle_packet(uint8_t * pkt_raw)
|
|||||||
wb.cid = cid;
|
wb.cid = cid;
|
||||||
wb.cmd = CTAPHID_PING;
|
wb.cmd = CTAPHID_PING;
|
||||||
wb.bcnt = len;
|
wb.bcnt = len;
|
||||||
#if DEBUG_LEVEL > 0
|
timestamp();
|
||||||
t1 = millis();
|
|
||||||
#endif
|
|
||||||
ctaphid_write(&wb, ctap_buffer, len);
|
ctaphid_write(&wb, ctap_buffer, len);
|
||||||
ctaphid_write(&wb, NULL,0);
|
ctaphid_write(&wb, NULL,0);
|
||||||
#if DEBUG_LEVEL > 0
|
printf1(TAG_TIME,"PING writeback: %d ms\n",timestamp());
|
||||||
t2 = millis();
|
|
||||||
printf1(TAG_TIME,"PING writeback: %d ms\n",(uint32_t)(t2-t1));
|
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
#ifndef DISABLE_CTAPHID_WINK
|
#ifndef DISABLE_CTAPHID_WINK
|
||||||
@ -641,16 +629,11 @@ uint8_t ctaphid_handle_packet(uint8_t * pkt_raw)
|
|||||||
wb.bcnt = (ctap_resp.length+1);
|
wb.bcnt = (ctap_resp.length+1);
|
||||||
|
|
||||||
|
|
||||||
#if DEBUG_LEVEL > 0
|
timestamp();
|
||||||
t1 = millis();
|
|
||||||
#endif
|
|
||||||
ctaphid_write(&wb, &status, 1);
|
ctaphid_write(&wb, &status, 1);
|
||||||
ctaphid_write(&wb, ctap_resp.data, ctap_resp.length);
|
ctaphid_write(&wb, ctap_resp.data, ctap_resp.length);
|
||||||
ctaphid_write(&wb, NULL, 0);
|
ctaphid_write(&wb, NULL, 0);
|
||||||
#if DEBUG_LEVEL > 0
|
printf1(TAG_TIME,"CBOR writeback: %d ms\n",timestamp());
|
||||||
t2 = millis();
|
|
||||||
printf1(TAG_TIME,"CBOR writeback: %d ms\n",(uint32_t)(t2-t1));
|
|
||||||
#endif
|
|
||||||
is_busy = 0;
|
is_busy = 0;
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
@ -34,13 +34,11 @@
|
|||||||
int16_t bridge_u2f_to_solo(uint8_t * _chal, uint8_t * _appid, uint8_t klen, uint8_t * keyh)
|
int16_t bridge_u2f_to_solo(uint8_t * _chal, uint8_t * _appid, uint8_t klen, uint8_t * keyh)
|
||||||
{
|
{
|
||||||
static uint8_t msg_buf[72];
|
static uint8_t msg_buf[72];
|
||||||
int reqlen = klen;
|
|
||||||
int i;
|
|
||||||
int8_t ret = 0;
|
int8_t ret = 0;
|
||||||
|
|
||||||
wallet_request * req = (wallet_request *) keyh;
|
wallet_request * req = (wallet_request *) keyh;
|
||||||
|
|
||||||
printf1(TAG_WALLET, "u2f-solo [%d]: ", reqlen); dump_hex1(TAG_WALLET, keyh, reqlen);
|
printf1(TAG_WALLET, "u2f-solo [%d]: ", reqlen); dump_hex1(TAG_WALLET, keyh, klen);
|
||||||
|
|
||||||
switch(req->operation)
|
switch(req->operation)
|
||||||
{
|
{
|
||||||
|
11
fido2/log.c
11
fido2/log.c
@ -9,6 +9,7 @@
|
|||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
#include "device.h"
|
||||||
|
|
||||||
#if DEBUG_LEVEL > 0
|
#if DEBUG_LEVEL > 0
|
||||||
|
|
||||||
@ -99,4 +100,14 @@ void LOG_HEX(uint32_t tag, uint8_t * data, int length)
|
|||||||
set_logging_tag(tag);
|
set_logging_tag(tag);
|
||||||
dump_hex(data,length);
|
dump_hex(data,length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t timestamp()
|
||||||
|
{
|
||||||
|
static uint32_t t1 = 0;
|
||||||
|
uint32_t t2 = millis();
|
||||||
|
uint32_t diff = t2 - t1;
|
||||||
|
t1 = t2;
|
||||||
|
return t2;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -55,6 +55,8 @@ void set_logging_mask(uint32_t mask);
|
|||||||
|
|
||||||
#define dump_hex1(tag,data,len) LOG_HEX(tag,data,len)
|
#define dump_hex1(tag,data,len) LOG_HEX(tag,data,len)
|
||||||
|
|
||||||
|
uint32_t timestamp();
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#define set_logging_mask(mask)
|
#define set_logging_mask(mask)
|
||||||
@ -62,6 +64,7 @@ void set_logging_mask(uint32_t mask);
|
|||||||
#define printf2(tag,fmt, ...)
|
#define printf2(tag,fmt, ...)
|
||||||
#define printf3(tag,fmt, ...)
|
#define printf3(tag,fmt, ...)
|
||||||
#define dump_hex1(tag,data,len)
|
#define dump_hex1(tag,data,len)
|
||||||
|
#define timestamp()
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
25
fido2/u2f.c
25
fido2/u2f.c
@ -30,11 +30,6 @@ 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)
|
||||||
{
|
{
|
||||||
uint16_t rcode = 0;
|
uint16_t rcode = 0;
|
||||||
#ifdef ENABLE_U2F
|
|
||||||
#if DEBUG_LEVEL > 0
|
|
||||||
uint64_t t1,t2;
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
uint32_t len = ((req->LC3) | ((uint32_t)req->LC2 << 8) | ((uint32_t)req->LC1 << 16));
|
uint32_t len = ((req->LC3) | ((uint32_t)req->LC2 << 8) | ((uint32_t)req->LC1 << 16));
|
||||||
uint8_t byte;
|
uint8_t byte;
|
||||||
|
|
||||||
@ -62,26 +57,18 @@ void u2f_request(struct u2f_request_apdu* req, CTAP_RESPONSE * resp)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#if DEBUG_LEVEL > 0
|
|
||||||
t1 = millis();
|
timestamp();
|
||||||
#endif
|
|
||||||
rcode = u2f_register((struct u2f_register_request*)req->payload);
|
rcode = u2f_register((struct u2f_register_request*)req->payload);
|
||||||
#if DEBUG_LEVEL > 0
|
printf1(TAG_TIME,"u2f_register time: %d ms\n", timestamp());
|
||||||
t2 = millis();
|
|
||||||
printf1(TAG_TIME,"u2f_register time: %d ms\n", t2-t1);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case U2F_AUTHENTICATE:
|
case U2F_AUTHENTICATE:
|
||||||
printf1(TAG_U2F, "U2F_AUTHENTICATE\n");
|
printf1(TAG_U2F, "U2F_AUTHENTICATE\n");
|
||||||
#if DEBUG_LEVEL > 0
|
timestamp();
|
||||||
t1 = millis();
|
|
||||||
#endif
|
|
||||||
rcode = u2f_authenticate((struct u2f_authenticate_request*)req->payload, req->p1);
|
rcode = u2f_authenticate((struct u2f_authenticate_request*)req->payload, req->p1);
|
||||||
#if DEBUG_LEVEL > 0
|
printf1(TAG_TIME,"u2f_authenticate time: %d ms\n", timestamp());
|
||||||
t2 = millis();
|
|
||||||
printf1(TAG_TIME,"u2f_authenticate time: %d ms\n", t2-t1);
|
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
case U2F_VERSION:
|
case U2F_VERSION:
|
||||||
printf1(TAG_U2F, "U2F_VERSION\n");
|
printf1(TAG_U2F, "U2F_VERSION\n");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user