mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 05:43:48 -07:00
fixing textual output of ASN1 printing
This commit is contained in:
parent
e6e58227cb
commit
ea416c3694
2 changed files with 26 additions and 10 deletions
|
@ -35,6 +35,7 @@ enum asn1_tag_t {
|
||||||
ASN1_TAG_UTC_TIME,
|
ASN1_TAG_UTC_TIME,
|
||||||
ASN1_TAG_STR_TIME,
|
ASN1_TAG_STR_TIME,
|
||||||
ASN1_TAG_OBJECT_ID,
|
ASN1_TAG_OBJECT_ID,
|
||||||
|
ASN1_TAG_HEX,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct asn1_tag {
|
struct asn1_tag {
|
||||||
|
@ -157,8 +158,11 @@ static void asn1_tag_dump_str_time(const struct tlv *tlv, const struct asn1_tag
|
||||||
}
|
}
|
||||||
|
|
||||||
static void asn1_tag_dump_string(const struct tlv *tlv, const struct asn1_tag *tag, int level) {
|
static void asn1_tag_dump_string(const struct tlv *tlv, const struct asn1_tag *tag, int level) {
|
||||||
PrintAndLogEx(NORMAL, " value: '" NOLF);
|
PrintAndLogEx(NORMAL, " value: '%s'", sprint_hex(tlv->value, tlv->len));
|
||||||
PrintAndLogEx(NORMAL, "%s'", sprint_hex(tlv->value, tlv->len));
|
}
|
||||||
|
|
||||||
|
static void asn1_tag_dump_hex(const struct tlv *tlv, const struct asn1_tag *tag, int level) {
|
||||||
|
PrintAndLogEx(NORMAL, " value: '%s'", sprint_hex_inrow(tlv->value, tlv->len));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void asn1_tag_dump_octet_string(const struct tlv *tlv, const struct asn1_tag *tag, int level, bool *needdump) {
|
static void asn1_tag_dump_octet_string(const struct tlv *tlv, const struct asn1_tag *tag, int level, bool *needdump) {
|
||||||
|
@ -170,7 +174,7 @@ static void asn1_tag_dump_octet_string(const struct tlv *tlv, const struct asn1_
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*needdump) {
|
if (*needdump) {
|
||||||
PrintAndLogEx(NORMAL, "'");
|
PrintAndLogEx(NORMAL, "");
|
||||||
} else {
|
} else {
|
||||||
PrintAndLogEx(NORMAL, " " NOLF);
|
PrintAndLogEx(NORMAL, " " NOLF);
|
||||||
asn1_tag_dump_string(tlv, tag, level);
|
asn1_tag_dump_string(tlv, tag, level);
|
||||||
|
@ -314,18 +318,26 @@ bool asn1_tag_dump(const struct tlv *tlv, int level, bool *candump) {
|
||||||
|
|
||||||
const struct asn1_tag *tag = asn1_get_tag(tlv);
|
const struct asn1_tag *tag = asn1_get_tag(tlv);
|
||||||
|
|
||||||
|
/*
|
||||||
|
if ((tlv->tag & 0x20) == 0x20 ) {
|
||||||
|
} else if ((tlv->tag & 0x80) == 0x80 ) {
|
||||||
|
} else {
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
PrintAndLogEx(INFO,
|
PrintAndLogEx(INFO,
|
||||||
"%*s-- %2x [%02zx] '"_YELLOW_("%s") "' :" NOLF
|
"%*s-- %2x [%02zx] '"_YELLOW_("%s") "'" NOLF
|
||||||
, (level * 4)
|
, (level * 4)
|
||||||
, " "
|
, " "
|
||||||
, tlv->tag
|
, tlv->tag
|
||||||
, tlv->len
|
, tlv->len
|
||||||
, tag->name
|
, tag->name
|
||||||
);
|
);
|
||||||
|
|
||||||
switch (tag->type) {
|
switch (tag->type) {
|
||||||
case ASN1_TAG_GENERIC:
|
case ASN1_TAG_GENERIC:
|
||||||
PrintAndLogEx(NORMAL, "");
|
PrintAndLogEx(NORMAL, "");
|
||||||
|
// maybe print number of elements?
|
||||||
break;
|
break;
|
||||||
case ASN1_TAG_STRING:
|
case ASN1_TAG_STRING:
|
||||||
asn1_tag_dump_string(tlv, tag, level);
|
asn1_tag_dump_string(tlv, tag, level);
|
||||||
|
@ -352,6 +364,10 @@ bool asn1_tag_dump(const struct tlv *tlv, int level, bool *candump) {
|
||||||
asn1_tag_dump_object_id(tlv, tag, level);
|
asn1_tag_dump_object_id(tlv, tag, level);
|
||||||
*candump = false;
|
*candump = false;
|
||||||
break;
|
break;
|
||||||
|
case ASN1_TAG_HEX:
|
||||||
|
asn1_tag_dump_hex(tlv, tag, level);
|
||||||
|
*candump = false;
|
||||||
|
break;
|
||||||
};
|
};
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -65,7 +65,7 @@ static void asn1_print_cb(void *data, const struct tlv *tlv, int level, bool is_
|
||||||
bool candump = true;
|
bool candump = true;
|
||||||
asn1_tag_dump(tlv, level, &candump);
|
asn1_tag_dump(tlv, level, &candump);
|
||||||
if (is_leaf && candump) {
|
if (is_leaf && candump) {
|
||||||
print_buffer(tlv->value, tlv->len, level);
|
print_buffer(tlv->value, tlv->len, level + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue