From 7947d2efb97341d500842ce0f8775224a7c9c8b6 Mon Sep 17 00:00:00 2001 From: Ave Date: Sat, 6 Feb 2021 19:11:45 +0300 Subject: [PATCH] emrtd: Calculate document type from MRZ length + Add the German Aufenthaltstitel --- client/src/cmdhfemrtd.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/client/src/cmdhfemrtd.c b/client/src/cmdhfemrtd.c index 604beb68c..229f84dee 100644 --- a/client/src/cmdhfemrtd.c +++ b/client/src/cmdhfemrtd.c @@ -1338,19 +1338,26 @@ static int emrtd_print_ef_dg1_info(uint8_t *data, size_t datalen) { // Determine and print the document type if (mrz[0] == 'I' && mrz[1] == 'P') { - td_variant = 1; PrintAndLogEx(SUCCESS, "Document Type.........: " _YELLOW_("Passport Card")); } else if (mrz[0] == 'I') { - td_variant = 1; PrintAndLogEx(SUCCESS, "Document Type.........: " _YELLOW_("ID Card")); } else if (mrz[0] == 'P') { - td_variant = 3; PrintAndLogEx(SUCCESS, "Document Type.........: " _YELLOW_("Passport")); + } else if (mrz[0] == 'A') { + PrintAndLogEx(SUCCESS, "Document Type.........: " _YELLOW_("German Residency Permit")); } else { - td_variant = 1; PrintAndLogEx(SUCCESS, "Document Type.........: " _YELLOW_("Unknown")); - PrintAndLogEx(INFO, "Assuming ID-style MRZ."); } + + if (mrzlen == 90) { + td_variant = 1; + } else if (mrzlen == 88) { + td_variant = 3; + } else { + PrintAndLogEx(ERR, "MRZ length (%zu) is wrong.", mrzlen); + return PM3_ESOFT; + } + PrintAndLogEx(SUCCESS, "Document Form Factor..: " _YELLOW_("TD%i"), td_variant); // Print the MRZ