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_make_settings.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 'librecrypt_make_settings.c')
| -rw-r--r-- | librecrypt_make_settings.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/librecrypt_make_settings.c b/librecrypt_make_settings.c new file mode 100644 index 0000000..99c7e3b --- /dev/null +++ b/librecrypt_make_settings.c @@ -0,0 +1,50 @@ +/* See LICENSE file for copyright and license details. */ +#include "common.h" +#ifndef TEST + + +ssize_t +librecrypt_make_settings(char *out_buffer, size_t size, const char *algorithm, size_t memcost, uintmax_t timecost, + int gensalt, ssize_t (*rng)(void *out, size_t n, void *user), void *user) +{ + const struct algorithm *algo; + + if (!algorithm) { + algo = &librecrypt_algorithms_[0]; + if (IS_END_OF_ALGORITHMS(algo)) + goto enosys; + } else { + if (strchr(algorithm, LIBRECRYPT_ALGORITHM_LINK_DELIMITER)) { + errno = EINVAL; + return -1; + } + algo = librecrypt_find_first_algorithm_(algorithm, strlen(algorithm)); + if (!algo) + goto enosys; + } + + if (!rng) + rng = &librecrypt_rng_; + + return (*algo->make_settings)(out_buffer, size, algorithm, memcost, timecost, gensalt, rng, user); + +enosys: + errno = ENOSYS; + return -1; +} + + +#else + + +int +main(void) +{ + SET_UP_ALARM(); + + return 0; +} + + +#endif +/* TODO test */ |
