From f47b617a58c6851da9a456c56adb8f5170bae6e6 Mon Sep 17 00:00:00 2001 From: Ave Date: Tue, 29 Dec 2020 03:51:30 +0300 Subject: [PATCH] emrtd: Check emrtd_parse_ef_sod_hash_algo output --- client/src/cmdhfemrtd.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/client/src/cmdhfemrtd.c b/client/src/cmdhfemrtd.c index e782e43ab..089bb6633 100644 --- a/client/src/cmdhfemrtd.c +++ b/client/src/cmdhfemrtd.c @@ -1550,6 +1550,9 @@ static int emrtd_parse_ef_sod_hash_algo(uint8_t *data, size_t datalen, int *hash *hashalgo = 1; } else if (memcmp(emrtd_hashalgo_sha512, hashalgoset, 11) == 0) { *hashalgo = 3; + } else { + *hashalgo = 0; + return PM3_ESOFT; } return PM3_SUCCESS; @@ -1576,7 +1579,9 @@ static int emrtd_parse_ef_sod_hashes(uint8_t *data, size_t datalen, uint8_t *has PrintAndLogEx(DEBUG, "hash data: %s", sprint_hex_inrow(emrtdsig, emrtdsiglen)); - emrtd_parse_ef_sod_hash_algo(emrtdsig, emrtdsiglen, hashalgo); + if (emrtd_parse_ef_sod_hash_algo(emrtdsig, emrtdsiglen, hashalgo) != PM3_SUCCESS) { + PrintAndLogEx(ERR, "Failed to parse hash list. Unknown algo?"); + } if (!emrtd_lds_get_data_by_tag(emrtdsig, emrtdsiglen, hashlist, &hashlistlen, 0x30, 0x00, false, true, 1)) { PrintAndLogEx(ERR, "Failed to read hash list from EF_SOD.");