diff options
| author | Mattias Andrée <m@maandree.se> | 2026-04-26 22:36:47 +0200 |
|---|---|---|
| committer | Mattias Andrée <m@maandree.se> | 2026-04-26 22:36:47 +0200 |
| commit | d77ab463184d113ca6119403887c9f4ed0dfdf0b (patch) | |
| tree | ca8a1de443f90a4b7def56ea5b61c96aaa949f45 /librecrypt_test_supported.c | |
| download | librecrypt-d77ab463184d113ca6119403887c9f4ed0dfdf0b.tar.gz librecrypt-d77ab463184d113ca6119403887c9f4ed0dfdf0b.tar.bz2 librecrypt-d77ab463184d113ca6119403887c9f4ed0dfdf0b.tar.xz | |
First commit
Signed-off-by: Mattias Andrée <m@maandree.se>
Diffstat (limited to '')
| -rw-r--r-- | librecrypt_test_supported.c | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/librecrypt_test_supported.c b/librecrypt_test_supported.c new file mode 100644 index 0000000..fad8bd9 --- /dev/null +++ b/librecrypt_test_supported.c @@ -0,0 +1,59 @@ +/* See LICENSE file for copyright and license details. */ +#include "common.h" +#ifndef TEST + + +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; + + for (;;) { + has_next = 0; + for (n = 0u; settings[n]; n++) { + if (settings[n] == LIBRECRYPT_ALGORITHM_LINK_DELIMITER) { + has_next = 1; + break; + } + } + + algo = librecrypt_find_first_algorithm_(settings, n); + if (!algo) + return 0; + + prefix = (*algo->get_prefix)(settings, n); + if (has_next && prefix < n) + return 0; + + if (!(*algo->test_supported)(phrase, len, text, settings, prefix)) + return 0; + + if (!has_next) + return 1; + + phrase = NULL; + len = algo->hash_size; + text = 0; + + settings = &settings[n]; + settings++; + } +} + + +#else + + +int +main(void) +{ + SET_UP_ALARM(); + + return 0; +} + + +#endif +/* TODO test */ |
