From b29f4153e83623f24bebe99976e1368ef31bb008 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Thu, 21 May 2026 17:12:20 +0200 Subject: Add support for custom hash functions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- librecrypt_find_first_algorithm_.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'librecrypt_find_first_algorithm_.c') diff --git a/librecrypt_find_first_algorithm_.c b/librecrypt_find_first_algorithm_.c index ebe3699..ff967c9 100644 --- a/librecrypt_find_first_algorithm_.c +++ b/librecrypt_find_first_algorithm_.c @@ -10,8 +10,22 @@ librecrypt_find_first_algorithm_(const char *settings, size_t len, LIBRECRYPT_CO const struct librecrypt_algorithm *algo, *found = NULL; size_t i; - (void) ctx; /* TODO */ + /* Search application provided hash functions first; + * they should have priority of they report the same + * priority as library-provided hash functions */ + if (!ctx) + goto library_provided; + /* TODO test */ + for (i = 0u; i < ctx->nalgos; i++) { + algo = &ctx->algos[i]; + r = (*algo->is_algorithm)(settings, len); + if (r > priority) { + priority = r; + found = algo; + } + } +library_provided: for (i = 0u;; i++) { /* Get next algorithm in the list */ algo = &librecrypt_algorithms_[i]; -- cgit v1.3.1