From 193d39d9b78a9e3c0c257b2e1e9f9dd4a7a13349 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Fri, 15 May 2026 20:53:25 +0200 Subject: Misc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- librecrypt_hash.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'librecrypt_hash.c') diff --git a/librecrypt_hash.c b/librecrypt_hash.c index 69b8dcf..050e0c1 100644 --- a/librecrypt_hash.c +++ b/librecrypt_hash.c @@ -119,11 +119,32 @@ check(const char *phrase, const char *settings, const char *chain, const char *h int main(void) { + char conf[256]; + int r; + SET_UP_ALARM(); INIT_RESOURCE_TEST(); #define GET_SCRATCH_SIZE(HASHLEN) ((HASHLEN) > 64u ? ((HASHLEN) + 63u) & ~31u : (HASHLEN)) #if defined(SUPPORT_ARGON2I) + r = snprintf(conf, sizeof(conf), "$argon2i$m=256,t=8,p=1$AAAABBBBCCCC$*%zu", SIZE_MAX / 4u * 3u + 3u); + assert(r > 0 && (size_t)r < sizeof(conf)); + errno = 0; + EXPECT(librecrypt_hash(NULL, 0u, NULL, 0u, conf, NULL) == -1); +# if SIZE_MAX > UINT32_MAX + EXPECT(errno == EINVAL); +# else + EXPECT(errno == EOVERFLOW); + if (libtest_have_custom_malloc()) { + char buf[1024]; + libtest_pretend_allocation_successful = 1; + errno = 0; + EXPECT(librecrypt_hash(buf, sizeof(buf), NULL, 0u, conf, NULL) == -1); + libtest_pretend_allocation_successful = 0; + EXPECT(errno == EOVERFLOW); + } +# endif + CHECK("password", "$argon2i$" "m=256,t=2,p=1$c29tZXNhbHQ$", 32, 1, "/U3YPXYsSb3q9XxHvc0MLxur+GP960kN9j7emXX8zwY"); CHECK("password", "$argon2i$v=19$m=256,t=2,p=1$c29tZXNhbHQ$", 32, 1, "iekCn0Y3spW+sCcFanM2xBT63UP2sghkUoHLIUpWRS8"); CHECK_BAD("$argon2i$"); -- cgit v1.2.3-70-g09d2