diff options
author | Mattias Andrée <maandree@kth.se> | 2022-02-12 21:56:50 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2022-02-12 21:56:50 +0100 |
commit | 33c953317cad9ea06d8a26fe2cc2ed0ed9e29692 (patch) | |
tree | 9e34e8fd215966299d11cf93d5471c76b3a933a7 /test.c | |
parent | libar2_encode_base64: data may be NULL if buf is NULL (diff) | |
download | libar2-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 '')
-rw-r--r-- | test.c | 48 |
1 files changed, 48 insertions, 0 deletions
@@ -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(¶ms, 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, ¶ms), sizeof(PARAMSTR)); + assert_zueq(libar2_encode_params(pbuf, ¶ms), 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(¶ms, 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, ¶ms), sizeof(PARAMSTR)); + assert_zueq(libar2_encode_params(pbuf, ¶ms), sizeof(PARAMSTR)); + assert_streq(pbuf, PARAMSTR); + assert(sbuf != NULL); + ctx_st.deallocate(sbuf, &ctx_st); + sbuf = NULL; +#undef PARAMSTR + #undef DECODE } |