mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 05:43:48 -07:00
removing dump_buffer step1
This commit is contained in:
parent
14ea72ca5d
commit
4e6ba6fcf5
5 changed files with 70 additions and 36 deletions
|
@ -23,10 +23,10 @@
|
|||
|
||||
#include "../emv_pk.h"
|
||||
#include "../crypto.h"
|
||||
#include "../dump.h"
|
||||
#include "../tlv.h"
|
||||
#include "../emv_pki.h"
|
||||
#include "ui.h" // printandlog
|
||||
#include "util.h" // print_buffer
|
||||
|
||||
struct emv_pk c_mchip_05 = {
|
||||
.rid = { 0xa0, 0x00, 0x00, 0x00, 0x04, },
|
||||
|
@ -172,7 +172,7 @@ static int cda_test_raw(bool verbose) {
|
|||
|
||||
if (verbose) {
|
||||
PrintAndLogEx(INFO, "issuer cert:");
|
||||
dump_buffer(ipk_data, ipk_data_len, stdout, 0);
|
||||
print_buffer(ipk_data, ipk_data_len, 1);
|
||||
}
|
||||
|
||||
size_t ipk_pk_len = ipk_data[13];
|
||||
|
@ -202,7 +202,7 @@ static int cda_test_raw(bool verbose) {
|
|||
|
||||
if (verbose) {
|
||||
PrintAndLogEx(INFO, "crypto hash:");
|
||||
dump_buffer(h, 20, stdout, 0);
|
||||
print_buffer(h, 20, 1);
|
||||
}
|
||||
|
||||
if (memcmp(ipk_data + ipk_data_len - 21, h, 20)) {
|
||||
|
@ -231,7 +231,7 @@ static int cda_test_raw(bool verbose) {
|
|||
|
||||
if (verbose) {
|
||||
PrintAndLogEx(INFO, "icc cert:");
|
||||
dump_buffer(iccpk_data, iccpk_data_len, stdout, 0);
|
||||
print_buffer(iccpk_data, iccpk_data_len, 1);
|
||||
}
|
||||
|
||||
size_t iccpk_pk_len = iccpk_data[19];
|
||||
|
@ -260,7 +260,7 @@ static int cda_test_raw(bool verbose) {
|
|||
|
||||
if (verbose) {
|
||||
PrintAndLogEx(INFO, "crypto hash1.1:");
|
||||
dump_buffer(h, 20, stdout, 0);
|
||||
print_buffer(h, 20, 1);
|
||||
}
|
||||
|
||||
if (memcmp(iccpk_data + iccpk_data_len - 21, h, 20)) {
|
||||
|
@ -287,7 +287,7 @@ static int cda_test_raw(bool verbose) {
|
|||
|
||||
if (verbose) {
|
||||
PrintAndLogEx(INFO, "SDAD:");
|
||||
dump_buffer(sdad, sdad_len, stdout, 0);
|
||||
print_buffer(sdad, sdad_len, 1);
|
||||
}
|
||||
|
||||
ch = crypto_hash_open(HASH_SHA_1);
|
||||
|
@ -308,7 +308,7 @@ static int cda_test_raw(bool verbose) {
|
|||
|
||||
if (verbose) {
|
||||
PrintAndLogEx(INFO, "crypto hash2:");
|
||||
dump_buffer(h2, 20, stdout, 0);
|
||||
print_buffer(h2, 20, 1);
|
||||
}
|
||||
|
||||
crypto_hash_close(ch);
|
||||
|
@ -331,7 +331,7 @@ static int cda_test_raw(bool verbose) {
|
|||
|
||||
if (verbose) {
|
||||
PrintAndLogEx(INFO, "crypto hash2.1:");
|
||||
dump_buffer(h, 20, stdout, 0);
|
||||
print_buffer(h, 20, 1);
|
||||
}
|
||||
|
||||
if (memcmp(sdad + 5 + 8 + 1 + 8, h, 20)) {
|
||||
|
@ -408,7 +408,7 @@ static int cda_test_pk(bool verbose) {
|
|||
|
||||
if (verbose) {
|
||||
PrintAndLogEx(INFO, "IDN:");
|
||||
dump_buffer(idn->value, idn->len, stdout, 0);
|
||||
print_buffer(idn->value, idn->len, 1);
|
||||
}
|
||||
|
||||
tlvdb_free(idndb);
|
||||
|
|
|
@ -23,11 +23,10 @@
|
|||
#include "dda_test.h"
|
||||
#include "../emv_pk.h"
|
||||
#include "../crypto.h"
|
||||
#include "../dump.h"
|
||||
#include "../tlv.h"
|
||||
#include "../emv_pki.h"
|
||||
#include "ui.h" // printandlog
|
||||
|
||||
#include "util.h" // print_buffer
|
||||
|
||||
struct emv_pk mchip_05 = {
|
||||
.rid = { 0xa0, 0x00, 0x00, 0x00, 0x04, },
|
||||
|
@ -161,7 +160,7 @@ static int dda_test_raw(bool verbose) {
|
|||
|
||||
if (verbose) {
|
||||
PrintAndLogEx(INFO, "issuer cert:");
|
||||
dump_buffer(ipk_data, ipk_data_len, stdout, 0);
|
||||
print_buffer(ipk_data, ipk_data_len, 1);
|
||||
}
|
||||
|
||||
size_t ipk_pk_len = ipk_data[13];
|
||||
|
@ -191,7 +190,7 @@ static int dda_test_raw(bool verbose) {
|
|||
|
||||
if (verbose) {
|
||||
PrintAndLogEx(INFO, "crypto hash:");
|
||||
dump_buffer(h, 20, stdout, 0);
|
||||
print_buffer(h, 20, 1);
|
||||
}
|
||||
|
||||
if (memcmp(ipk_data + ipk_data_len - 21, h, 20)) {
|
||||
|
@ -220,7 +219,7 @@ static int dda_test_raw(bool verbose) {
|
|||
|
||||
if (verbose) {
|
||||
PrintAndLogEx(INFO, "icc cert:");
|
||||
dump_buffer(iccpk_data, iccpk_data_len, stdout, 0);
|
||||
print_buffer(iccpk_data, iccpk_data_len, 1);
|
||||
}
|
||||
|
||||
size_t iccpk_pk_len = iccpk_data[19];
|
||||
|
@ -249,7 +248,7 @@ static int dda_test_raw(bool verbose) {
|
|||
|
||||
if (verbose) {
|
||||
PrintAndLogEx(INFO, "crypto hash1.1:");
|
||||
dump_buffer(h, 20, stdout, 0);
|
||||
print_buffer(h, 20, 1);
|
||||
}
|
||||
|
||||
if (memcmp(iccpk_data + iccpk_data_len - 21, h, 20)) {
|
||||
|
@ -276,7 +275,7 @@ static int dda_test_raw(bool verbose) {
|
|||
|
||||
if (verbose) {
|
||||
PrintAndLogEx(INFO, "sdad:");
|
||||
dump_buffer(sdad, sdad_len, stdout, 0);
|
||||
print_buffer(sdad, sdad_len, 1);
|
||||
}
|
||||
|
||||
ch = crypto_hash_open(HASH_SHA_1);
|
||||
|
@ -297,7 +296,7 @@ static int dda_test_raw(bool verbose) {
|
|||
|
||||
if (verbose) {
|
||||
PrintAndLogEx(INFO, "crypto hash2:");
|
||||
dump_buffer(h2, 20, stdout, 0);
|
||||
print_buffer(h2, 20, 1);
|
||||
}
|
||||
|
||||
crypto_hash_close(ch);
|
||||
|
@ -356,7 +355,7 @@ static int dda_test_pk(bool verbose) {
|
|||
|
||||
if (verbose) {
|
||||
PrintAndLogEx(INFO, "IDN:");
|
||||
dump_buffer(idn->value, idn->len, stdout, 0);
|
||||
print_buffer(idn->value, idn->len, 1);
|
||||
}
|
||||
|
||||
tlvdb_free(idndb);
|
||||
|
|
|
@ -23,10 +23,10 @@
|
|||
|
||||
#include "../emv_pk.h"
|
||||
#include "../crypto.h"
|
||||
#include "../dump.h"
|
||||
#include "../tlv.h"
|
||||
#include "../emv_pki.h"
|
||||
#include "ui.h" // printandlog
|
||||
#include "util.h" // print_buffer
|
||||
#include "sda_test.h"
|
||||
|
||||
struct emv_pk vsdc_01 = {
|
||||
|
@ -122,7 +122,7 @@ static int sda_test_raw(bool verbose) {
|
|||
|
||||
if (verbose) {
|
||||
PrintAndLogEx(INFO, "issuer cert:");
|
||||
dump_buffer(ipk_data, ipk_data_len, stdout, 0);
|
||||
print_buffer(ipk_data, ipk_data_len, 1);
|
||||
}
|
||||
|
||||
size_t ipk_pk_len = ipk_data[13];
|
||||
|
@ -152,7 +152,7 @@ static int sda_test_raw(bool verbose) {
|
|||
|
||||
if (verbose) {
|
||||
PrintAndLogEx(INFO, "crypto hash:");
|
||||
dump_buffer(h, 20, stdout, 0);
|
||||
print_buffer(h, 20, 1);
|
||||
}
|
||||
|
||||
if (memcmp(ipk_data + ipk_data_len - 21, h, 20)) {
|
||||
|
@ -179,7 +179,7 @@ static int sda_test_raw(bool verbose) {
|
|||
|
||||
if (verbose) {
|
||||
PrintAndLogEx(INFO, "ssad:");
|
||||
dump_buffer(ssad, ssad_len, stdout, 0);
|
||||
print_buffer(ssad, ssad_len, 1);
|
||||
}
|
||||
|
||||
ch = crypto_hash_open(HASH_SHA_1);
|
||||
|
@ -200,7 +200,7 @@ static int sda_test_raw(bool verbose) {
|
|||
|
||||
if (verbose) {
|
||||
PrintAndLogEx(INFO, "crypto hash2:");
|
||||
dump_buffer(h2, 20, stdout, 0);
|
||||
print_buffer(h2, 20, 1);
|
||||
}
|
||||
|
||||
crypto_hash_close(ch);
|
||||
|
@ -245,7 +245,7 @@ static int sda_test_pk(bool verbose) {
|
|||
|
||||
if (verbose) {
|
||||
PrintAndLogEx(INFO, "dac:");
|
||||
dump_buffer(dac->value, dac->len, stdout, 0);
|
||||
print_buffer(dac->value, dac->len, 1);
|
||||
}
|
||||
|
||||
tlvdb_free(dacdb);
|
||||
|
|
|
@ -200,6 +200,52 @@ void print_hex_break(const uint8_t *data, const size_t len, uint8_t breaks) {
|
|||
PrintAndLogEx(NORMAL, "");
|
||||
}
|
||||
|
||||
void print_buffer(const uint8_t *data, const size_t len, int level) {
|
||||
|
||||
if (len < 1)
|
||||
return;
|
||||
|
||||
char buf[UTIL_BUFFER_SIZE_SPRINT + 3];
|
||||
int i;
|
||||
for (i = 0; i < len; i += 16) {
|
||||
|
||||
// (16 * 3) + (16) + + 1
|
||||
memset(buf, 0, sizeof(buf));
|
||||
sprintf(buf, "%*s%02x: ", (level * 4), " ", i);
|
||||
|
||||
hex_to_buffer((uint8_t *)(buf + strlen(buf)), data + i, 16, (sizeof(buf) - strlen(buf) - 1), 0, 1, true);
|
||||
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "| %s", sprint_ascii(data + i, 16));
|
||||
PrintAndLogEx(INFO, "%s", buf);
|
||||
}
|
||||
|
||||
// the last odd bytes
|
||||
uint8_t mod = len % 16;
|
||||
|
||||
if (mod) {
|
||||
memset(buf, 0, sizeof(buf));
|
||||
sprintf(buf, "%*s%02x: ", (level * 4), " ", i);
|
||||
hex_to_buffer((uint8_t *)(buf + strlen(buf)), data + i, mod, (sizeof(buf) - strlen(buf) - 1), 0, 1, true);
|
||||
|
||||
// add the spaces...
|
||||
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "%*s", ((16 - mod) * 3) , " ");
|
||||
|
||||
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "| %s", sprint_ascii(data + i, mod));
|
||||
PrintAndLogEx(INFO, "%s", buf);
|
||||
}
|
||||
}
|
||||
|
||||
void print_blocks(uint32_t *data, size_t len) {
|
||||
PrintAndLogEx(SUCCESS, "Blk | Data ");
|
||||
PrintAndLogEx(SUCCESS, "----+------------");
|
||||
|
||||
if (!data) {
|
||||
PrintAndLogEx(ERR, "..empty data");
|
||||
} else {
|
||||
for (uint8_t i = 0; i < len; i++)
|
||||
PrintAndLogEx(SUCCESS, " %02d | %08X", i, data[i]);
|
||||
}
|
||||
}
|
||||
|
||||
char *sprint_hex(const uint8_t *data, const size_t len) {
|
||||
static char buf[UTIL_BUFFER_SIZE_SPRINT - 3] = {0};
|
||||
hex_to_buffer((uint8_t *)buf, data, len, sizeof(buf) - 1, 0, 1, true);
|
||||
|
@ -344,18 +390,6 @@ char *sprint_ascii(const uint8_t *data, const size_t len) {
|
|||
return sprint_ascii_ex(data, len, 0);
|
||||
}
|
||||
|
||||
void print_blocks(uint32_t *data, size_t len) {
|
||||
PrintAndLogEx(SUCCESS, "Blk | Data ");
|
||||
PrintAndLogEx(SUCCESS, "----+------------");
|
||||
|
||||
if (!data) {
|
||||
PrintAndLogEx(ERR, "..empty data");
|
||||
} else {
|
||||
for (uint8_t i = 0; i < len; i++)
|
||||
PrintAndLogEx(SUCCESS, " %02d | %08X", i, data[i]);
|
||||
}
|
||||
}
|
||||
|
||||
int hex_to_bytes(const char *hexValue, uint8_t *bytesValue, size_t maxBytesValueLen) {
|
||||
char buf[4] = {0};
|
||||
int indx = 0;
|
||||
|
|
|
@ -50,6 +50,7 @@ char *sprint_hex_ascii(const uint8_t *data, const size_t len);
|
|||
char *sprint_ascii(const uint8_t *data, const size_t len);
|
||||
char *sprint_ascii_ex(const uint8_t *data, const size_t len, const size_t min_str_len);
|
||||
|
||||
void print_buffer(const uint8_t *data, const size_t len, int level);
|
||||
void print_blocks(uint32_t *data, size_t len);
|
||||
|
||||
int hex_to_bytes(const char *hexValue, uint8_t *bytesValue, size_t maxBytesValueLen);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue