remove dump_buffer_simple

This commit is contained in:
iceman1001 2020-11-11 18:05:05 +01:00
commit bf4cdf6eb7
4 changed files with 16 additions and 26 deletions

View file

@ -312,8 +312,8 @@ static int cmd_hf_fido_register(const char *cmd) {
int derp = 67 + keyHandleLen; int derp = 67 + keyHandleLen;
int derLen = (buf[derp + 2] << 8) + buf[derp + 3] + 4; int derLen = (buf[derp + 2] << 8) + buf[derp + 3] + 4;
if (verbose2) { if (verbose2) {
PrintAndLogEx(INFO, "DER certificate[%d]:"); PrintAndLogEx(INFO, "DER certificate[%d]:", derLen);
PrintAndLogEx(INFO, "------------------DER-------------------", derLen); PrintAndLogEx(INFO, "------------------DER-------------------");
PrintAndLogEx(INFO, "%s", sprint_hex(buf + derp, derLen)); PrintAndLogEx(INFO, "%s", sprint_hex(buf + derp, derLen));
PrintAndLogEx(INFO, "----------------DER---------------------"); PrintAndLogEx(INFO, "----------------DER---------------------");
} else { } else {

View file

@ -23,23 +23,13 @@
# define PRINT_INDENT(level) {for (int myi = 0; myi < (level); myi++) fprintf(f, " ");} # define PRINT_INDENT(level) {for (int myi = 0; myi < (level); myi++) fprintf(f, " ");}
#endif #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) { void dump_buffer(const unsigned char *ptr, size_t len, FILE *f, int level) {
int i, j; int j;
if (!f) if (!f)
f = stdout; f = stdout;
for (i = 0; i < len; i += 16) { for (int i = 0; i < len; i += 16) {
PRINT_INDENT(level); PRINT_INDENT(level);
fprintf(f, "\t%02x:", i); fprintf(f, "\t%02x:", i);
for (j = 0; j < 16; j++) { for (j = 0; j < 16; j++) {

View file

@ -20,7 +20,6 @@
#include <stdio.h> // FILE #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(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); void dump_buffer_tab(const unsigned char *ptr, size_t len, FILE *f, int tabs);

View file

@ -274,7 +274,7 @@ int FIDOCheckDERAndGetKey(uint8_t *der, size_t derLen, bool verbose, uint8_t *pu
} }
if (verbose) if (verbose)
PrintAndLogEx(NORMAL, "------------------DER-------------------"); PrintAndLogEx(INFO, "------------------DER-------------------");
mbedtls_x509_crt_free(&cert); mbedtls_x509_crt_free(&cert);
mbedtls_x509_crt_free(&cacert); mbedtls_x509_crt_free(&cacert);
@ -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); int res = ecdsa_asn1_get_signature(sign, signLen, rval, sval);
if (!res) { if (!res) {
if (verbose) { if (verbose) {
PrintAndLogEx(NORMAL, " r: %s", sprint_hex(rval, 32)); PrintAndLogEx(INFO, " r: %s", sprint_hex(rval, 32));
PrintAndLogEx(NORMAL, " s: %s", sprint_hex(sval, 32)); PrintAndLogEx(INFO, " s: %s", sprint_hex(sval, 32));
} }
uint8_t clientDataHash[32] = {0}; uint8_t clientDataHash[32] = {0};
@ -488,9 +488,9 @@ int FIDO2MakeCredentionalParseRes(json_t *root, uint8_t *data, size_t dataLen, b
if (showCBOR) { if (showCBOR) {
PrintAndLogEx(INFO, "COSE structure:"); PrintAndLogEx(INFO, "COSE structure:");
PrintAndLogEx(NORMAL, "---------------- CBOR ------------------"); PrintAndLogEx(INFO, "---------------- CBOR ------------------");
TinyCborPrintFIDOPackage(fido2COSEKey, true, &ubuf[55 + cridlen], cplen); TinyCborPrintFIDOPackage(fido2COSEKey, true, &ubuf[55 + cridlen], cplen);
PrintAndLogEx(NORMAL, "---------------- CBOR ------------------"); PrintAndLogEx(INFO, "---------------- CBOR ------------------");
} }
res = COSEGetECDSAKey(&ubuf[55 + cridlen], cplen, verbose, coseKey); res = COSEGetECDSAKey(&ubuf[55 + cridlen], cplen, verbose, coseKey);
@ -542,11 +542,12 @@ int FIDO2MakeCredentionalParseRes(json_t *root, uint8_t *data, size_t dataLen, b
res = CborGetArrayBinStringValue(&mapsmt, der, sizeof(der), &derLen); res = CborGetArrayBinStringValue(&mapsmt, der, sizeof(der), &derLen);
cbor_check(res); cbor_check(res);
if (verbose2) { if (verbose2) {
PrintAndLogEx(NORMAL, "DER certificate[%zu]:\n------------------DER-------------------", derLen); PrintAndLogEx(INFO, "DER certificate[%zu]:", derLen);
dump_buffer_simple((const unsigned char *)der, derLen, NULL); PrintAndLogEx(INFO, "------------------DER-------------------");
PrintAndLogEx(NORMAL, "\n----------------DER---------------------"); PrintAndLogEx(INFO, "%s", sprint_hex(der, derLen));
PrintAndLogEx(INFO, "----------------DER---------------------");
} else { } 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); JsonSaveBufAsHexCompact(root, "$.AppData.DER", der, derLen);
} }
@ -558,9 +559,9 @@ int FIDO2MakeCredentionalParseRes(json_t *root, uint8_t *data, size_t dataLen, b
// print DER certificate in TLV view // print DER certificate in TLV view
if (showDERTLV) { if (showDERTLV) {
PrintAndLogEx(NORMAL, "----------------DER TLV-----------------"); PrintAndLogEx(INFO, "----------------DER TLV-----------------");
asn1_print(der, derLen, " "); asn1_print(der, derLen, " ");
PrintAndLogEx(NORMAL, "----------------DER TLV-----------------"); PrintAndLogEx(INFO, "----------------DER TLV-----------------");
} }
FIDOCheckDERAndGetKey(der, derLen, verbose, public_key, sizeof(public_key)); FIDOCheckDERAndGetKey(der, derLen, verbose, public_key, sizeof(public_key));
JsonSaveBufAsHexCompact(root, "$.AppData.DERPublicKey", public_key, sizeof(public_key)); JsonSaveBufAsHexCompact(root, "$.AppData.DERPublicKey", public_key, sizeof(public_key));