GNUnet  0.11.x
crypto_pow.c
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet.
3  Copyright (C) 2012, 2013, 2019 GNUnet e.V.
4 
5  GNUnet is free software: you can redistribute it and/or modify it
6  under the terms of the GNU Affero General Public License as published
7  by the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  GNUnet is distributed in the hope that it will be useful, but
11  WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Affero General Public License for more details.
14 
15  You should have received a copy of the GNU Affero General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
18  SPDX-License-Identifier: AGPL3.0-or-later
19  */
26 #include "platform.h"
27 #include "gnunet_crypto_lib.h"
28 #include <sodium.h>
29 
40 void
42  const void *buf,
43  size_t buf_len,
44  struct GNUNET_HashCode *result)
45 {
46  /* Threads hardcoded at 1 in libsodium */
47  GNUNET_break (0 ==
48  crypto_pwhash_argon2id ((unsigned char *) result,
49  sizeof (struct GNUNET_HashCode),
50  buf,
51  buf_len,
52  (unsigned char*) salt,
53  3, /* iterations */
54  1024 * 1024, /* memory (1 MiB) */
55  crypto_pwhash_argon2id_ALG_ARGON2ID13));
56 }
57 
58 
59 /* end of crypto_pow.c */
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
cryptographic primitives for GNUnet
static char buf[2048]
static int result
Global testing status.
A 512-bit hashcode.
void GNUNET_CRYPTO_pow_hash(const struct GNUNET_CRYPTO_PowSalt *salt, const void *buf, size_t buf_len, struct GNUNET_HashCode *result)
Calculate the &#39;proof-of-work&#39; hash (an expensive hash).
Definition: crypto_pow.c:41
Value for a salt for GNUNET_CRYPTO_pow_hash().
static struct GNUNET_CRYPTO_PowSalt salt
Salt for PoW calcualations.