Skip to content

Commit

Permalink
remove dump_buffer_simple
Browse files Browse the repository at this point in the history
  • Loading branch information
iceman1001 committed Nov 11, 2020
1 parent 8f67b51 commit bf4cdf6
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 26 deletions.
4 changes: 2 additions & 2 deletions client/src/cmdhffido.c
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,8 @@ static int cmd_hf_fido_register(const char *cmd) {
int derp = 67 + keyHandleLen;
int derLen = (buf[derp + 2] << 8) + buf[derp + 3] + 4;
if (verbose2) {
PrintAndLogEx(INFO, "DER certificate[%d]:");
PrintAndLogEx(INFO, "------------------DER-------------------", derLen);
PrintAndLogEx(INFO, "DER certificate[%d]:", derLen);
PrintAndLogEx(INFO, "------------------DER-------------------");
PrintAndLogEx(INFO, "%s", sprint_hex(buf + derp, derLen));
PrintAndLogEx(INFO, "----------------DER---------------------");
} else {
Expand Down
14 changes: 2 additions & 12 deletions client/src/emv/dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,13 @@
# define PRINT_INDENT(level) {for (int myi = 0; myi < (level); myi++) fprintf(f, " ");}
#endif

void dump_buffer_simple(const unsigned char *ptr, size_t len, FILE *f) {
int i;

if (!f)
f = stdout;

for (i = 0; i < len; i ++)
fprintf(f, "%s%02hhX", i ? " " : "", ptr[i]);
}

void dump_buffer(const unsigned char *ptr, size_t len, FILE *f, int level) {
int i, j;
int j;

if (!f)
f = stdout;

for (i = 0; i < len; i += 16) {
for (int i = 0; i < len; i += 16) {
PRINT_INDENT(level);
fprintf(f, "\t%02x:", i);
for (j = 0; j < 16; j++) {
Expand Down
1 change: 0 additions & 1 deletion client/src/emv/dump.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

#include <stdio.h> // FILE

void dump_buffer_simple(const unsigned char *ptr, size_t len, FILE *f);
void dump_buffer(const unsigned char *ptr, size_t len, FILE *f, int level);
void dump_buffer_tab(const unsigned char *ptr, size_t len, FILE *f, int tabs);

Expand Down
23 changes: 12 additions & 11 deletions client/src/fido/fidocore.c
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ int FIDOCheckDERAndGetKey(uint8_t *der, size_t derLen, bool verbose, uint8_t *pu
}

if (verbose)
PrintAndLogEx(NORMAL, "------------------DER-------------------");
PrintAndLogEx(INFO, "------------------DER-------------------");

mbedtls_x509_crt_free(&cert);
mbedtls_x509_crt_free(&cacert);
Expand Down Expand Up @@ -366,8 +366,8 @@ static int FIDO2CheckSignature(json_t *root, uint8_t *publickey, uint8_t *sign,
int res = ecdsa_asn1_get_signature(sign, signLen, rval, sval);
if (!res) {
if (verbose) {
PrintAndLogEx(NORMAL, " r: %s", sprint_hex(rval, 32));
PrintAndLogEx(NORMAL, " s: %s", sprint_hex(sval, 32));
PrintAndLogEx(INFO, " r: %s", sprint_hex(rval, 32));
PrintAndLogEx(INFO, " s: %s", sprint_hex(sval, 32));
}

uint8_t clientDataHash[32] = {0};
Expand Down Expand Up @@ -488,9 +488,9 @@ int FIDO2MakeCredentionalParseRes(json_t *root, uint8_t *data, size_t dataLen, b

if (showCBOR) {
PrintAndLogEx(INFO, "COSE structure:");
PrintAndLogEx(NORMAL, "---------------- CBOR ------------------");
PrintAndLogEx(INFO, "---------------- CBOR ------------------");
TinyCborPrintFIDOPackage(fido2COSEKey, true, &ubuf[55 + cridlen], cplen);
PrintAndLogEx(NORMAL, "---------------- CBOR ------------------");
PrintAndLogEx(INFO, "---------------- CBOR ------------------");
}

res = COSEGetECDSAKey(&ubuf[55 + cridlen], cplen, verbose, coseKey);
Expand Down Expand Up @@ -542,11 +542,12 @@ int FIDO2MakeCredentionalParseRes(json_t *root, uint8_t *data, size_t dataLen, b
res = CborGetArrayBinStringValue(&mapsmt, der, sizeof(der), &derLen);
cbor_check(res);
if (verbose2) {
PrintAndLogEx(NORMAL, "DER certificate[%zu]:\n------------------DER-------------------", derLen);
dump_buffer_simple((const unsigned char *)der, derLen, NULL);
PrintAndLogEx(NORMAL, "\n----------------DER---------------------");
PrintAndLogEx(INFO, "DER certificate[%zu]:", derLen);
PrintAndLogEx(INFO, "------------------DER-------------------");
PrintAndLogEx(INFO, "%s", sprint_hex(der, derLen));
PrintAndLogEx(INFO, "----------------DER---------------------");
} else {
PrintAndLogEx(NORMAL, "DER [%zu]: %s...", derLen, sprint_hex(der, MIN(derLen, 16)));
PrintAndLogEx(INFO, "DER [%zu]: %s...", derLen, sprint_hex(der, MIN(derLen, 16)));
}
JsonSaveBufAsHexCompact(root, "$.AppData.DER", der, derLen);
}
Expand All @@ -558,9 +559,9 @@ int FIDO2MakeCredentionalParseRes(json_t *root, uint8_t *data, size_t dataLen, b

// print DER certificate in TLV view
if (showDERTLV) {
PrintAndLogEx(NORMAL, "----------------DER TLV-----------------");
PrintAndLogEx(INFO, "----------------DER TLV-----------------");
asn1_print(der, derLen, " ");
PrintAndLogEx(NORMAL, "----------------DER TLV-----------------");
PrintAndLogEx(INFO, "----------------DER TLV-----------------");
}
FIDOCheckDERAndGetKey(der, derLen, verbose, public_key, sizeof(public_key));
JsonSaveBufAsHexCompact(root, "$.AppData.DERPublicKey", public_key, sizeof(public_key));
Expand Down

0 comments on commit bf4cdf6

Please sign in to comment.