diff options
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/crypto_pow.c | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/src/util/crypto_pow.c b/src/util/crypto_pow.c index d3e4dbc43..5e225f244 100644 --- a/src/util/crypto_pow.c +++ b/src/util/crypto_pow.c | |||
@@ -25,9 +25,10 @@ | |||
25 | */ | 25 | */ |
26 | #include "platform.h" | 26 | #include "platform.h" |
27 | #include "gnunet_crypto_lib.h" | 27 | #include "gnunet_crypto_lib.h" |
28 | #include <gcrypt.h> | ||
28 | #include <argon2.h> | 29 | #include <argon2.h> |
29 | 30 | ||
30 | #define LSD001 | 31 | #define LSD0001 |
31 | 32 | ||
32 | /** | 33 | /** |
33 | * Calculate the 'proof-of-work' hash (an expensive hash). | 34 | * Calculate the 'proof-of-work' hash (an expensive hash). |
@@ -45,15 +46,15 @@ GNUNET_CRYPTO_pow_hash (const char *salt, | |||
45 | size_t buf_len, | 46 | size_t buf_len, |
46 | struct GNUNET_HashCode *result) | 47 | struct GNUNET_HashCode *result) |
47 | { | 48 | { |
48 | #ifdef LSD001 | 49 | #ifdef LSD0001 |
49 | char twofish_iv[128 / 8]; // 128 bit IV | 50 | char twofish_iv[128 / 8]; // 128 bit IV |
50 | char twofish_key[256 / 8]; // 256 bit Key | 51 | char twofish_key[256 / 8]; // 256 bit Key |
51 | char rbuf[buf_len]; | 52 | char rbuf[buf_len]; |
52 | int rc; | 53 | int rc; |
53 | gcry_cipher_hd_t handle; | 54 | gcry_cipher_hd_t handle; |
54 | 55 | ||
55 | GNUNET_break (ARGON2_OK == argon2d_hash_raw (2, /* iterations */ | 56 | GNUNET_break (ARGON2_OK == argon2d_hash_raw (3, /* iterations */ |
56 | 100000, /* memory (kb) */ | 57 | 1024, /* memory (1 MiB) */ |
57 | 1, /* threads */ | 58 | 1, /* threads */ |
58 | buf, | 59 | buf, |
59 | buf_len, | 60 | buf_len, |
@@ -85,30 +86,31 @@ GNUNET_CRYPTO_pow_hash (const char *salt, | |||
85 | GNUNET_assert (0 == gcry_cipher_encrypt (handle, &rbuf, buf_len, buf, | 86 | GNUNET_assert (0 == gcry_cipher_encrypt (handle, &rbuf, buf_len, buf, |
86 | buf_len)); | 87 | buf_len)); |
87 | gcry_cipher_close (handle); | 88 | gcry_cipher_close (handle); |
88 | GNUNET_break (ARGON2_OK == argon2d_hash_raw (2, /* iterations */ | 89 | GNUNET_break (ARGON2_OK == argon2d_hash_raw (3, /* iterations */ |
89 | 100000, /* memory */ | 90 | 1024, /* memory (1 MiB) */ |
90 | 1, /* threads */ | 91 | 1, /* threads */ |
91 | rbuf, | 92 | rbuf, |
92 | buf_len, | 93 | buf_len, |
93 | salt, | 94 | salt, |
94 | strlen (salt), | 95 | strlen (salt), |
95 | result, | 96 | result, |
96 | sizeof (struct GNUNET_HashCode))); | 97 | sizeof (struct |
98 | GNUNET_HashCode))); | ||
97 | 99 | ||
98 | #else | 100 | #else |
99 | struct GNUNET_CRYPTO_SymmetricInitializationVector iv; | 101 | struct GNUNET_CRYPTO_SymmetricInitializationVector iv; |
100 | struct GNUNET_CRYPTO_SymmetricSessionKey skey; | 102 | struct GNUNET_CRYPTO_SymmetricSessionKey skey; |
101 | char rbuf[buf_len]; | 103 | char rbuf[buf_len]; |
102 | 104 | ||
103 | GNUNET_break (ARGON2_OK == argon2d_hash_raw (buf, | 105 | GNUNET_break (0 == gcry_kdf_derive (buf, |
104 | buf_len, | 106 | buf_len, |
105 | GCRY_KDF_SCRYPT, | 107 | GCRY_KDF_SCRYPT, |
106 | 1 /* subalgo */, | 108 | 1 /* subalgo */, |
107 | salt, | 109 | salt, |
108 | strlen (salt), | 110 | strlen (salt), |
109 | 2 /* iterations; keep cost of individual op small */, | 111 | 2 /* iterations; keep cost of individual op small */, |
110 | sizeof(skey), | 112 | sizeof(skey), |
111 | &skey)); | 113 | &skey)); |
112 | GNUNET_CRYPTO_symmetric_derive_iv (&iv, | 114 | GNUNET_CRYPTO_symmetric_derive_iv (&iv, |
113 | &skey, | 115 | &skey, |
114 | "gnunet-proof-of-work-iv", | 116 | "gnunet-proof-of-work-iv", |