From bc1bb3509f202e26fcaf111c2d58075bb65cdc7e Mon Sep 17 00:00:00 2001 From: merlokk <807634+merlokk@users.noreply.github.com> Date: Wed, 6 Feb 2019 19:21:06 +0200 Subject: [PATCH] move APDU dumps to separate log channel --- fido2/log.c | 1 + fido2/log.h | 45 +++++++++++++++++++------------------ fido2/main.c | 37 +++++++++++++++--------------- targets/stm32l432/src/nfc.c | 16 +++++++------ 4 files changed, 52 insertions(+), 47 deletions(-) diff --git a/fido2/log.c b/fido2/log.c index 01514db..e070a23 100644 --- a/fido2/log.c +++ b/fido2/log.c @@ -63,6 +63,7 @@ struct logtag tagtable[] = { {TAG_BOOT,"BOOT"}, {TAG_EXT,"EXT"}, {TAG_NFC,"NFC"}, + {TAG_NFC_APDU, "NAPDU"}, }; diff --git a/fido2/log.h b/fido2/log.h index a6f5097..ea056ad 100644 --- a/fido2/log.h +++ b/fido2/log.h @@ -38,29 +38,30 @@ void set_logging_tag(uint32_t tag); typedef enum { - TAG_GEN = (1 << 0), - TAG_MC = (1 << 1), - TAG_GA = (1 << 2), - TAG_CP = (1 << 3), - TAG_ERR = (1 << 4), - TAG_PARSE= (1 << 5), - TAG_CTAP = (1 << 6), - TAG_U2F = (1 << 7), - TAG_DUMP = (1 << 8), - TAG_GREEN = (1 << 9), - TAG_RED= (1 << 10), - TAG_TIME= (1 << 11), - TAG_HID = (1 << 12), - TAG_USB = (1 << 13), - TAG_WALLET = (1 << 14), - TAG_STOR = (1 << 15), - TAG_DUMP2 = (1 << 16), - TAG_BOOT = (1 << 17), - TAG_EXT = (1 << 17), - TAG_NFC = (1 << 18), + TAG_GEN = (1 << 0), + TAG_MC = (1 << 1), + TAG_GA = (1 << 2), + TAG_CP = (1 << 3), + TAG_ERR = (1 << 4), + TAG_PARSE = (1 << 5), + TAG_CTAP = (1 << 6), + TAG_U2F = (1 << 7), + TAG_DUMP = (1 << 8), + TAG_GREEN = (1 << 9), + TAG_RED = (1 << 10), + TAG_TIME = (1 << 11), + TAG_HID = (1 << 12), + TAG_USB = (1 << 13), + TAG_WALLET = (1 << 14), + TAG_STOR = (1 << 15), + TAG_DUMP2 = (1 << 16), + TAG_BOOT = (1 << 17), + TAG_EXT = (1 << 18), + TAG_NFC = (1 << 19), + TAG_NFC_APDU = (1 << 20), - TAG_NO_TAG = (1UL<<30), - TAG_FILENO = (1UL<<31) + TAG_NO_TAG = (1UL << 30), + TAG_FILENO = (1UL << 31) } LOG_TAG; #if DEBUG_LEVEL > 0 diff --git a/fido2/main.c b/fido2/main.c index 3849633..19111e6 100644 --- a/fido2/main.c +++ b/fido2/main.c @@ -40,24 +40,25 @@ int main(int argc, char * argv[]) uint32_t t1 = 0; set_logging_mask( - /*0*/ - // TAG_GEN| - // TAG_MC | - // TAG_GA | - // TAG_WALLET | - TAG_STOR | - TAG_NFC | - // TAG_CP | - // TAG_CTAP| - // TAG_HID| - //TAG_U2F| - // TAG_PARSE | - // TAG_TIME| - // TAG_DUMP| - TAG_GREEN| - TAG_RED| - TAG_ERR - ); + /*0*/ + //TAG_GEN| + //TAG_MC | + //TAG_GA | + //TAG_WALLET | + TAG_STOR | + //TAG_NFC_APDU | + TAG_NFC | + //TAG_CP | + //TAG_CTAP| + //TAG_HID| + //TAG_U2F| + //TAG_PARSE | + //TAG_TIME| + //TAG_DUMP| + TAG_GREEN| + TAG_RED| + TAG_ERR + ); device_init(); printf1(TAG_GEN,"init device\n"); diff --git a/targets/stm32l432/src/nfc.c b/targets/stm32l432/src/nfc.c index 892a853..c1d6024 100644 --- a/targets/stm32l432/src/nfc.c +++ b/targets/stm32l432/src/nfc.c @@ -91,7 +91,8 @@ bool ams_receive_with_timeout(uint32_t timeout_ms, uint8_t * data, int maxlen, i { uint8_t len = buffer_status2 & AMS_BUF_LEN_MASK; ams_read_buffer(buf, len); - printf1(TAG_NFC,">> "); dump_hex1(TAG_NFC, buf, len); + printf1(TAG_NFC_APDU, ">> "); + dump_hex1(TAG_NFC_APDU, buf, len); *dlen = MIN(32, MIN(maxlen, len)); memcpy(data, buf, *dlen); @@ -116,7 +117,8 @@ void nfc_write_frame(uint8_t * data, uint8_t len) ams_write_buffer(data,len); ams_write_command(AMS_CMD_TRANSMIT_BUFFER); - printf1(TAG_NFC,"<< "); dump_hex1(TAG_NFC, data, len); + printf1(TAG_NFC_APDU, "<< "); + dump_hex1(TAG_NFC_APDU, data, len); } bool nfc_write_response_ex(uint8_t req0, uint8_t * data, uint8_t len, uint16_t resp) @@ -600,7 +602,7 @@ void nfc_process_block(uint8_t * buf, int len) { if (buf[0] & 0x10) { - printf1(TAG_NFC, "NFC_CMD_IBLOCK chaining blen=%d len=%d\r\n", ibuflen, len); + printf1(TAG_NFC_APDU, "NFC_CMD_IBLOCK chaining blen=%d len=%d\r\n", ibuflen, len); if (ibuflen + len > sizeof(ibuf)) { printf1(TAG_NFC, "I block memory error! must have %d but have only %d\r\n", ibuflen + len, sizeof(ibuf)); @@ -608,8 +610,8 @@ void nfc_process_block(uint8_t * buf, int len) return; } - printf1(TAG_NFC,"i> "); - dump_hex1(TAG_NFC, buf, len); + printf1(TAG_NFC_APDU,"i> "); + dump_hex1(TAG_NFC_APDU, buf, len); if (len) { @@ -635,8 +637,8 @@ void nfc_process_block(uint8_t * buf, int len) printf1(TAG_NFC, "NFC_CMD_IBLOCK chaining last block. blen=%d len=%d\r\n", ibuflen, len); - printf1(TAG_NFC,"i> "); - dump_hex1(TAG_NFC, buf, len); + printf1(TAG_NFC_APDU,"i> "); + dump_hex1(TAG_NFC_APDU, buf, len); nfc_process_iblock(ibuf, ibuflen); } else {