diff options
| author | Mattias Andrée <m@maandree.se> | 2026-07-01 21:37:09 +0200 |
|---|---|---|
| committer | Mattias Andrée <m@maandree.se> | 2026-07-01 21:37:09 +0200 |
| commit | 1323b81cd2679bb61a480524a0e4cd008d3d0bee (patch) | |
| tree | d7fc0c3417b6ae7a1688cddd8ce3a9607ec53dd7 /librecrypt_hash.c | |
| parent | Add test and fix a bug (diff) | |
| download | librecrypt-3b7ce5adbb2373f3fcd80d5e3593a4900efa7125.tar.gz librecrypt-3b7ce5adbb2373f3fcd80d5e3593a4900efa7125.tar.bz2 librecrypt-3b7ce5adbb2373f3fcd80d5e3593a4900efa7125.tar.xz | |
Signed-off-by: Mattias Andrée <m@maandree.se>
Diffstat (limited to '')
| -rw-r--r-- | librecrypt_hash.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/librecrypt_hash.c b/librecrypt_hash.c index 35aa8e4..3d37d03 100644 --- a/librecrypt_hash.c +++ b/librecrypt_hash.c @@ -138,13 +138,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_hash(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()) { char buf[1024]; @@ -154,24 +155,33 @@ main(void) libtest_pretend_allocation_successful = 0; 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 #undef GET_SCRATCH_SIZE @@ -180,7 +190,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); |
