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_create_context.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'librecrypt_create_context.c') diff --git a/librecrypt_create_context.c b/librecrypt_create_context.c index c9696d7..a6f5153 100644 --- a/librecrypt_create_context.c +++ b/librecrypt_create_context.c @@ -21,6 +21,7 @@ librecrypt_create_context(void) * (zeroed) associated with them */ ret->user_data = NULL; + ret->algos = NULL; for (i = 0u; i < ELEMSOF(ret->peppers); i++) ret->peppers[i].data = NULL; @@ -31,13 +32,27 @@ librecrypt_create_context(void) #else +extern LIBRECRYPT_CONTEXT *volatile ctx; +LIBRECRYPT_CONTEXT *volatile ctx; + + int main(void) { SET_UP_ALARM(); INIT_RESOURCE_TEST(); - /* TODO test */ + ctx = librecrypt_create_context(); + assert(ctx != NULL); + librecrypt_free_context(ctx); + + if (libtest_have_custom_malloc()) { + libtest_set_alloc_failure_in(1u); + errno = 0; + EXPECT(librecrypt_create_context() == NULL); + EXPECT(errno == ENOMEM); + EXPECT(libtest_get_alloc_failure_in() == 0u); + } STOP_RESOURCE_TEST(); return 0; -- cgit v1.3.1