likely fixed, needs more testing

master
Chris Punches 2025-03-16 02:07:38 -04:00
parent 28555d5773
commit 6d34c69b9f
1 changed files with 15 additions and 8 deletions

View File

@ -27,21 +27,28 @@ std::string get_configured_hash_algorithm()
std::string get_available_algorithms() std::string get_available_algorithms()
{ {
std::vector<std::string> algorithms;
std::vector<std::string> working_algorithms; std::vector<std::string> working_algorithms;
// Initialize OpenSSL // Initialize OpenSSL
OpenSSL_add_all_digests(); OpenSSL_add_all_digests();
// Test common hash algorithms explicitly to ensure they work for file hashing // Use OBJ_NAME_do_all to get all message digest algorithms
const char* common_algos[] = { struct AllDigestsCallback {
"md5", "sha1", "sha224", "sha256", "sha384", "sha512", static void callback(const OBJ_NAME* obj, void* arg) {
"ripemd160", "whirlpool", "sm3", "sha3-224", "sha3-256", if (obj->type == OBJ_NAME_TYPE_MD_METH) {
"sha3-384", "sha3-512" std::vector<std::string>* algs = static_cast<std::vector<std::string>*>(arg);
algs->push_back(obj->name);
}
}
}; };
for (const auto& algo_name : common_algos) { // Get all algorithm names
// Get the digest OBJ_NAME_do_all(OBJ_NAME_TYPE_MD_METH, AllDigestsCallback::callback, &algorithms);
const EVP_MD* md = EVP_get_digestbyname(algo_name);
// Test each algorithm with a complete hashing process
for (const auto& algo_name : algorithms) {
const EVP_MD* md = EVP_get_digestbyname(algo_name.c_str());
if (!md) continue; if (!md) continue;
// Create context // Create context