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