diff options
| author | Mattias Andrée <m@maandree.se> | 2026-05-20 23:04:11 +0200 |
|---|---|---|
| committer | Mattias Andrée <m@maandree.se> | 2026-05-20 23:04:11 +0200 |
| commit | c35b47228f5494f4d806e9166628110af6dd2469 (patch) | |
| tree | 3b5a123af999a5e047b8565efee293a5d95c3f6c /librecrypt_context_get_pepper_.c | |
| parent | Prepare for supporting custom algorithms (diff) | |
| download | librecrypt-c35b47228f5494f4d806e9166628110af6dd2469.tar.gz librecrypt-c35b47228f5494f4d806e9166628110af6dd2469.tar.bz2 librecrypt-c35b47228f5494f4d806e9166628110af6dd2469.tar.xz | |
Signed-off-by: Mattias Andrée <m@maandree.se>
Diffstat (limited to 'librecrypt_context_get_pepper_.c')
| -rw-r--r-- | librecrypt_context_get_pepper_.c | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/librecrypt_context_get_pepper_.c b/librecrypt_context_get_pepper_.c new file mode 100644 index 0000000..69373f5 --- /dev/null +++ b/librecrypt_context_get_pepper_.c @@ -0,0 +1,63 @@ +/* See LICENSE file for copyright and license details. */ +#include "common.h" +#ifndef TEST + + +struct pepper * +librecrypt_context_get_pepper_(LIBRECRYPT_CONTEXT *ctx, enum librecrypt_hash_algorithm algo, size_t len) +{ + struct pepper *pepper; + size_t index = (size_t)algo; + + switch (algo) { + +#if defined(SUPPORT_ARGON2I) || defined(SUPPORT_ARGON2D) || defined(SUPPORT_ARGON2ID) || defined(SUPPORT_ARGON2DS) +# if defined(SUPPORT_ARGON2I) + case LIBRECRYPT_ARGON2I_V1_0: + case LIBRECRYPT_ARGON2I_V1_3: +# endif +# if defined(SUPPORT_ARGON2D) + case LIBRECRYPT_ARGON2D_V1_0: + case LIBRECRYPT_ARGON2D_V1_3: +# endif +# if defined(SUPPORT_ARGON2ID) + case LIBRECRYPT_ARGON2ID_V1_0: + case LIBRECRYPT_ARGON2ID_V1_3: +# endif +# if defined(SUPPORT_ARGON2DS) + case LIBRECRYPT_ARGON2DS_V1_0: + case LIBRECRYPT_ARGON2DS_V1_3: +# endif +# if SIZE_MAX > UINT32_MAX /* LIBAR2_MAX_KEYLEN is just UINT32_MAX cast to size_t; keep it simple: don't include <libar2.h> */ + if (len > UINT32_MAX) { + errno = EINVAL; + return NULL; + } +# endif + return &ctx->peppers[algo]; +#endif + + default: + errno = ENOSYS; + return NULL; + } +} + + +#else + + +int +main(void) +{ + SET_UP_ALARM(); + INIT_RESOURCE_TEST(); + + /* TODO test */ + + STOP_RESOURCE_TEST(); + return 0; +} + + +#endif |
