diff options
author | NIIBE Yutaka <gniibe@fsij.org> | 2022-01-26 15:43:57 +0900 |
---|---|---|
committer | NIIBE Yutaka <gniibe@fsij.org> | 2022-01-26 15:43:57 +0900 |
commit | bb08ae763d249213b1f3a4a687c24aab9b7ec3c8 (patch) | |
tree | e3ce781a5bc22011f29a1cb9f7e8b90f2c64125b | |
parent | f21871e241e96148cef3ad4314ad596178cf8967 (diff) | |
download | libgcrypt-bb08ae763d249213b1f3a4a687c24aab9b7ec3c8.tar.gz |
kdf: Fix bugs in Argon2 implementation.
--
Not yet finished.
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
-rw-r--r-- | cipher/kdf.c | 6 | ||||
-rw-r--r-- | tests/t-kdf.c | 2 |
2 files changed, 4 insertions, 4 deletions
diff --git a/cipher/kdf.c b/cipher/kdf.c index bdc7a2a0..6852efe7 100644 --- a/cipher/kdf.c +++ b/cipher/kdf.c @@ -702,7 +702,7 @@ argon2_compute_segment (argon2_ctx_t a, const struct argon2_thread_data *t) if (a->hash_type == GCRY_KDF_ARGON2I || (a->hash_type == GCRY_KDF_ARGON2ID && t->pass == 0 && t->slice < 2)) { - random_index = xtrymalloc (sizeof (u32)*a->segment_length); + random_index = xtrymalloc (2*sizeof (u32)*a->segment_length); if (!random_index) return gpg_err_code_from_errno (errno); argon2_pseudo_rand_gen (a, t, random_index); @@ -811,7 +811,7 @@ argon2_open (gcry_kdf_hd_t *hd, int subalgo, taglen = (unsigned int)param[0]; t_cost = (unsigned int)param[1]; m_cost = (unsigned int)param[2]; - if (paramlen == 4) + if (paramlen >= 4) parallelism = (unsigned int)param[3]; if (paramlen == 5) { @@ -849,6 +849,8 @@ argon2_open (gcry_kdf_hd_t *hd, int subalgo, a->ad = ad; a->adlen = adlen; + a->m_cost = m_cost; + a->block = NULL; a->thread_data = NULL; diff --git a/tests/t-kdf.c b/tests/t-kdf.c index 6828aaf4..88205c26 100644 --- a/tests/t-kdf.c +++ b/tests/t-kdf.c @@ -1493,9 +1493,7 @@ main (int argc, char **argv) check_openpgp (); check_pbkdf2 (); check_scrypt (); -#if 0 check_argon2 (); -#endif } return error_count ? 1 : 0; |