aboutsummaryrefslogtreecommitdiffstats
path: root/test.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2022-02-12 21:56:50 +0100
committerMattias Andrée <maandree@kth.se>2022-02-12 21:56:50 +0100
commit33c953317cad9ea06d8a26fe2cc2ed0ed9e29692 (patch)
tree9e34e8fd215966299d11cf93d5471c76b3a933a7 /test.c
parentlibar2_encode_base64: data may be NULL if buf is NULL (diff)
downloadlibar2-33c953317cad9ea06d8a26fe2cc2ed0ed9e29692.tar.gz
libar2-33c953317cad9ea06d8a26fe2cc2ed0ed9e29692.tar.bz2
libar2-33c953317cad9ea06d8a26fe2cc2ed0ed9e29692.tar.xz
Use params->version == 0 for implicit specification of version 1.0
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'test.c')
-rw-r--r--test.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/test.c b/test.c
index 8172e16..a799b2e 100644
--- a/test.c
+++ b/test.c
@@ -526,6 +526,54 @@ check_libar2_encode_params_libar2_decode_params(void)
sbuf = NULL;
#undef PARAMSTR
+#define PARAMSTR "$argon2i$v=16$m=4096,t=3,p=1$fn5/f35+f38$"
+ memset(&params, 0xFF, sizeof(params));
+ assert_zueq(DECODE(PARAMSTR, "1234"), sizeof(PARAMSTR) - 1);
+ assert(params.type == LIBAR2_ARGON2I);
+ assert(params.version == LIBAR2_ARGON2_VERSION_10);
+ assert(params.t_cost == 3);
+ assert(params.m_cost == 4096);
+ assert(params.lanes == 1);
+ assert(params.salt != NULL);
+ assert(params.saltlen == 8);
+ assert(!memcmp(params.salt, "~~\x7f\x7f~~\x7f\x7f", params.saltlen));
+ assert(!params.key);
+ assert(!params.keylen);
+ assert(!params.ad);
+ assert(!params.adlen);
+ assert(params.hashlen == 3);
+ assert_zueq(libar2_encode_params(NULL, &params), sizeof(PARAMSTR));
+ assert_zueq(libar2_encode_params(pbuf, &params), sizeof(PARAMSTR));
+ assert_streq(pbuf, PARAMSTR);
+ assert(sbuf != NULL);
+ ctx_st.deallocate(sbuf, &ctx_st);
+ sbuf = NULL;
+#undef PARAMSTR
+
+#define PARAMSTR "$argon2i$m=4096,t=3,p=1$fn5/f35+f38$"
+ memset(&params, 0xFF, sizeof(params));
+ assert_zueq(DECODE(PARAMSTR, "1234"), sizeof(PARAMSTR) - 1);
+ assert(params.type == LIBAR2_ARGON2I);
+ assert(params.version == 0);
+ assert(params.t_cost == 3);
+ assert(params.m_cost == 4096);
+ assert(params.lanes == 1);
+ assert(params.salt != NULL);
+ assert(params.saltlen == 8);
+ assert(!memcmp(params.salt, "~~\x7f\x7f~~\x7f\x7f", params.saltlen));
+ assert(!params.key);
+ assert(!params.keylen);
+ assert(!params.ad);
+ assert(!params.adlen);
+ assert(params.hashlen == 3);
+ assert_zueq(libar2_encode_params(NULL, &params), sizeof(PARAMSTR));
+ assert_zueq(libar2_encode_params(pbuf, &params), sizeof(PARAMSTR));
+ assert_streq(pbuf, PARAMSTR);
+ assert(sbuf != NULL);
+ ctx_st.deallocate(sbuf, &ctx_st);
+ sbuf = NULL;
+#undef PARAMSTR
+
#undef DECODE
}