/* See LICENSE file for copyright and license details. */ #include "common.h" static const char *default_algostrs[] = { #if defined(SUPPORT_MD2) && 0 /* skipping: compromised is theory */ "MD2", #endif #if defined(SUPPORT_MD4) && 0 /* skipping: compromised */ "MD4", #endif #if defined(SUPPORT_MD5) && 0 /* skipping: compromised */ "MD5", #endif #if defined(SUPPORT_RIPEMD_128) && 1 "RIPEMD-128", #endif #if defined(SUPPORT_RIPEMD_160) && 1 "RIPEMD-160", #endif #if defined(SUPPORT_RIPEMD_256) && 1 "RIPEMD-256", #endif #if defined(SUPPORT_RIPEMD_320) && 1 "RIPEMD-320", #endif #if defined(SUPPORT_SHA0) && 0 /* skipping: compromised */ "SHA0", #endif #if defined(SUPPORT_SHA1) && 0 /* skipping: compromised */ "SHA1", #endif #if defined(SUPPORT_SHA2) && 1 "SHA-224", "SHA-256", "SHA-384", "SHA-512", "SHA-512/224", "SHA-512/256", #endif #if defined(SUPPORT_SHA3) && 1 "SHA3-224", "SHA3-256", "SHA3-384", "SHA3-512", #endif #if defined(SUPPORT_KECCAK) && 1 "Keccak-224", "Keccak-256", "Keccak-384", "Keccak-512", #endif #if defined(SUPPORT_RAWSHAKE) && 1 "RawSHAKE128", "RawSHAKE256", "RawSHAKE512", #endif #if defined(SUPPORT_SHAKE) && 1 "SHAKE128", "SHAKE256", "SHAKE512", #endif #if defined(SUPPORT_BLAKE224) && 1 "BLAKE224", #endif #if defined(SUPPORT_BLAKE256) && 1 "BLAKE256", #endif #if defined(SUPPORT_BLAKE384) && 1 "BLAKE384", #endif #if defined(SUPPORT_BLAKE512) && 1 "BLAKE512", #endif NULL }; int main(int argc, char **argv) { struct algorithm default_algorithms[ELEMSOF(default_algostrs)]; struct config config = {.format = LOWERCASE_HEX | WITH_FILENAME | WITH_LF}; char stdin_str[] = "-"; char *stdin_array[] = {stdin_str, NULL}; char *algostrbuf = NULL; size_t i; int ret; libsimple_default_failure_exit = 2; cmdline(&argc, &argv, &config, &algostrbuf); if (!*argv) argv = stdin_array; if (config.verify) { ret = verify_checksums(argv, config.algorithms, config.nalgorithms, config.format, config.threads, config.warn_improper_format, config.hexinput); } else { if (!config.nalgorithms) { memset(default_algorithms, 0, sizeof(default_algorithms)); for (i = 0; default_algostrs[i]; i++) { default_algorithms[i].algostr = default_algostrs[i]; default_algorithms[i].result = NULL; } config.nalgorithms = i; if (!config.nalgorithms) { eprintf("not compiled to support any default hash functions"); } } ret = calculate_and_print_each(argv, config.algorithms, config.nalgorithms, config.threads, config.format, config.hexinput, config.recursive, config.xdev, config.xlink); } for (i = 0; i < config.nalgorithms; i++) free(config.algorithms[i].result); free(config.algorithms); free(algostrbuf); return ret; }