aboutsummaryrefslogtreecommitdiffstats
path: root/librecrypt_set_custom_algorithms.c
diff options
context:
space:
mode:
authorMattias Andrée <m@maandree.se>2026-05-21 17:12:20 +0200
committerMattias Andrée <m@maandree.se>2026-05-21 17:12:20 +0200
commitb29f4153e83623f24bebe99976e1368ef31bb008 (patch)
tree65473709df1194a2f9277dc5fb47add5e41430c0 /librecrypt_set_custom_algorithms.c
parentAdd (so far untested and undocument) support for pepper (diff)
downloadlibrecrypt-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_set_custom_algorithms.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/librecrypt_set_custom_algorithms.c b/librecrypt_set_custom_algorithms.c
new file mode 100644
index 0000000..2494490
--- /dev/null
+++ b/librecrypt_set_custom_algorithms.c
@@ -0,0 +1,51 @@
+/* See LICENSE file for copyright and license details. */
+#include "common.h"
+#ifndef TEST
+
+
+void
+librecrypt_set_custom_algorithms(LIBRECRYPT_CONTEXT *ctx, const struct librecrypt_algorithm *algos, size_t nalgos)
+{
+ ctx->algos = algos;
+ ctx->nalgos = nalgos;
+}
+
+
+#else
+
+
+int
+main(void)
+{
+ LIBRECRYPT_CONTEXT *ctx;
+ const struct librecrypt_algorithm algos[5];
+
+ SET_UP_ALARM();
+ INIT_RESOURCE_TEST();
+
+ ctx = librecrypt_create_context();
+ assert(ctx != NULL);
+
+ EXPECT(ctx->algos == NULL);
+ EXPECT(ctx->nalgos == 0u);
+ librecrypt_set_custom_algorithms(ctx, algos, 5u);
+ EXPECT(ctx->algos == algos);
+ EXPECT(ctx->nalgos == 5u);
+ librecrypt_set_custom_algorithms(ctx, algos, 5u);
+ EXPECT(ctx->algos == algos);
+ EXPECT(ctx->nalgos == 5u);
+ librecrypt_set_custom_algorithms(ctx, algos, 4u);
+ EXPECT(ctx->algos == algos);
+ EXPECT(ctx->nalgos == 4u);
+ librecrypt_set_custom_algorithms(ctx, NULL, 0u);
+ EXPECT(ctx->algos == NULL);
+ EXPECT(ctx->nalgos == 0u);
+
+ librecrypt_free_context(ctx);
+
+ STOP_RESOURCE_TEST();
+ return 0;
+}
+
+
+#endif