diff options
author | Mattias Andrée <maandree@kth.se> | 2022-02-14 21:28:52 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2022-02-14 21:28:52 +0100 |
commit | ea565f8d945db5dd0a638973fecae37318412bbf (patch) | |
tree | ac86bfd810383102010c82736684cc872f8cee2a /test.c | |
parent | XOR seed provided to srand with data depending on current seed, in case it is already seed in a better manner (diff) | |
download | libar2simplified-ea565f8d945db5dd0a638973fecae37318412bbf.tar.gz libar2simplified-ea565f8d945db5dd0a638973fecae37318412bbf.tar.bz2 libar2simplified-ea565f8d945db5dd0a638973fecae37318412bbf.tar.xz |
Add libar2simplified_crypt and fix threading
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'test.c')
-rw-r--r-- | test.c | 14 |
1 files changed, 11 insertions, 3 deletions
@@ -71,14 +71,12 @@ static void check_hash(const char *pwd_, size_t pwdlen, const char *hash, int lineno) { struct libar2_argon2_parameters *params; - char *output[512], pwd[512], *tag_expect, *tag_got, *paramstr; + char *output[512], pwd[512], *tag_expect, *tag_got, *paramstr, *hash_got; size_t taglen; from_lineno = lineno; errno = 0; - strcpy(pwd, pwd_); - assert(!!(params = libar2simplified_decode(hash, &tag_expect, NULL, NULL))); assert_zueq(libar2_decode_base64(tag_expect, output, &taglen), strlen(tag_expect)); assert_zueq(taglen, params->hashlen); @@ -86,12 +84,20 @@ check_hash(const char *pwd_, size_t pwdlen, const char *hash, int lineno) assert_streq(paramstr, hash); free(paramstr); + strcpy(pwd, pwd_); assert(!libar2simplified_hash(output, pwd, pwdlen, params)); tag_got = libar2simplified_encode_hash(params, output); free(params); assert_streq(tag_got, tag_expect); free(tag_got); + if (strlen(pwd_) == pwdlen) { /* libar2simplified_crypt does not support NUL bytes in the password */ + strcpy(pwd, pwd_); + hash_got = libar2simplified_crypt(pwd, hash, NULL); + assert_streq(hash_got, hash); + free(hash_got); + } + from_lineno = 0; } @@ -132,5 +138,7 @@ main(void) CHECK("password", "$argon2i$v=19$m=256,t=2,p=2$c29tZXNhbHQ$T/XOJ2mh1/TIpJHfCdQan76Q5esCFVoT5MAeIM1Oq2E"); CHECK("password", "$argon2id$v=19$m=256,t=2,p=2$c29tZXNhbHQ$bQk8UB/VmZZF4Oo79iDXuL5/0ttZwg2f/5U52iv1cDc"); + CHECK("password", "$argon2id$v=19$m=2048,t=16,p=16$c29tZXNhbHQ$FRWpYzcrsos+DHNInvfsl0g8mZBdPqUdarIYh/Pnc1g"); + return 0; } |