data asn1 now decodes timestamp correct... Or I hope so. And strings values are now highlighted with GREEN

This commit is contained in:
iceman1001 2023-03-12 19:18:55 +01:00
parent 4a7713070b
commit d11d1fbc33

View file

@ -116,7 +116,7 @@ static void asn1_tag_dump_str_time(const struct tlv *tlv, const struct asn1_tag
int len = tlv->len; int len = tlv->len;
*needdump = false; *needdump = false;
int startindx = longyear ? 4 : 2; int startidx = longyear ? 4 : 2;
if (len > 4) { if (len > 4) {
PrintAndLogEx(NORMAL, " value: '" NOLF); PrintAndLogEx(NORMAL, " value: '" NOLF);
@ -125,34 +125,38 @@ static void asn1_tag_dump_str_time(const struct tlv *tlv, const struct asn1_tag
if (longyear == false) if (longyear == false)
PrintAndLogEx(NORMAL, "20" NOLF); PrintAndLogEx(NORMAL, "20" NOLF);
PrintAndLogEx(NORMAL, "%s-" NOLF, sprint_hex(tlv->value, startindx)); PrintAndLogEx(NORMAL, "%.*s-" NOLF, startidx, tlv->value);
if (len < startindx + 2) if (len < startidx + 2)
break; break;
// month // month
PrintAndLogEx(NORMAL, "%02x%02x-" NOLF, tlv->value[startindx], tlv->value[startindx + 1]); PrintAndLogEx(NORMAL, "%.*s-" NOLF, 2, tlv->value + startidx );
if (len < startindx + 4) if (len < startidx + 4)
break; break;
// day // day
PrintAndLogEx(NORMAL, "%02x%02x " NOLF, tlv->value[startindx + 2], tlv->value[startindx + 3]); PrintAndLogEx(NORMAL, "%.*s " NOLF, 2, tlv->value + startidx + 2);
if (len < startindx + 6) if (len < startidx + 6)
break; break;
// hour // hour
PrintAndLogEx(NORMAL, "%02x%02x:" NOLF, tlv->value[startindx + 4], tlv->value[startindx + 5]); PrintAndLogEx(NORMAL, "%.*s:" NOLF, 2, tlv->value + startidx + 4);
if (len < startindx + 8) if (len < startidx + 8)
break; break;
// min // min
PrintAndLogEx(NORMAL, "%02x%02x:" NOLF, tlv->value[startindx + 6], tlv->value[startindx + 7]); PrintAndLogEx(NORMAL, "%.*s:" NOLF, 2, tlv->value + startidx + 6);
if (len < startindx + 10) if (len < startidx + 10)
break; break;
// sec // sec
PrintAndLogEx(NORMAL, "%02x%02x" NOLF, tlv->value[startindx + 8], tlv->value[startindx + 9]); PrintAndLogEx(NORMAL, "%.*s" NOLF, 2, tlv->value + startidx + 8);
if (len < startindx + 11) if (len < startidx + 11)
break; break;
// time zone // time zone
PrintAndLogEx(NORMAL, " zone: %.*s" NOLF, len - 10 - (longyear ? 4 : 2), &tlv->value[startindx + 10]); PrintAndLogEx(NORMAL, " zone: %.*s" NOLF, len - 10 - (longyear ? 4 : 2), tlv->value + startidx + 10);
break; break;
} }
PrintAndLogEx(NORMAL, "'"); PrintAndLogEx(NORMAL, "'");
@ -163,7 +167,7 @@ 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: '%.*s' hex: '%s'", tlv->len, tlv->value, sprint_hex(tlv->value, tlv->len)); PrintAndLogEx(NORMAL, " value: '" _GREEN_("%.*s") "' hex: '%s'", tlv->len, tlv->value, sprint_hex(tlv->value, tlv->len));
} }
static void asn1_tag_dump_hex(const struct tlv *tlv, const struct asn1_tag *tag, int level) { static void asn1_tag_dump_hex(const struct tlv *tlv, const struct asn1_tag *tag, int level) {