remove dump.c step2

This commit is contained in:
iceman1001
2020-11-12 18:43:03 +01:00
parent 4e6ba6fcf5
commit 243d509203
17 changed files with 21 additions and 105 deletions

View File

@@ -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 <config.h>
#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");
}
}

View File

@@ -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 <stdio.h> // FILE
void dump_buffer(const unsigned char *ptr, size_t len, FILE *f, int level);
#endif

View File

@@ -24,7 +24,6 @@
#include <stdarg.h>
#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) {

View File

@@ -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);
}
}

View File

@@ -24,7 +24,6 @@
#include "commonutil.h" // ARRAYLEN
#include "../crypto.h"
#include "../dump.h"
#include "util_posix.h"
#include "ui.h" // printandlog