Skip to content

Commit

Permalink
fix(checksum): disable extended output algorithms (e.g. shake(128|256))
Browse files Browse the repository at this point in the history
  • Loading branch information
mhx committed Nov 20, 2024
1 parent b14b3b0 commit afbd85e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/checksum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ std::unordered_set<std::string> supported_algorithms{
"xxh3-128",
};

constexpr std::array unsupported_algorithms{
"shake128"sv,
"shake256"sv,
};

std::string make_hexdigest(checksum::impl& cs) {
std::array<char, EVP_MAX_MD_SIZE> tmp;
auto dig_size = cs.digest_size();
Expand Down Expand Up @@ -102,7 +107,9 @@ class checksum_evp : public checksum::impl {
std::vector<std::string> available;
::EVP_MD_do_all(
[](const ::EVP_MD*, const char* from, const char* to, void* vec) {
if (!to) {
// TODO: C++23: use std::ranges::contains
if (!to && std::ranges::find(unsupported_algorithms, from) ==
unsupported_algorithms.end()) {
reinterpret_cast<std::vector<std::string>*>(vec)->emplace_back(
from);
}
Expand Down

0 comments on commit afbd85e

Please sign in to comment.