From adfa8e1265f6155d1a582baa9929af198bb5d4de Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Fri, 1 May 2026 17:45:39 +0200 Subject: Misc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- librecrypt_test_supported.c | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) (limited to 'librecrypt_test_supported.c') diff --git a/librecrypt_test_supported.c b/librecrypt_test_supported.c index fad8bd9..71daad1 100644 --- a/librecrypt_test_supported.c +++ b/librecrypt_test_supported.c @@ -7,38 +7,35 @@ int librecrypt_test_supported(const char *phrase, size_t len, int text, const char *settings) { const struct algorithm *algo; - size_t n, prefix; - int has_next; + size_t n; + /* For each chained algorithm*/ for (;;) { - has_next = 0; - for (n = 0u; settings[n]; n++) { - if (settings[n] == LIBRECRYPT_ALGORITHM_LINK_DELIMITER) { - has_next = 1; + /* Measure until next '>' */ + for (n = 0u; settings[n]; n++) + if (settings[n] == LIBRECRYPT_ALGORITHM_LINK_DELIMITER) break; - } - } + /* Identify algorithm */ algo = librecrypt_find_first_algorithm_(settings, n); if (!algo) return 0; - prefix = (*algo->get_prefix)(settings, n); - if (has_next && prefix < n) + /* Check configuration and input support, and get hash size */ + if (!(*algo->test_supported)(phrase, len, text, settings, n, &len)) return 0; - if (!(*algo->test_supported)(phrase, len, text, settings, prefix)) - return 0; - - if (!has_next) + /* Return just process last chained algorithm */ + if (!settings[n]) return 1; + /* Hashes are binary */ phrase = NULL; - len = algo->hash_size; text = 0; - settings = &settings[n]; - settings++; + /* Goto next algorithm */ + settings = &settings[n]; /* conf */ + settings++; /* '>' */ } } -- cgit v1.2.3-70-g09d2