diff options
Diffstat (limited to 'librecrypt_hash.c')
| -rw-r--r-- | librecrypt_hash.c | 21 |
1 files changed, 21 insertions, 0 deletions
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$"); |
