aboutsummaryrefslogtreecommitdiffstats
path: root/librecrypt_test_supported.c
diff options
context:
space:
mode:
authorMattias Andrée <m@maandree.se>2026-05-01 17:45:39 +0200
committerMattias Andrée <m@maandree.se>2026-05-01 17:45:39 +0200
commitadfa8e1265f6155d1a582baa9929af198bb5d4de (patch)
treee3cee62aa5a8768621cd294295f787b8cc54141b /librecrypt_test_supported.c
parentAdd librecrypt.7 and README (diff)
downloadlibrecrypt-adfa8e1265f6155d1a582baa9929af198bb5d4de.tar.gz
librecrypt-adfa8e1265f6155d1a582baa9929af198bb5d4de.tar.bz2
librecrypt-adfa8e1265f6155d1a582baa9929af198bb5d4de.tar.xz
Misc
Signed-off-by: Mattias Andrée <m@maandree.se>
Diffstat (limited to '')
-rw-r--r--librecrypt_test_supported.c31
1 files changed, 14 insertions, 17 deletions
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++; /* '>' */
}
}