aboutsummaryrefslogtreecommitdiffstats
path: root/librecrypt_crypt.c
diff options
context:
space:
mode:
authorMattias Andrée <m@maandree.se>2026-07-01 21:37:09 +0200
committerMattias Andrée <m@maandree.se>2026-07-01 21:37:09 +0200
commit1323b81cd2679bb61a480524a0e4cd008d3d0bee (patch)
treed7fc0c3417b6ae7a1688cddd8ce3a9607ec53dd7 /librecrypt_crypt.c
parentAdd test and fix a bug (diff)
downloadlibrecrypt-1.1.1.tar.gz
librecrypt-1.1.1.tar.bz2
librecrypt-1.1.1.tar.xz
Add support for the reference implementation of Argon2HEAD1.1.1master
Signed-off-by: Mattias Andrée <m@maandree.se>
Diffstat (limited to 'librecrypt_crypt.c')
-rw-r--r--librecrypt_crypt.c28
1 files changed, 19 insertions, 9 deletions
diff --git a/librecrypt_crypt.c b/librecrypt_crypt.c
index 21e6e32..fb93cd2 100644
--- a/librecrypt_crypt.c
+++ b/librecrypt_crypt.c
@@ -123,13 +123,14 @@ main(void)
#define GET_SCRATCH_SIZE(HASHLEN) GET_ARGON2_SCRATCH_SIZE(HASHLEN)
#if defined(SUPPORT_ARGON2I)
+# if defined(SUPPORT_ARGON2_V1_0)
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_crypt(NULL, 0u, NULL, 0u, conf, ctx) == -1);
-# if SIZE_MAX > UINT32_MAX
+# if SIZE_MAX > UINT32_MAX
EXPECT(errno == EINVAL);
-# else
+# else
EXPECT(errno == EOVERFLOW);
if (libtest_have_custom_malloc()) {
libtest_pretend_allocation_successful = 1;
@@ -138,43 +139,52 @@ main(void)
libtest_pretend_allocation_successful = 0;
EXPECT(errno == EOVERFLOW);
}
-# endif
+# endif
-# if SIZE_MAX == UINT32_MAX
+# if SIZE_MAX == UINT32_MAX
r = snprintf(conf, sizeof(conf), "$argon2i$m=256,t=8,p=1$AAAABBBBCCCC$*%zu", (SIZE_MAX / 4u * 3u) / 2u);
assert(r > 0 && (size_t)r < sizeof(conf));
errno = 0;
EXPECT(librecrypt_crypt(NULL, 0u, NULL, 0u, conf, ctx) == -1);
EXPECT(errno == EOVERFLOW);
-# endif
+# endif
-# if SIZE_MAX == UINT32_MAX
+# if SIZE_MAX == UINT32_MAX
r = snprintf(conf, sizeof(conf), "$argon2i$m=256,t=8,p=1$AAAABBBBCCCC$*%zu", SIZE_MAX / 4u * 3u);
assert(r > 0 && (size_t)r < sizeof(conf));
errno = 0;
EXPECT(librecrypt_crypt(NULL, 0u, NULL, 0u, conf, ctx) == -1);
EXPECT(errno == EOVERFLOW);
-# endif
+# endif
CHECK("password", "$argon2i$" "m=256,t=2,p=1$c29tZXNhbHQ$", 32, 1, "/U3YPXYsSb3q9XxHvc0MLxur+GP960kN9j7emXX8zwY");
+# endif
+# if defined(SUPPORT_ARGON2_V1_3)
CHECK("password", "$argon2i$v=19$m=256,t=2,p=1$c29tZXNhbHQ$", 32, 1, "iekCn0Y3spW+sCcFanM2xBT63UP2sghkUoHLIUpWRS8");
+# endif
CHECK_BAD("$argon2i$");
#endif
#if defined(SUPPORT_ARGON2ID)
+# if defined(SUPPORT_ARGON2_V1_3)
CHECK("password", "$argon2id$v=19$m=256,t=2,p=1$c29tZXNhbHQ$", 32, 1, "nf65EOgLrQMR/uIPnA4rEsF5h7TKyQwu9U1bMCHGi/4");
+# endif
CHECK_BAD("$argon2id$");
#endif
#if defined(SUPPORT_ARGON2DS)
+# if defined(SUPPORT_ARGON2_V1_0)
CHECK("", "$argon2ds$v=16$m=""8,t=1,p=1$ICAgICAgICA$", 32, 1, "zgdykk9ZjN5VyrW0LxGw8LmrJ1Z6fqSC+3jPQtn4n0s");
+# endif
CHECK_BAD("$argon2ds$");
#endif
#if defined(SUPPORT_ARGON2D)
+# if defined(SUPPORT_ARGON2_V1_0)
CHECK("", "$argon2d$v=16$m=""8,t=1,p=1$ICAgICAgICA$", 100, 0, "NjODMrWrS7zeivNNpHsuxD9c6uDmUQ6YqPRhb8H5DSNw9"
"n683FUCJZ3tyxgfJpYYANI+01WT/S5zp1UVs+qNRwnkdE"
"yLKZMg+DIOXVc9z1po9ZlZG8+Gp4g5brqfza3lvkR9vw");
+# endif
CHECK_BAD("$argon2d$");
#endif
-#if defined(SUPPORT_ARGON2ID)
+#if defined(SUPPORT_ARGON2ID) && defined(SUPPORT_ARGON2_V1_3)
assert(!libtest_getentropy_error);
libtest_getentropy_real = 0;
@@ -239,7 +249,7 @@ main(void)
assert(ctx != NULL);
memset(nuls, 0, sizeof(nuls));
-#if defined(SUPPORT_ARGON2I)
+#if defined(SUPPORT_ARGON2I) && defined(SUPPORT_ARGON2_V1_3)
# define GET_SCRATCH_SIZE(HASHLEN) GET_ARGON2_SCRATCH_SIZE(HASHLEN)
assert(sizeof(nuls) >= 4u);
assert(librecrypt_set_pepper(ctx, LIBRECRYPT_ARGON2I_V1_3, nuls, 4u) == 0);