[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnunet] branch master updated: implement new simplified POW for LSD001
From: |
gnunet |
Subject: |
[gnunet] branch master updated: implement new simplified POW for LSD001 |
Date: |
Sun, 15 Mar 2020 15:23:13 +0100 |
This is an automated email from the git hooks/post-receive script.
martin-schanzenbach pushed a commit to branch master
in repository gnunet.
The following commit(s) were added to refs/heads/master by this push:
new b37cfa2fd implement new simplified POW for LSD001
b37cfa2fd is described below
commit b37cfa2fdf9443f824c8d5585f9a892525e556f9
Author: Schanzenbach, Martin <address@hidden>
AuthorDate: Sun Mar 15 15:18:53 2020 +0100
implement new simplified POW for LSD001
---
src/util/crypto_pow.c | 42 +++++++++++++++++++++++++++++++++++++++++-
1 file changed, 41 insertions(+), 1 deletion(-)
diff --git a/src/util/crypto_pow.c b/src/util/crypto_pow.c
index be575e537..9b20ab345 100644
--- a/src/util/crypto_pow.c
+++ b/src/util/crypto_pow.c
@@ -27,7 +27,6 @@
#include "gnunet_crypto_lib.h"
#include <gcrypt.h>
-
/**
* Calculate the 'proof-of-work' hash (an expensive hash).
* We're using a non-standard formula to avoid issues with
@@ -44,6 +43,46 @@ GNUNET_CRYPTO_pow_hash (const char *salt,
size_t buf_len,
struct GNUNET_HashCode *result)
{
+#ifdef LSD001
+ char twofish_iv[128 / 8]; //128 bit IV
+ char twofish_key[256 / 8]; //256 bit Key
+ char rbuf[buf_len];
+ int rc;
+ gcry_cipher_hd_t handle;
+
+ GNUNET_break (0 == gcry_kdf_derive (buf,
+ buf_len,
+ GCRY_KDF_SCRYPT,
+ 1 /* subalgo */,
+ salt,
+ strlen (salt),
+ 2 /* iterations; keep cost of individual
op small */,
+ sizeof(twofish_key),
+ &twofish_key));
+
+ GNUNET_CRYPTO_kdf (twofish_iv,
+ sizeof (twofish_iv),
+ "gnunet-proof-of-work-iv",
+ strlen ("gnunet-proof-of-work-iv"),
+ twofish_key,
+ sizeof(twofish_key),
+ salt,
+ strlen (salt),
+ NULL, 0);
+ GNUNET_assert (0 ==
+ gcry_cipher_open (&handle, GCRY_CIPHER_TWOFISH,
+ GCRY_CIPHER_MODE_CFB, 0));
+ rc = gcry_cipher_setkey (handle,
+ twofish_key,
+ sizeof(twofish_key));
+ GNUNET_assert ((0 == rc) || ((char) rc == GPG_ERR_WEAK_KEY));
+ rc = gcry_cipher_setiv (handle,
+ twofish_iv,
+ sizeof(twofish_iv));
+ GNUNET_assert ((0 == rc) || ((char) rc == GPG_ERR_WEAK_KEY));
+ GNUNET_assert (0 == gcry_cipher_encrypt (handle, &rbuf, buf_len, buf,
buf_len));
+ gcry_cipher_close (handle);
+#else
struct GNUNET_CRYPTO_SymmetricInitializationVector iv;
struct GNUNET_CRYPTO_SymmetricSessionKey skey;
char rbuf[buf_len];
@@ -69,6 +108,7 @@ GNUNET_CRYPTO_pow_hash (const char *salt,
&skey,
&iv,
&rbuf);
+#endif
GNUNET_break (0 == gcry_kdf_derive (rbuf,
buf_len,
GCRY_KDF_SCRYPT,
--
To stop receiving notification emails like this one, please contact
address@hidden.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnunet] branch master updated: implement new simplified POW for LSD001,
gnunet <=