diff options
| author | Mattias Andrée <m@maandree.se> | 2026-05-21 17:12:20 +0200 |
|---|---|---|
| committer | Mattias Andrée <m@maandree.se> | 2026-05-21 17:12:20 +0200 |
| commit | b29f4153e83623f24bebe99976e1368ef31bb008 (patch) | |
| tree | 65473709df1194a2f9277dc5fb47add5e41430c0 /librecrypt_find_first_algorithm_.c | |
| parent | Add (so far untested and undocument) support for pepper (diff) | |
| download | librecrypt-b29f4153e83623f24bebe99976e1368ef31bb008.tar.gz librecrypt-b29f4153e83623f24bebe99976e1368ef31bb008.tar.bz2 librecrypt-b29f4153e83623f24bebe99976e1368ef31bb008.tar.xz | |
Add support for custom hash functions
Signed-off-by: Mattias Andrée <m@maandree.se>
Diffstat (limited to '')
| -rw-r--r-- | librecrypt_find_first_algorithm_.c | 16 |
1 files changed, 15 insertions, 1 deletions
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]; |
