Skip to content

Commit

Permalink
emrtd: Ensure that emrtd_parse_ef_sod_hash_algo returns -1 on errors too
Browse files Browse the repository at this point in the history
  • Loading branch information
aveao committed Dec 29, 2020
1 parent 03be720 commit d1ec96e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions client/src/cmdhfemrtd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1544,6 +1544,9 @@ static int emrtd_parse_ef_sod_hash_algo(uint8_t *data, size_t datalen, int *hash
uint8_t hashalgoset[64] = { 0x00 };
size_t hashalgosetlen = 0;

// We'll return hash algo -1 if we can't find anything
*hashalgo = -1;

if (!emrtd_lds_get_data_by_tag(data, datalen, hashalgoset, &hashalgosetlen, 0x30, 0x00, false, true, 0)) {
PrintAndLogEx(ERR, "Failed to read hash algo set from EF_SOD.");
return false;
Expand Down Expand Up @@ -1571,8 +1574,6 @@ static int emrtd_parse_ef_sod_hash_algo(uint8_t *data, size_t datalen, int *hash
}
}

// Return hash algo -1 if we can't find anything
*hashalgo = -1;
PrintAndLogEx(ERR, "Failed to parse hash list (Unknown algo: %s). Hash verification won't be available.", sprint_hex_inrow(hashalgoset, hashalgosetlen));
return PM3_ESOFT;
}
Expand Down

0 comments on commit d1ec96e

Please sign in to comment.