diff --git a/client/emv/apduinfo.c b/client/emv/apduinfo.c index 6deeb618b..8ea69437c 100644 --- a/client/emv/apduinfo.c +++ b/client/emv/apduinfo.c @@ -10,6 +10,8 @@ #include "apduinfo.h" +#include "util.h" + const APDUCode APDUCodeTable[] = { // ID Type Description {"XXXX", APDUCODE_TYPE_NONE, ""}, // blank string @@ -315,9 +317,9 @@ const char *GetAPDUCodeDescription(uint8_t sw1, uint8_t sw2) { return APDUCodeTable[0].Description; //empty string } -int apdu_decode(uint8_t *data, size_t len, APDU_STRUCT *apdu) +int APDUDecode(uint8_t *data, size_t len, APDUStruct *apdu) { - EXT_APDU_HEADER *hapdu = (EXT_APDU_HEADER *)data; + ExtAPDUHeader *hapdu = (ExtAPDUHeader *)data; apdu->cla = hapdu->cla; apdu->ins = hapdu->ins; @@ -426,3 +428,13 @@ int apdu_decode(uint8_t *data, size_t len, APDU_STRUCT *apdu) return 0; } + +int APDUEncode(APDUStruct apdu, uint8_t *data, size_t len) { + + return 0; +} + +void APDUPrint(APDUStruct apdu) { + PrintAndLogEx(INFO, "apdu: %scase=%02x cla=%02x ins=%02x p1=%02x p2=%02x lc=%d le=%d\n", + apdu.extended_apdu ? "[e]":"", apdu.case_type, apdu.cla, apdu.ins, apdu.p1, apdu.p2, apdu.lc, apdu.le); +} diff --git a/client/emv/apduinfo.h b/client/emv/apduinfo.h index 399fd44a1..ba4bf7b13 100644 --- a/client/emv/apduinfo.h +++ b/client/emv/apduinfo.h @@ -39,7 +39,7 @@ typedef struct uint8_t p1; uint8_t p2; uint8_t lc[3]; -} __attribute__((packed)) EXT_APDU_HEADER; +} __attribute__((packed)) ExtAPDUHeader; typedef struct { @@ -52,8 +52,10 @@ typedef struct uint32_t le; bool extended_apdu; uint8_t case_type; -} __attribute__((packed)) APDU_STRUCT; -extern int apdu_decode(uint8_t *data, size_t len, APDU_STRUCT *apdu); +} __attribute__((packed)) APDUStruct; +extern int APDUDecode(uint8_t *data, size_t len, APDUStruct *apdu); +extern int APDUEncode(APDUStruct apdu, uint8_t *data, size_t len); +extern void APDUPrint(APDUStruct apdu); #endif