if SSAD present before check it (A@Pay)

This commit is contained in:
merlokk 2021-04-08 17:59:47 +03:00
commit 2f634923bb
2 changed files with 16 additions and 12 deletions

View file

@ -349,7 +349,7 @@ unsigned char *emv_pki_sdatl_fill(const struct tlvdb *db, size_t *sdatl_len) {
} }
struct tlvdb *emv_pki_recover_dac_ex(const struct emv_pk *enc_pk, const struct tlvdb *db, const struct tlv *sda_tlv, bool showData) { struct tlvdb *emv_pki_recover_dac_ex(const struct emv_pk *enc_pk, const struct tlvdb *db, const struct tlv *sda_tlv, bool showData) {
size_t data_len; size_t data_len = 0;
// Static Data Authentication Tag List // Static Data Authentication Tag List
size_t sdatl_len; size_t sdatl_len;

View file

@ -970,18 +970,22 @@ int trCDA(struct tlvdb *tlv, struct tlvdb *ac_tlv, struct tlv *pdol_data_tlv, st
sprint_hex(icc_pk->serial, 3) sprint_hex(icc_pk->serial, 3)
); );
// Signed Static Application Data (SSAD) check
const struct tlv *ssad_tlv = tlvdb_get(tlv, 0x93, NULL);
if (ssad_tlv && ssad_tlv->len > 1) {
struct tlvdb *dac_db = emv_pki_recover_dac(issuer_pk, tlv, sda_tlv); struct tlvdb *dac_db = emv_pki_recover_dac(issuer_pk, tlv, sda_tlv);
if (dac_db) { if (dac_db) {
const struct tlv *dac_tlv = tlvdb_get(dac_db, 0x9f45, NULL); const struct tlv *dac_tlv = tlvdb_get(dac_db, 0x9f45, NULL);
PrintAndLogEx(SUCCESS, "SSAD verified (%s) (%02hhx:%02hhx)", _GREEN_("ok"), dac_tlv->value[0], dac_tlv->value[1]); PrintAndLogEx(SUCCESS, "Signed Static Application Data (SSAD) verified (%s) (%02hhx:%02hhx)", _GREEN_("ok"), dac_tlv->value[0], dac_tlv->value[1]);
tlvdb_add(tlv, dac_db); tlvdb_add(tlv, dac_db);
} else { } else {
PrintAndLogEx(ERR, "Error: SSAD verify error"); PrintAndLogEx(ERR, "Error: Signed Static Application Data (SSAD) verify error");
emv_pk_free(pk); emv_pk_free(pk);
emv_pk_free(issuer_pk); emv_pk_free(issuer_pk);
emv_pk_free(icc_pk); emv_pk_free(icc_pk);
return 4; return 4;
} }
}
PrintAndLogEx(INFO, "* * Check Signed Dynamic Application Data (SDAD)"); PrintAndLogEx(INFO, "* * Check Signed Dynamic Application Data (SDAD)");
struct tlvdb *idn_db = emv_pki_perform_cda_ex(icc_pk, tlv, ac_tlv, struct tlvdb *idn_db = emv_pki_perform_cda_ex(icc_pk, tlv, ac_tlv,