diff --git a/fido2/ctap.c b/fido2/ctap.c index 4cbdeb7..3f323d9 100644 --- a/fido2/ctap.c +++ b/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); diff --git a/fido2/ctaphid.c b/fido2/ctaphid.c index 3f787ae..5ddc260 100644 --- a/fido2/ctaphid.c +++ b/fido2/ctaphid.c @@ -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 diff --git a/fido2/extensions/solo.c b/fido2/extensions/solo.c index 6b36fe2..f539138 100644 --- a/fido2/extensions/solo.c +++ b/fido2/extensions/solo.c @@ -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) { diff --git a/fido2/log.c b/fido2/log.c index c3aadf0..209bf54 100644 --- a/fido2/log.c +++ b/fido2/log.c @@ -9,6 +9,7 @@ #include #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 diff --git a/fido2/log.h b/fido2/log.h index a8edf1f..21403e7 100644 --- a/fido2/log.h +++ b/fido2/log.h @@ -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 diff --git a/fido2/u2f.c b/fido2/u2f.c index 75f0021..d7caf5e 100644 --- a/fido2/u2f.c +++ b/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");