clean up build: GCC warnings

This commit is contained in:
yparitcher
2019-01-06 01:19:14 -05:00
parent 23c140fd99
commit 400b37a96a
16 changed files with 150 additions and 85 deletions

View File

@@ -1358,8 +1358,9 @@ uint8_t ctap_request(uint8_t * pkt_raw, int length, CTAP_RESPONSE * resp)
CborEncoder encoder;
uint8_t status = 0;
uint8_t cmd = *pkt_raw;
uint64_t t1;
uint64_t t2;
#if DEBUG_LEVEL > 0
uint64_t t1,t2;
#endif
pkt_raw++;
length--;
@@ -1392,10 +1393,14 @@ 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
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
resp->length = cbor_encoder_get_buffer_size(&encoder, buf);
dump_hex1(TAG_DUMP, buf, resp->length);
@@ -1404,10 +1409,14 @@ 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
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
resp->length = cbor_encoder_get_buffer_size(&encoder, buf);

View File

@@ -533,13 +533,21 @@ uint8_t ctaphid_handle_packet(uint8_t * pkt_raw)
uint8_t cmd;
uint32_t cid;
int len;
#ifndef DISABLE_CTAPHID_CBOR
int status;
#endif
static uint8_t is_busy = 0;
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);
@@ -581,11 +589,15 @@ 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
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
break;
#endif
#ifndef DISABLE_CTAPHID_WINK
@@ -629,12 +641,16 @@ uint8_t ctaphid_handle_packet(uint8_t * pkt_raw)
wb.bcnt = (ctap_resp.length+1);
#if DEBUG_LEVEL > 0
t1 = millis();
#endif
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
is_busy = 0;
break;
#endif

View File

@@ -58,9 +58,9 @@ void set_logging_mask(uint32_t mask);
#else
#define set_logging_mask(mask)
#define printf1(fmt, ...)
#define printf2(fmt, ...)
#define printf3(fmt, ...)
#define printf1(tag,fmt, ...)
#define printf2(tag,fmt, ...)
#define printf3(tag,fmt, ...)
#define dump_hex1(tag,data,len)
#endif

View File

@@ -11,11 +11,16 @@
#include "log.h"
#include "device.h"
#include "wallet.h"
#ifdef ENABLE_U2F_EXTENSIONS
#include "extensions.h"
#endif
#include APP_CONFIG
// void u2f_response_writeback(uint8_t * buf, uint8_t len);
#ifdef ENABLE_U2F
static int16_t u2f_register(struct u2f_register_request * req);
static int16_t u2f_authenticate(struct u2f_authenticate_request * req, uint8_t control);
#endif
int8_t u2f_response_writeback(const uint8_t * buf, uint16_t len);
void u2f_reset_response();
@@ -25,7 +30,11 @@ 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;
@@ -53,18 +62,26 @@ void u2f_request(struct u2f_request_apdu* req, CTAP_RESPONSE * resp)
}
else
{
#if DEBUG_LEVEL > 0
t1 = millis();
#endif
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
}
break;
case U2F_AUTHENTICATE:
printf1(TAG_U2F, "U2F_AUTHENTICATE\n");
#if DEBUG_LEVEL > 0
t1 = millis();
#endif
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
break;
case U2F_VERSION:
printf1(TAG_U2F, "U2F_VERSION\n");
@@ -128,6 +145,7 @@ void u2f_set_writeback_buffer(CTAP_RESPONSE * resp)
_u2f_resp = resp;
}
#ifdef ENABLE_U2F
static void dump_signature_der(uint8_t * sig)
{
uint8_t sigder[72];
@@ -300,6 +318,7 @@ static int16_t u2f_register(struct u2f_register_request * req)
return U2F_SW_NO_ERROR;
}
#endif
int16_t u2f_version()
{