VSDC up to CDOL2 calc

This commit is contained in:
merlokk 2019-01-10 18:33:21 +02:00
parent 628eceb5ed
commit eaedf7f811
3 changed files with 30 additions and 1 deletions

View file

@ -1209,6 +1209,23 @@ int CmdEMVExec(const char *cmd) {
PrintAndLogEx(NORMAL, "* * Host Response: `%s`", HostResponse); PrintAndLogEx(NORMAL, "* * Host Response: `%s`", HostResponse);
tlvdb_change_or_add_node(tlvRoot, 0x8a, sizeof(HostResponse) - 1, (const unsigned char *)HostResponse); tlvdb_change_or_add_node(tlvRoot, 0x8a, sizeof(HostResponse) - 1, (const unsigned char *)HostResponse);
// needs to send AC2 command (res == ARQC)
uint8_t CID = 0;
tlvdb_get_uint8(tlvRoot, 0x9f27, &CID);
if ((CID & 0xc0) == 0x80) {
PrintAndLogEx(NORMAL, "* * Calc CDOL2");
struct tlv *cdol_data_tlv = dol_process(tlvdb_get(tlvRoot, 0x8d, NULL), tlvRoot, 0x01); // 0x01 - dummy tag
if (!cdol_data_tlv) {
PrintAndLogEx(WARNING, "Error: can't create CDOL2 TLV.");
dreturn(6);
}
PrintAndLogEx(NORMAL, "CDOL2 data[%d]: %s", cdol_data_tlv->len, sprint_hex(cdol_data_tlv->value, cdol_data_tlv->len));
PrintAndLogEx(NORMAL, "* * AC2");
}
} }

View file

@ -469,7 +469,10 @@ const struct tlv *tlvdb_get_inchild(const struct tlvdb *tlvdb, tlv_tag_t tag, co
} }
const struct tlv *tlvdb_get_tlv(const struct tlvdb *tlvdb) { const struct tlv *tlvdb_get_tlv(const struct tlvdb *tlvdb) {
return &tlvdb->tag; if (tlvdb)
return &tlvdb->tag;
else
return NULL;
} }
unsigned char *tlv_encode(const struct tlv *tlv, size_t *len) unsigned char *tlv_encode(const struct tlv *tlv, size_t *len)
@ -546,6 +549,13 @@ struct tlvdb *tlvdb_elm_get_parent(struct tlvdb *tlvdb)
return tlvdb->parent; return tlvdb->parent;
} }
bool tlvdb_get_uint8(struct tlvdb *tlvRoot, tlv_tag_t tag, uint8_t *value)
{
const struct tlvdb *tlvdb = tlvdb_get(tlvRoot, tag, NULL);
const struct tlv *tlvelm = tlvdb_get_tlv(tlvdb);
return tlv_get_uint8(tlvelm, value);
}
bool tlv_get_uint8(const struct tlv *etlv, uint8_t *value) bool tlv_get_uint8(const struct tlv *etlv, uint8_t *value)
{ {
*value = 0; *value = 0;

View file

@ -65,4 +65,6 @@ bool tlv_equal(const struct tlv *a, const struct tlv *b);
bool tlv_get_uint8(const struct tlv *etlv, uint8_t *value); bool tlv_get_uint8(const struct tlv *etlv, uint8_t *value);
bool tlv_get_int(const struct tlv *etlv, int *value); bool tlv_get_int(const struct tlv *etlv, int *value);
bool tlvdb_get_uint8(struct tlvdb *tlvRoot, tlv_tag_t tag, uint8_t *value);
#endif #endif