summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorNIIBE Yutaka <gniibe@fsij.org>2022-01-28 14:40:45 +0900
committerNIIBE Yutaka <gniibe@fsij.org>2022-01-28 14:40:45 +0900
commit4cbbd87e2af00c7b3f0236a56f12bd51e9295816 (patch)
treef6d5116a2588e90e189cc884ded6c9e253dd86b3 /tests
parent6467287ba121df9e5965d5a3a7a4f349793d49d2 (diff)
downloadlibgcrypt-4cbbd87e2af00c7b3f0236a56f12bd51e9295816.tar.gz
kdf: Implement Argon2 KDF using blake2b_vl_hash function.
* cipher/kdf.c (hash): Remove, as it's not possible to implement with _gcry_md_* programming interface. (xor_block): New. (argon2_fill_first_blocks): Rename from argon2_genh0_first_blocks. (argon2_init): Don't use ->HD any more. (fill_block, pseudo_random_generate, index_alpha): New. (argon2_compute_segment): Implement ARGOND, ARGON2I and ARGON2ID. (argon2_final): Fix using blake2b_vl_hash. (argon2_open): Fix for parameters and the restriction for output length. * tests/t-kdf.c (check_argon2): Update test vector for version 0x13. (main): Enable the test. -- Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/t-kdf.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/tests/t-kdf.c b/tests/t-kdf.c
index 6828aaf4..2aa3b5fb 100644
--- a/tests/t-kdf.c
+++ b/tests/t-kdf.c
@@ -1364,7 +1364,7 @@ static void
check_argon2 (void)
{
gcry_error_t err;
- const unsigned long param[5] = { 32, 3, 16, 4, 4 };
+ const unsigned long param[5] = { 32, 3, 32, 4, 4 };
const unsigned char pass[32] = {
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
@@ -1376,10 +1376,22 @@ check_argon2 (void)
const unsigned char ad[12] = { 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 };
unsigned char out[32];
unsigned char expected[32] = {
- 0xf8, 0x7c, 0x95, 0x96, 0xbd, 0xbf, 0x75, 0x0b,
- 0xfb, 0x35, 0x3a, 0x89, 0x70, 0xe5, 0x44, 0x1a,
- 0x70, 0x24, 0x3e, 0xb4, 0x90, 0x30, 0xdf, 0xe2,
- 0x74, 0xd9, 0xad, 0x4e, 0x37, 0x0e, 0x38, 0x9b
+#if 0
+ 0x51, 0x2b, 0x39, 0x1b, 0x6f, 0x11, 0x62, 0x97,
+ 0x53, 0x71, 0xd3, 0x09, 0x19, 0x73, 0x42, 0x94,
+ 0xf8, 0x68, 0xe3, 0xbe, 0x39, 0x84, 0xf3, 0xc1,
+ 0xa1, 0x3a, 0x4d, 0xb9, 0xfa, 0xbe, 0x4a, 0xcb
+#elif 0 /* GCRY_KDF_ARGON2I */
+ 0xc8, 0x14, 0xd9, 0xd1, 0xdc, 0x7f, 0x37, 0xaa,
+ 0x13, 0xf0, 0xd7, 0x7f, 0x24, 0x94, 0xbd, 0xa1,
+ 0xc8, 0xde, 0x6b, 0x01, 0x6d, 0xd3, 0x88, 0xd2,
+ 0x99, 0x52, 0xa4, 0xc4, 0x67, 0x2b, 0x6c, 0xe8
+#else /* GCRY_KDF_ARGON2ID */
+ 0x0d, 0x64, 0x0d, 0xf5, 0x8d, 0x78, 0x76, 0x6c,
+ 0x08, 0xc0, 0x37, 0xa3, 0x4a, 0x8b, 0x53, 0xc9,
+ 0xd0, 0x1e, 0xf0, 0x45, 0x2d, 0x75, 0xb6, 0x5e,
+ 0xb5, 0x25, 0x20, 0xe9, 0x6b, 0x01, 0xe6, 0x59
+#endif
};
int i;
@@ -1493,9 +1505,7 @@ main (int argc, char **argv)
check_openpgp ();
check_pbkdf2 ();
check_scrypt ();
-#if 0
check_argon2 ();
-#endif
}
return error_count ? 1 : 0;