Return true if HEX_DIGEST is the same as the hex-encoded digest of the DIGEST_LENGTH/8 bytes at BIN_BUFFER. */
| 1340 | /* Return true if HEX_DIGEST is the same as the hex-encoded digest of the |
| 1341 | DIGEST_LENGTH/8 bytes at BIN_BUFFER. */ |
| 1342 | static bool |
| 1343 | hex_equal (unsigned char const *hex_digest, unsigned char const *bin_buffer) |
| 1344 | { |
| 1345 | static const char bin2hex[] = { '0', '1', '2', '3', |
| 1346 | '4', '5', '6', '7', |
| 1347 | '8', '9', 'a', 'b', |
| 1348 | 'c', 'd', 'e', 'f' }; |
| 1349 | idx_t digest_bin_bytes = digest_hex_bytes >> 1; |
| 1350 | |
| 1351 | /* Compare generated binary number with text representation |
| 1352 | in check file. Ignore case of hex digits. */ |
| 1353 | idx_t cnt; |
| 1354 | for (cnt = 0; cnt < digest_bin_bytes; ++cnt) |
| 1355 | { |
| 1356 | if (c_tolower (hex_digest[2 * cnt]) |
| 1357 | != bin2hex[bin_buffer[cnt] >> 4] |
| 1358 | || (c_tolower (hex_digest[2 * cnt + 1]) |
| 1359 | != (bin2hex[bin_buffer[cnt] & 0xf]))) |
| 1360 | break; |
| 1361 | } |
| 1362 | return cnt == digest_bin_bytes; |
| 1363 | } |
| 1364 | |
| 1365 | static bool |
| 1366 | digest_check (char const *checkfile_name) |