emrtd: Dump image from EF_DG7 too

This commit is contained in:
Ave 2020-12-19 03:27:48 +03:00
commit 6ca472fc8f

View file

@ -735,7 +735,6 @@ static bool emrtd_dump_ef_dg2(uint8_t *file_contents, int file_length) {
return true;
}
static bool emrtd_dump_ef_dg5(uint8_t *file_contents, int file_length) {
uint8_t data[EMRTD_MAX_FILE_SIZE];
int datalen = 0;
@ -754,6 +753,24 @@ static bool emrtd_dump_ef_dg5(uint8_t *file_contents, int file_length) {
return true;
}
static bool emrtd_dump_ef_dg7(uint8_t *file_contents, int file_length) {
uint8_t data[EMRTD_MAX_FILE_SIZE];
int datalen = 0;
// If we can't find image in EF_DG7, return false.
if (emrtd_lds_get_data_by_tag(file_contents, file_length, data, &datalen, 0x5F, 0x42, true) == false) {
return false;
}
if (datalen < EMRTD_MAX_FILE_SIZE) {
saveFile("EF_DG7", ".jpg", data, datalen);
} else {
PrintAndLogEx(ERR, "error (emrtd_dump_ef_dg7) datalen out-of-bounds");
return false;
}
return true;
}
static bool emrtd_dump_ef_sod(uint8_t *file_contents, int file_length) {
int fieldlen = emrtd_get_asn1_field_length(file_contents, file_length, 1);
int datalen = emrtd_get_asn1_data_length(file_contents, file_length, 1);
@ -783,6 +800,8 @@ static bool emrtd_dump_file(uint8_t *ks_enc, uint8_t *ks_mac, uint8_t *ssc, cons
emrtd_dump_ef_dg2(response, resplen);
} else if (strcmp(file, EMRTD_EF_DG5) == 0) {
emrtd_dump_ef_dg5(response, resplen);
} else if (strcmp(file, EMRTD_EF_DG7) == 0) {
emrtd_dump_ef_dg7(response, resplen);
} else if (strcmp(file, EMRTD_EF_SOD) == 0) {
emrtd_dump_ef_sod(response, resplen);
}