diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index 77181f8bf..be8eaec5b 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -188,7 +188,6 @@ set (TARGET_SOURCES ${PM3_ROOT}/client/src/emv/crypto.c ${PM3_ROOT}/client/src/emv/crypto_polarssl.c ${PM3_ROOT}/client/src/emv/dol.c - ${PM3_ROOT}/client/src/emv/dump.c ${PM3_ROOT}/client/src/emv/emv_pk.c ${PM3_ROOT}/client/src/emv/emv_pki.c ${PM3_ROOT}/client/src/emv/emv_pki_priv.c diff --git a/client/Makefile b/client/Makefile index 333cbad08..8e7ff3724 100644 --- a/client/Makefile +++ b/client/Makefile @@ -506,7 +506,6 @@ SRCS = aiddesfire.c \ emv/crypto.c\ emv/crypto_polarssl.c\ emv/dol.c \ - emv/dump.c \ emv/emv_pk.c\ emv/emv_pki.c\ emv/emv_pki_priv.c\ diff --git a/client/src/cmdhf14a.c b/client/src/cmdhf14a.c index 0cb6006d4..52c320dd7 100644 --- a/client/src/cmdhf14a.c +++ b/client/src/cmdhf14a.c @@ -29,7 +29,6 @@ #include "aidsearch.h" #include "cmdhf.h" // handle HF plot #include "protocols.h" // MAGIC_GEN_1A -#include "emv/dump.h" // dump_buffer bool APDUInFramingEnable = true; diff --git a/client/src/cmdhffido.c b/client/src/cmdhffido.c index 91c1a85b3..e196c2681 100644 --- a/client/src/cmdhffido.c +++ b/client/src/cmdhffido.c @@ -19,9 +19,7 @@ //----------------------------------------------------------------------------- #include "cmdhffido.h" - #include - #include "cmdparser.h" // command_t #include "commonutil.h" #include "comms.h" @@ -33,10 +31,10 @@ #include "crypto/libpcrypto.h" #include "fido/cbortools.h" #include "fido/fidocore.h" -#include "emv/dump.h" #include "ui.h" #include "cmdhf14a.h" #include "cmdtrace.h" +#include "util.h" static int CmdHelp(const char *Cmd); @@ -88,7 +86,7 @@ static int cmd_hf_fido_info(const char *cmd) { } else { PrintAndLogEx(INFO, "FIDO authenticator detected (not standard U2F)."); PrintAndLogEx(INFO, "Non U2F authenticator version:"); - dump_buffer((const unsigned char *)buf, len, NULL, 0); + print_buffer((const unsigned char *)buf, len, 1); } } else { PrintAndLogEx(INFO, "FIDO U2F authenticator detected. Version: %.*s", (int)len, buf); @@ -296,7 +294,7 @@ static int cmd_hf_fido_register(const char *cmd) { if (verbose2) { PrintAndLogEx(INFO, "------------ " _CYAN_("data") " ----------------------"); - dump_buffer((const unsigned char *)buf, len, NULL, 0); + print_buffer((const unsigned char *)buf, len, 1); PrintAndLogEx(INFO, "-------------" _CYAN_("data") " ----------------------"); } diff --git a/client/src/cmdhfmf.c b/client/src/cmdhfmf.c index b6a1592bb..82fc8a1c4 100644 --- a/client/src/cmdhfmf.c +++ b/client/src/cmdhfmf.c @@ -16,7 +16,6 @@ #include "comms.h" // clearCommandBuffer #include "fileutils.h" #include "cmdtrace.h" -#include "emv/dump.h" #include "mifare/mifaredefault.h" // mifare default key array #include "cliparser.h" // argtable #include "hardnested_bf_core.h" // SetSIMDInstr @@ -5095,7 +5094,7 @@ static int CmdHFMFNDEF(const char *Cmd) { if (verbose2) { PrintAndLogEx(NORMAL, ""); PrintAndLogEx(INFO, "--- " _CYAN_("MFC NDEF raw") " ----------------"); - dump_buffer(data, datalen, stdout, 1); + print_buffer(data, datalen, 1); } NDEFDecodeAndPrint(data, datalen, verbose); diff --git a/client/src/cmdhfmfdes.c b/client/src/cmdhfmfdes.c index 871c9d115..358f61493 100644 --- a/client/src/cmdhfmfdes.c +++ b/client/src/cmdhfmfdes.c @@ -35,6 +35,7 @@ #include "mifare/mad.h" #include "generator.h" #include "aiddesfire.h" +#include "util.h" #define MAX_KEY_LEN 24 #define MAX_KEYS_LIST_LEN 1024 @@ -4769,7 +4770,7 @@ static int CmdHF14aDesNDEF(const char *Cmd) { if (verbose2) { PrintAndLogEx(NORMAL, ""); PrintAndLogEx(INFO, "--- " _CYAN_("DESFire NDEF raw") " ----------------"); - dump_buffer(data, datalen, stdout, 1); + print_buffer(data, datalen, 1); } PrintAndLogEx(HINT, "Try " _YELLOW_("`hf mfdes ndef -vv`") " for more details"); diff --git a/client/src/cmdhfmfp.c b/client/src/cmdhfmfp.c index 5ef2ac826..1f0d47ae5 100644 --- a/client/src/cmdhfmfp.c +++ b/client/src/cmdhfmfp.c @@ -15,12 +15,12 @@ #include "commonutil.h" // ARRAYLEN #include "comms.h" #include "ui.h" +#include "util.h" #include "cmdhf14a.h" #include "mifare/mifare4.h" #include "mifare/mad.h" #include "mifare/ndef.h" #include "cliparser.h" -#include "emv/dump.h" #include "mifare/mifaredefault.h" #include "util_posix.h" #include "fileutils.h" @@ -1551,7 +1551,7 @@ static int CmdHFMFPNDEF(const char *Cmd) { if (verbose2) { PrintAndLogEx(NORMAL, ""); PrintAndLogEx(INFO, "--- " _CYAN_("MF Plus NDEF raw") " ----------------"); - dump_buffer(data, datalen, stdout, 1); + print_buffer(data, datalen, 1); } NDEFDecodeAndPrint(data, datalen, verbose); diff --git a/client/src/cmdsmartcard.c b/client/src/cmdsmartcard.c index ae9d018d4..ddeece950 100644 --- a/client/src/cmdsmartcard.c +++ b/client/src/cmdsmartcard.c @@ -18,8 +18,8 @@ #include "comms.h" // getfromdevice #include "emv/emvcore.h" // decodeTVL #include "crypto/libpcrypto.h" // sha512hash -#include "emv/dump.h" #include "ui.h" +#include "util.h" #include "fileutils.h" #include "crc16.h" // crc @@ -316,7 +316,7 @@ static void PrintATR(uint8_t *atr, size_t atrlen) { if (K > 1) { PrintAndLogEx(INFO, "\tHistorical bytes"); - dump_buffer(&atr[2 + T1len + TD1len + TDilen], K, NULL, 1); + print_buffer(&atr[2 + T1len + TD1len + TDilen], K, 1); } } diff --git a/client/src/crypto/asn1dump.c b/client/src/crypto/asn1dump.c index 91b04216a..42aab70bc 100644 --- a/client/src/crypto/asn1dump.c +++ b/client/src/crypto/asn1dump.c @@ -21,7 +21,6 @@ #include #include #include "emv/emv_tags.h" -#include "emv/dump.h" #include "emv/emvjson.h" #include "util.h" #include "proxmark3.h" diff --git a/client/src/crypto/asn1utils.c b/client/src/crypto/asn1utils.c index 9e5826712..eede8ef0d 100644 --- a/client/src/crypto/asn1utils.c +++ b/client/src/crypto/asn1utils.c @@ -16,7 +16,6 @@ #include "ui.h" // Print... #include "emv/tlv.h" -#include "emv/dump.h" #include "asn1dump.h" #include "util.h" @@ -68,7 +67,7 @@ static void print_cb(void *data, const struct tlv *tlv, int level, bool is_leaf) bool candump = true; asn1_tag_dump(tlv, stdout, level, &candump); if (is_leaf && candump) { - dump_buffer(tlv->value, tlv->len, stdout, level); + print_buffer(tlv->value, tlv->len, level); } } diff --git a/client/src/emv/dump.c b/client/src/emv/dump.c deleted file mode 100644 index 137fc5bdb..000000000 --- a/client/src/emv/dump.c +++ /dev/null @@ -1,47 +0,0 @@ -/* - * libopenemv - a library to work with EMV family of smart cards - * Copyright (C) 2015 Dmitry Eremin-Solenikov - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include "dump.h" - -#ifndef PRINT_INDENT -# define PRINT_INDENT(level) {for (int myi = 0; myi < (level); myi++) fprintf(f, " ");} -#endif - -void dump_buffer(const unsigned char *ptr, size_t len, FILE *f, int level) { - int j; - - if (!f) - f = stdout; - - for (int i = 0; i < len; i += 16) { - PRINT_INDENT(level); - fprintf(f, "\t%02x:", i); - for (j = 0; j < 16; j++) { - if (i + j < len) - fprintf(f, " %02hhx", ptr[i + j]); - else - fprintf(f, " "); - } - fprintf(f, " |"); - for (j = 0; j < 16 && i + j < len; j++) { - fprintf(f, "%c", (ptr[i + j] >= 0x20 && ptr[i + j] < 0x7f) ? ptr[i + j] : '.'); - } - fprintf(f, "\n"); - } -} diff --git a/client/src/emv/dump.h b/client/src/emv/dump.h deleted file mode 100644 index 77cd489f3..000000000 --- a/client/src/emv/dump.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * libopenemv - a library to work with EMV family of smart cards - * Copyright (C) 2015 Dmitry Eremin-Solenikov - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - */ - -#ifndef DUMP_H -#define DUMP_H - -#include "common.h" - -#include // FILE - -void dump_buffer(const unsigned char *ptr, size_t len, FILE *f, int level); - -#endif diff --git a/client/src/emv/emv_pki.c b/client/src/emv/emv_pki.c index 0afcfe775..f06a5ea69 100644 --- a/client/src/emv/emv_pki.c +++ b/client/src/emv/emv_pki.c @@ -24,7 +24,6 @@ #include #include "crypto.h" -#include "dump.h" #include "util.h" #include "ui.h" @@ -73,7 +72,7 @@ static unsigned char *emv_pki_decode_message(const struct emv_pk *enc_pk, /* if (true){ PrintAndLogEx(SUCCESS, "Recovered data:\n"); - dump_buffer(data, data_len, stdout, 0); + print_buffer(data, data_len, 1); }*/ if (data[data_len - 1] != 0xbc || data[0] != 0x6a || data[1] != msgtype) { @@ -200,7 +199,7 @@ static struct emv_pk *emv_pki_decode_key_ex(const struct emv_pk *enc_pk, if (showData) { PrintAndLogEx(SUCCESS, "Recovered data:"); - dump_buffer(data, data_len, stdout, 0); + print_buffer(data, data_len, 1); } /* Perform the rest of checks here */ @@ -375,7 +374,7 @@ struct tlvdb *emv_pki_recover_dac_ex(const struct emv_pk *enc_pk, const struct t if (showData) { PrintAndLogEx(SUCCESS, "Recovered data:"); - dump_buffer(data, data_len, stdout, 0); + print_buffer(data, data_len, 1); } struct tlvdb *dac_db = tlvdb_fixed(0x9f45, 2, data + 3); @@ -409,7 +408,7 @@ struct tlvdb *emv_pki_recover_idn_ex(const struct emv_pk *enc_pk, const struct t if (showData) { PrintAndLogEx(SUCCESS, "Recovered data:"); - dump_buffer(data, data_len, stdout, 0); + print_buffer(data, data_len, 1); } size_t idn_len = data[4]; @@ -445,7 +444,7 @@ struct tlvdb *emv_pki_recover_atc_ex(const struct emv_pk *enc_pk, const struct t if (showData) { PrintAndLogEx(SUCCESS, "Recovered data:"); - dump_buffer(data, data_len, stdout, 0); + print_buffer(data, data_len, 1); } size_t idn_len = data[4]; @@ -511,7 +510,7 @@ struct tlvdb *emv_pki_perform_cda_ex(const struct emv_pk *enc_pk, const struct t if (showData) { PrintAndLogEx(SUCCESS, "Recovered data:"); - dump_buffer(data, data_len, stdout, 0); + print_buffer(data, data_len, 1); } if (data[3] < 30 || data[3] > data_len - 4) { diff --git a/client/src/emv/emvcore.c b/client/src/emv/emvcore.c index 23de78c7d..ecbb7c4f9 100644 --- a/client/src/emv/emvcore.c +++ b/client/src/emv/emvcore.c @@ -19,7 +19,6 @@ #include "ui.h" #include "cmdhf14a.h" #include "dol.h" -#include "dump.h" #include "emv_tags.h" #include "emvjson.h" #include "util_posix.h" @@ -160,7 +159,7 @@ enum CardPSVendor GetCardPSVendor(uint8_t *AID, size_t AIDlen) { static void print_cb(void *data, const struct tlv *tlv, int level, bool is_leaf) { emv_tag_dump(tlv, stdout, level); if (is_leaf) { - dump_buffer(tlv->value, tlv->len, stdout, level); + print_buffer(tlv->value, tlv->len, level); } } diff --git a/client/src/emv/test/crypto_test.c b/client/src/emv/test/crypto_test.c index e3b8124f0..987a672da 100644 --- a/client/src/emv/test/crypto_test.c +++ b/client/src/emv/test/crypto_test.c @@ -24,7 +24,6 @@ #include "commonutil.h" // ARRAYLEN #include "../crypto.h" -#include "../dump.h" #include "util_posix.h" #include "ui.h" // printandlog diff --git a/client/src/fido/fidocore.c b/client/src/fido/fidocore.c index 26fa30dc4..d355779fe 100644 --- a/client/src/fido/fidocore.c +++ b/client/src/fido/fidocore.c @@ -22,7 +22,6 @@ #include "crypto/libpcrypto.h" #include "additional_ca.h" #include "cose.h" -#include "emv/dump.h" #include "ui.h" #include "util.h" diff --git a/client/src/mifare/ndef.c b/client/src/mifare/ndef.c index 785b822db..2839933e1 100644 --- a/client/src/mifare/ndef.c +++ b/client/src/mifare/ndef.c @@ -14,7 +14,6 @@ #include "ui.h" #include "util.h" // sprint_hex... -#include "emv/dump.h" #include "crypto/asn1utils.h" #include "pm3_cmd.h" @@ -375,15 +374,15 @@ static int ndefRecordDecodeAndPrint(uint8_t *ndefRecord, size_t ndefRecordLen) { if (NDEFHeader.TypeLen) { PrintAndLogEx(INFO, "Type data:"); - dump_buffer(NDEFHeader.Type, NDEFHeader.TypeLen, stdout, 1); + print_buffer(NDEFHeader.Type, NDEFHeader.TypeLen, 1); } if (NDEFHeader.IDLen) { PrintAndLogEx(INFO, "ID data:"); - dump_buffer(NDEFHeader.ID, NDEFHeader.IDLen, stdout, 1); + print_buffer(NDEFHeader.ID, NDEFHeader.IDLen, 1); } if (NDEFHeader.PayloadLen) { PrintAndLogEx(INFO, "Payload data:"); - dump_buffer(NDEFHeader.Payload, NDEFHeader.PayloadLen, stdout, 1); + print_buffer(NDEFHeader.Payload, NDEFHeader.PayloadLen, 1); if (NDEFHeader.TypeLen) ndefDecodePayload(&NDEFHeader); }