aboutsummaryrefslogtreecommitdiffstats
path: root/librecrypt_test_supported.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--librecrypt_test_supported.c59
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 */