diff options
author | Martin Schanzenbach <mschanzenbach@posteo.de> | 2020-04-21 18:37:28 +0200 |
---|---|---|
committer | Martin Schanzenbach <mschanzenbach@posteo.de> | 2020-04-21 18:37:28 +0200 |
commit | 091f411cc91975e43d7d994a981b82d45bbc9bcb (patch) | |
tree | ea39395f77be7533dba4d7376a659df080cbb4e4 /src | |
parent | e3866c8f09e173e7d36cce25015ecfbd666cd5bc (diff) | |
download | gnunet-091f411cc91975e43d7d994a981b82d45bbc9bcb.tar.gz gnunet-091f411cc91975e43d7d994a981b82d45bbc9bcb.zip |
purge scrypt; add argon2
Diffstat (limited to 'src')
-rw-r--r-- | src/util/crypto_pow.c | 40 |
1 files changed, 0 insertions, 40 deletions
diff --git a/src/util/crypto_pow.c b/src/util/crypto_pow.c index 1ab4443d1..35511a130 100644 --- a/src/util/crypto_pow.c +++ b/src/util/crypto_pow.c | |||
@@ -25,11 +25,8 @@ | |||
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> | ||
29 | #include <argon2.h> | 28 | #include <argon2.h> |
30 | 29 | ||
31 | #define LSD0001 | ||
32 | |||
33 | /** | 30 | /** |
34 | * Calculate the 'proof-of-work' hash (an expensive hash). | 31 | * Calculate the 'proof-of-work' hash (an expensive hash). |
35 | * We're using a non-standard formula to avoid issues with | 32 | * We're using a non-standard formula to avoid issues with |
@@ -46,7 +43,6 @@ GNUNET_CRYPTO_pow_hash (const char *salt, | |||
46 | size_t buf_len, | 43 | size_t buf_len, |
47 | struct GNUNET_HashCode *result) | 44 | struct GNUNET_HashCode *result) |
48 | { | 45 | { |
49 | #ifdef LSD0001 | ||
50 | GNUNET_break (ARGON2_OK == argon2d_hash_raw (3, /* iterations */ | 46 | GNUNET_break (ARGON2_OK == argon2d_hash_raw (3, /* iterations */ |
51 | 1024, /* memory (1 MiB) */ | 47 | 1024, /* memory (1 MiB) */ |
52 | 1, /* threads */ | 48 | 1, /* threads */ |
@@ -58,42 +54,6 @@ GNUNET_CRYPTO_pow_hash (const char *salt, | |||
58 | sizeof (struct | 54 | sizeof (struct |
59 | GNUNET_HashCode))); | 55 | GNUNET_HashCode))); |
60 | 56 | ||
61 | #else | ||
62 | struct GNUNET_CRYPTO_SymmetricInitializationVector iv; | ||
63 | struct GNUNET_CRYPTO_SymmetricSessionKey skey; | ||
64 | char rbuf[buf_len]; | ||
65 | |||
66 | GNUNET_break (0 == gcry_kdf_derive (buf, | ||
67 | buf_len, | ||
68 | GCRY_KDF_SCRYPT, | ||
69 | 1 /* subalgo */, | ||
70 | salt, | ||
71 | strlen (salt), | ||
72 | 2 /* iterations; keep cost of individual op small */, | ||
73 | sizeof(skey), | ||
74 | &skey)); | ||
75 | GNUNET_CRYPTO_symmetric_derive_iv (&iv, | ||
76 | &skey, | ||
77 | "gnunet-proof-of-work-iv", | ||
78 | strlen ("gnunet-proof-of-work-iv"), | ||
79 | salt, | ||
80 | strlen (salt), | ||
81 | NULL, 0); | ||
82 | GNUNET_CRYPTO_symmetric_encrypt (buf, | ||
83 | buf_len, | ||
84 | &skey, | ||
85 | &iv, | ||
86 | &rbuf); | ||
87 | GNUNET_break (0 == gcry_kdf_derive (rbuf, | ||
88 | buf_len, | ||
89 | GCRY_KDF_SCRYPT, | ||
90 | 1 /* subalgo */, | ||
91 | salt, | ||
92 | strlen (salt), | ||
93 | 2 /* iterations; keep cost of individual op small */, | ||
94 | sizeof(struct GNUNET_HashCode), | ||
95 | result)); | ||
96 | #endif | ||
97 | } | 57 | } |
98 | 58 | ||
99 | 59 | ||