[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnunet] branch master updated: BUILD: Allow plugins to build before hig
From: |
gnunet |
Subject: |
[gnunet] branch master updated: BUILD: Allow plugins to build before higher-level components |
Date: |
Thu, 19 Oct 2023 21:25:34 +0200 |
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 888e49aa8 BUILD: Allow plugins to build before higher-level components
888e49aa8 is described below
commit 888e49aa86f1067e4738c89bac9ac78155cd508a
Author: Martin Schanzenbach <schanzen@gnunet.org>
AuthorDate: Thu Oct 19 21:25:24 2023 +0200
BUILD: Allow plugins to build before higher-level components
---
configure.ac | 3 +-
po/POTFILES.in | 8 +-
src/Makefile.am | 2 +-
src/cli/namestore/meson.build | 2 +-
src/cli/revocation/Makefile.am | 2 +-
src/cli/revocation/gnunet-revocation-tvg.c | 22 +-
src/cli/revocation/gnunet-revocation.c | 66 ++--
src/cli/revocation/meson.build | 10 +
src/include/gnunet_crypto_lib.h | 2 -
src/include/gnunet_gnsrecord_lib.h | 129 ++++++
src/include/gnunet_revocation_service.h | 132 +------
src/lib/gnsrecord/Makefile.am | 1 +
src/lib/gnsrecord/gnsrecord_crypto.h | 9 +
.../gnsrecord/gnsrecord_pow.c} | 406 +++----------------
src/lib/gnsrecord/meson.build | 1 +
src/meson.build | 2 +-
src/plugin/Makefile.am | 1 -
src/plugin/fs/Makefile.am | 1 -
src/plugin/gns/Makefile.am | 2 -
src/plugin/gns/meson.build | 2 +-
src/plugin/meson.build | 1 -
src/plugin/namecache/Makefile.am | 9 -
src/plugin/namestore/Makefile.am | 29 +-
src/plugin/namestore/meson.build | 20 +-
src/plugin/reclaim/Makefile.am | 6 +-
src/plugin/reclaim/meson.build | 8 +-
src/plugin/revocation/Makefile.am | 3 +-
src/plugin/revocation/meson.build | 2 -
src/plugin/revocation/plugin_block_revocation.c | 28 +-
src/rest-plugin/Makefile.am | 1 +
src/rest-plugin/meson.build | 1 +
src/rest-plugin/namestore/Makefile.am | 53 +++
src/rest-plugin/namestore/meson.build | 14 +
.../namestore/plugin_rest_namestore.c | 0
src/service/Makefile.am | 1 +
src/{plugin => service}/dhtu/.gitignore | 0
src/{plugin => service}/dhtu/Makefile.am | 0
src/{plugin => service}/dhtu/dhtu.conf | 0
src/{plugin => service}/dhtu/meson.build | 0
src/{plugin => service}/dhtu/plugin_dhtu_gnunet.c | 0
src/{plugin => service}/dhtu/plugin_dhtu_ip.c | 0
src/{plugin => service}/dhtu/test_dhtu_ip.c | 0
.../dhtu/testing_dhtu_cmd_send.c | 0
src/service/meson.build | 1 +
src/service/namestore/meson.build | 2 -
src/service/revocation/Makefile.am | 2 +-
src/service/revocation/gnunet-service-revocation.c | 22 +-
src/service/revocation/meson.build | 5 +-
src/service/revocation/revocation.h | 9 -
src/service/revocation/revocation_api.c | 440 +--------------------
50 files changed, 375 insertions(+), 1085 deletions(-)
diff --git a/configure.ac b/configure.ac
index 982a4afe9..255b4bab4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1238,7 +1238,6 @@ src/lib/pq/Makefile
src/lib/sq/Makefile
src/plugin/Makefile
src/plugin/block/Makefile
-src/plugin/dhtu/Makefile
src/plugin/fs/Makefile
src/plugin/gns/Makefile
src/plugin/gnsrecord/Makefile
@@ -1258,6 +1257,7 @@ src/service/datastore/Makefile
src/service/datastore/datastore.conf
src/service/dht/Makefile
src/service/dht/dht.conf
+src/service/dhtu/Makefile
src/service/dns/Makefile
src/service/dns/dns.conf
src/service/exit/Makefile
@@ -1309,6 +1309,7 @@ src/service/zonemaster/zonemaster.conf
src/rest-plugin/Makefile
src/rest-plugin/gns/Makefile
src/rest-plugin/identity/Makefile
+src/rest-plugin/namestore/Makefile
src/rest-plugin/reclaim/Makefile
src/rest-plugin/rest/Makefile
src/cli/Makefile
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 8e5600890..d8c22b629 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -207,9 +207,6 @@ src/lib/util/tun.c
src/lib/util/uri.c
src/plugin/block/plugin_block_template.c
src/plugin/block/plugin_block_test.c
-src/plugin/dhtu/plugin_dhtu_gnunet.c
-src/plugin/dhtu/plugin_dhtu_ip.c
-src/plugin/dhtu/testing_dhtu_cmd_send.c
src/plugin/fs/plugin_block_fs.c
src/plugin/gns/plugin_block_gns.c
src/plugin/gns/plugin_gnsrecord_gns.c
@@ -220,7 +217,6 @@ src/plugin/namecache/plugin_namecache_sqlite.c
src/plugin/namestore/plugin_namestore_flat.c
src/plugin/namestore/plugin_namestore_postgres.c
src/plugin/namestore/plugin_namestore_sqlite.c
-src/plugin/namestore/plugin_rest_namestore.c
src/plugin/reclaim/pabc_helper.c
src/plugin/reclaim/plugin_gnsrecord_reclaim.c
src/plugin/reclaim/plugin_reclaim_attribute_basic.c
@@ -229,6 +225,7 @@ src/plugin/reclaim/plugin_reclaim_credential_pabc.c
src/plugin/revocation/plugin_block_revocation.c
src/rest-plugin/gns/plugin_rest_gns.c
src/rest-plugin/identity/plugin_rest_identity.c
+src/rest-plugin/namestore/plugin_rest_namestore.c
src/rest-plugin/reclaim/json_reclaim.c
src/rest-plugin/reclaim/oidc_helper.c
src/rest-plugin/reclaim/plugin_rest_openid_connect.c
@@ -285,6 +282,9 @@ src/service/dht/gnunet-service-dht_neighbours.c
src/service/dht/gnunet-service-dht_routing.c
src/service/dht/gnunet_dht_profiler.c
src/service/dht/plugin_block_dht.c
+src/service/dhtu/plugin_dhtu_gnunet.c
+src/service/dhtu/plugin_dhtu_ip.c
+src/service/dhtu/testing_dhtu_cmd_send.c
src/service/dns/dns_api.c
src/service/dns/gnunet-dns-monitor.c
src/service/dns/gnunet-dns-redirector.c
diff --git a/src/Makefile.am b/src/Makefile.am
index 2b1e94c50..c0c5309b2 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -5,8 +5,8 @@
SUBDIRS = \
include $(INTLEMU_SUBDIRS) \
lib \
- service \
plugin \
+ service \
rest-plugin \
cli \
contrib
diff --git a/src/cli/namestore/meson.build b/src/cli/namestore/meson.build
index 2bad795b9..e619876c5 100644
--- a/src/cli/namestore/meson.build
+++ b/src/cli/namestore/meson.build
@@ -1,5 +1,5 @@
executable ('gnunet-namestore',
- gnunetnamestore_src,
+ ['gnunet-namestore.c'],
dependencies: [libgnunetnamestore_dep,
libgnunetutil_dep,
libgnunetgnsrecord_dep,
diff --git a/src/cli/revocation/Makefile.am b/src/cli/revocation/Makefile.am
index 6bd4919f9..f88a74ca6 100644
--- a/src/cli/revocation/Makefile.am
+++ b/src/cli/revocation/Makefile.am
@@ -27,7 +27,7 @@ gnunet_revocation_tvg_SOURCES = \
gnunet-revocation-tvg.c
gnunet_revocation_tvg_LDADD = \
$(top_builddir)/src/service/revocation/libgnunetrevocation.la \
- $(top_builddir)/src/service/identity/libgnunetidentity.la \
+ $(top_builddir)/src/lib/gnsrecord/libgnunetgnsrecord.la \
$(top_builddir)/src/lib/util/libgnunetutil.la \
$(GN_LIBINTL)
diff --git a/src/cli/revocation/gnunet-revocation-tvg.c
b/src/cli/revocation/gnunet-revocation-tvg.c
index 7d354ed74..5c2bfbe45 100644
--- a/src/cli/revocation/gnunet-revocation-tvg.c
+++ b/src/cli/revocation/gnunet-revocation-tvg.c
@@ -29,7 +29,7 @@
#include "gnunet_revocation_service.h"
#include "gnunet_testing_lib.h"
// FIXME try to avoid this include somehow
-#include "../../service/revocation/revocation.h"
+#include "../../lib/gnsrecord/gnsrecord_crypto.h"
#include <inttypes.h>
#define TEST_EPOCHS 2
@@ -105,8 +105,8 @@ static void
run_with_key (struct GNUNET_CRYPTO_PrivateKey *id_priv)
{
struct GNUNET_CRYPTO_PublicKey id_pub;
- struct GNUNET_REVOCATION_PowP *pow;
- struct GNUNET_REVOCATION_PowCalculationHandle *ph;
+ struct GNUNET_GNSRECORD_PowP *pow;
+ struct GNUNET_GNSRECORD_PowCalculationHandle *ph;
struct GNUNET_TIME_Relative exp;
char ztld[128];
ssize_t key_len;
@@ -127,10 +127,10 @@ run_with_key (struct GNUNET_CRYPTO_PrivateKey *id_priv)
fprintf (stdout, "Encoded zone identifier (zkl = zTLD):\n");
fprintf (stdout, "%s\n", ztld);
fprintf (stdout, "\n");
- pow = GNUNET_malloc (GNUNET_REVOCATION_MAX_PROOF_SIZE);
- GNUNET_REVOCATION_pow_init (id_priv,
+ pow = GNUNET_malloc (GNUNET_MAX_POW_SIZE);
+ GNUNET_GNSRECORD_pow_init (id_priv,
pow);
- ph = GNUNET_REVOCATION_pow_start (pow,
+ ph = GNUNET_GNSRECORD_pow_start (pow,
TEST_EPOCHS,
TEST_DIFFICULTY);
fprintf (stdout, "Difficulty (%d base difficulty + %d epochs): %d\n\n",
@@ -138,12 +138,12 @@ run_with_key (struct GNUNET_CRYPTO_PrivateKey *id_priv)
TEST_EPOCHS,
TEST_DIFFICULTY + TEST_EPOCHS);
uint64_t pow_passes = 0;
- while (GNUNET_YES != GNUNET_REVOCATION_pow_round (ph))
+ while (GNUNET_YES != GNUNET_GNSRECORD_pow_round (ph))
{
pow_passes++;
}
- struct GNUNET_REVOCATION_SignaturePurposePS *purp;
- purp = REV_create_signature_message (pow);
+ struct GNUNET_GNSRECORD_SignaturePurposePS *purp;
+ purp = GNR_create_signature_message (pow);
fprintf (stdout, "Signed message:\n");
print_bytes (purp,
ntohl (purp->purpose.size),
@@ -153,12 +153,12 @@ run_with_key (struct GNUNET_CRYPTO_PrivateKey *id_priv)
exp = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_YEARS,
TEST_EPOCHS);
- GNUNET_assert (GNUNET_OK == GNUNET_REVOCATION_check_pow (pow,
+ GNUNET_assert (GNUNET_OK == GNUNET_GNSRECORD_check_pow (pow,
TEST_DIFFICULTY,
exp));
fprintf (stdout, "Proof:\n");
print_bytes (pow,
- GNUNET_REVOCATION_proof_get_size (pow),
+ GNUNET_GNSRECORD_proof_get_size (pow),
8);
GNUNET_free (ph);
diff --git a/src/cli/revocation/gnunet-revocation.c
b/src/cli/revocation/gnunet-revocation.c
index 9667e7655..add9a003b 100644
--- a/src/cli/revocation/gnunet-revocation.c
+++ b/src/cli/revocation/gnunet-revocation.c
@@ -24,9 +24,9 @@
* @author Christian Grothoff
*/
#include "platform.h"
+#include "gnunet_gnsrecord_lib.h"
#include "gnunet_util_lib.h"
#include "gnunet_revocation_service.h"
-#include "gnunet_identity_service.h"
/**
* Pow passes
@@ -101,7 +101,7 @@ static struct GNUNET_SCHEDULER_Task *pow_task;
/**
* Proof-of-work object
*/
-static struct GNUNET_REVOCATION_PowP *proof_of_work;
+static struct GNUNET_GNSRECORD_PowP *proof_of_work;
/**
* Function run if the user aborts with CTRL-C.
@@ -228,7 +228,7 @@ perform_revocation ()
static void
sync_pow ()
{
- size_t psize = GNUNET_REVOCATION_proof_get_size (proof_of_work);
+ size_t psize = GNUNET_GNSRECORD_proof_get_size (proof_of_work);
if ((NULL != filename) &&
(GNUNET_OK !=
GNUNET_DISK_fn_write (filename,
@@ -248,7 +248,7 @@ sync_pow ()
static void
calculate_pow_shutdown (void *cls)
{
- struct GNUNET_REVOCATION_PowCalculationHandle *ph = cls;
+ struct GNUNET_GNSRECORD_PowCalculationHandle *ph = cls;
fprintf (stderr, "%s", _ ("Cancelling calculation.\n"));
sync_pow ();
if (NULL != pow_task)
@@ -257,7 +257,7 @@ calculate_pow_shutdown (void *cls)
pow_task = NULL;
}
if (NULL != ph)
- GNUNET_REVOCATION_pow_stop (ph);
+ GNUNET_GNSRECORD_pow_stop (ph);
}
@@ -269,7 +269,7 @@ calculate_pow_shutdown (void *cls)
static void
calculate_pow (void *cls)
{
- struct GNUNET_REVOCATION_PowCalculationHandle *ph = cls;
+ struct GNUNET_GNSRECORD_PowCalculationHandle *ph = cls;
size_t psize;
/* store temporary results */
@@ -277,9 +277,9 @@ calculate_pow (void *cls)
if (0 == (pow_passes % 128))
sync_pow ();
/* actually do POW calculation */
- if (GNUNET_OK == GNUNET_REVOCATION_pow_round (ph))
+ if (GNUNET_OK == GNUNET_GNSRECORD_pow_round (ph))
{
- psize = GNUNET_REVOCATION_proof_get_size (proof_of_work);
+ psize = GNUNET_GNSRECORD_proof_get_size (proof_of_work);
if (NULL != filename)
{
(void) GNUNET_DISK_directory_remove (filename);
@@ -325,7 +325,7 @@ ego_callback (void *cls, struct GNUNET_IDENTITY_Ego *ego)
{
struct GNUNET_CRYPTO_PublicKey key;
const struct GNUNET_CRYPTO_PrivateKey *privkey;
- struct GNUNET_REVOCATION_PowCalculationHandle *ph = NULL;
+ struct GNUNET_GNSRECORD_PowCalculationHandle *ph = NULL;
size_t psize;
el = NULL;
@@ -337,11 +337,11 @@ ego_callback (void *cls, struct GNUNET_IDENTITY_Ego *ego)
}
GNUNET_IDENTITY_ego_get_public_key (ego, &key);
privkey = GNUNET_IDENTITY_ego_get_private_key (ego);
- proof_of_work = GNUNET_malloc (GNUNET_REVOCATION_MAX_PROOF_SIZE);
+ proof_of_work = GNUNET_malloc (GNUNET_MAX_POW_SIZE);
if ((NULL != filename) && (GNUNET_YES == GNUNET_DISK_file_test (filename)) &&
(0 < (psize =
GNUNET_DISK_fn_read (filename, proof_of_work,
- GNUNET_REVOCATION_MAX_PROOF_SIZE))))
+ GNUNET_MAX_POW_SIZE))))
{
ssize_t ksize = GNUNET_CRYPTO_public_key_get_length (&key);
if (0 > ksize)
@@ -360,9 +360,9 @@ ego_callback (void *cls, struct GNUNET_IDENTITY_Ego *ego)
return;
}
if (GNUNET_YES ==
- GNUNET_REVOCATION_check_pow (proof_of_work,
- (unsigned int) matching_bits,
- epoch_duration))
+ GNUNET_GNSRECORD_check_pow (proof_of_work,
+ (unsigned int) matching_bits,
+ epoch_duration))
{
fprintf (stderr, "%s", _ ("Revocation certificate ready\n"));
if (perform)
@@ -377,20 +377,20 @@ ego_callback (void *cls, struct GNUNET_IDENTITY_Ego *ego)
fprintf (stderr,
"%s",
_ ("Continuing calculation where left off...\n"));
- ph = GNUNET_REVOCATION_pow_start (proof_of_work,
- epochs,
- matching_bits);
+ ph = GNUNET_GNSRECORD_pow_start (proof_of_work,
+ epochs,
+ matching_bits);
}
fprintf (stderr,
"%s",
_ ("Revocation certificate not ready, calculating proof of
work\n"));
if (NULL == ph)
{
- GNUNET_REVOCATION_pow_init (privkey,
- proof_of_work);
- ph = GNUNET_REVOCATION_pow_start (proof_of_work,
- epochs, /* Epochs */
- matching_bits);
+ GNUNET_GNSRECORD_pow_init (privkey,
+ proof_of_work);
+ ph = GNUNET_GNSRECORD_pow_start (proof_of_work,
+ epochs, /* Epochs */
+ matching_bits);
}
pow_task = GNUNET_SCHEDULER_add_now (&calculate_pow, ph);
GNUNET_SCHEDULER_add_shutdown (&calculate_pow_shutdown, ph);
@@ -419,7 +419,7 @@ run (void *cls,
{
if (GNUNET_OK !=
GNUNET_CRYPTO_public_key_from_string (test_ego,
- &pk))
+ &pk))
{
fprintf (stderr, _ ("Public key `%s' malformed\n"), test_ego);
return;
@@ -472,17 +472,17 @@ run (void *cls,
if ((NULL != filename) && (perform))
{
size_t bread;
- proof_of_work = GNUNET_malloc (GNUNET_REVOCATION_MAX_PROOF_SIZE);
+ proof_of_work = GNUNET_malloc (GNUNET_MAX_POW_SIZE);
if (0 < (bread = GNUNET_DISK_fn_read (filename,
proof_of_work,
- GNUNET_REVOCATION_MAX_PROOF_SIZE)))
+ GNUNET_MAX_POW_SIZE)))
{
fprintf (stderr,
_ ("Failed to read revocation certificate from `%s'\n"),
filename);
return;
}
- psize = GNUNET_REVOCATION_proof_get_size (proof_of_work);
+ psize = GNUNET_GNSRECORD_proof_get_size (proof_of_work);
if (bread != psize)
{
fprintf (stderr,
@@ -492,14 +492,14 @@ run (void *cls,
}
GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL);
if (GNUNET_YES !=
- GNUNET_REVOCATION_check_pow (proof_of_work,
- (unsigned int) matching_bits,
- epoch_duration))
+ GNUNET_GNSRECORD_check_pow (proof_of_work,
+ (unsigned int) matching_bits,
+ epoch_duration))
{
- struct GNUNET_REVOCATION_PowCalculationHandle *ph;
- ph = GNUNET_REVOCATION_pow_start (proof_of_work,
- epochs, /* Epochs */
- matching_bits);
+ struct GNUNET_GNSRECORD_PowCalculationHandle *ph;
+ ph = GNUNET_GNSRECORD_pow_start (proof_of_work,
+ epochs, /* Epochs */
+ matching_bits);
pow_task = GNUNET_SCHEDULER_add_now (&calculate_pow, ph);
GNUNET_SCHEDULER_add_shutdown (&calculate_pow_shutdown, ph);
diff --git a/src/cli/revocation/meson.build b/src/cli/revocation/meson.build
index 83923c278..090b381df 100644
--- a/src/cli/revocation/meson.build
+++ b/src/cli/revocation/meson.build
@@ -4,9 +4,19 @@ executable ('gnunet-revocation',
libgnunetutil_dep,
libgnunetstatistics_dep,
libgnunetcore_dep,
+ libgnunetgnsrecord_dep,
libgnunetsetu_dep,
libgnunetidentity_dep],
include_directories: [incdir, configuration_inc],
install: true,
install_dir: get_option('bindir'))
+executable ('gnunet-revocation-tvg',
+ ['gnunet-revocation.c'],
+ dependencies: [libgnunetrevocation_dep,
+ libgnunetutil_dep,
+ libgnunetgnsrecord_dep,
+ libgnunetidentity_dep],
+ include_directories: [incdir, configuration_inc],
+ install: false)
+
diff --git a/src/include/gnunet_crypto_lib.h b/src/include/gnunet_crypto_lib.h
index ca51f586c..f3ea3ed25 100644
--- a/src/include/gnunet_crypto_lib.h
+++ b/src/include/gnunet_crypto_lib.h
@@ -3637,8 +3637,6 @@ GNUNET_CRYPTO_key_get_public (const struct
GNUNET_CRYPTO_PrivateKey *privkey,
struct GNUNET_CRYPTO_PublicKey *key);
-
-
#if 0 /* keep Emacsens' auto-indent happy */
{
#endif
diff --git a/src/include/gnunet_gnsrecord_lib.h
b/src/include/gnunet_gnsrecord_lib.h
index d78e637e8..3f1830498 100644
--- a/src/include/gnunet_gnsrecord_lib.h
+++ b/src/include/gnunet_gnsrecord_lib.h
@@ -829,6 +829,135 @@ GNUNET_GNSRECORD_normalize_record_set (const char *label,
enum GNUNET_GenericReturnValue
GNUNET_GNSRECORD_label_check (const char*label, char **emsg);
+/**
+ * Maximum length of a revocation
+ */
+#define GNUNET_MAX_POW_SIZE sizeof(struct GNUNET_GNSRECORD_PowP) +\
+ sizeof(struct
GNUNET_CRYPTO_PublicKey) +\
+ 1024 //FIXME max sig_len
+
+/**
+ * The proof-of-work narrowing factor.
+ * The number of PoWs that are calculates as part of revocation.
+ */
+#define POW_COUNT 32
+
+
+GNUNET_NETWORK_STRUCT_BEGIN
+
+/**
+ * Struct for a proof of work as part of the revocation.
+ */
+struct GNUNET_GNSRECORD_PowP
+{
+ /**
+ * The timestamp of the revocation
+ */
+ struct GNUNET_TIME_AbsoluteNBO timestamp;
+
+ /**
+ * The TTL of this revocation (purely informational)
+ */
+ struct GNUNET_TIME_RelativeNBO ttl;
+
+ /**
+ * The PoWs
+ */
+ uint64_t pow[POW_COUNT] GNUNET_PACKED;
+
+ /** followed by the public key type, the key and a signature **/
+};
+
+
+/**
+ * The signature object we use for the PoW
+ */
+struct GNUNET_GNSRECORD_SignaturePurposePS
+{
+ /**
+ * The signature purpose
+ */
+ struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
+
+ /**
+ * The timestamp of the revocation
+ */
+ struct GNUNET_TIME_AbsoluteNBO timestamp;
+
+ /** Followed by the zone public key type and key **/
+};
+
+GNUNET_NETWORK_STRUCT_END
+
+
+/**
+ * Handle to a running proof-of-work calculation.
+ */
+struct GNUNET_GNSRECORD_PowCalculationHandle;
+
+
+/**
+ * Check if the given proof-of-work is valid.
+ *
+ * @param pow proof of work
+ * @param matching_bits how many bits must match (configuration)
+ * @param epoch_duration length of single epoch in configuration
+ * @return #GNUNET_YES if the @a pow is acceptable, #GNUNET_NO if not
+ */
+enum GNUNET_GenericReturnValue
+GNUNET_GNSRECORD_check_pow (const struct GNUNET_GNSRECORD_PowP *pow,
+ unsigned int matching_bits,
+ struct GNUNET_TIME_Relative epoch_duration);
+
+
+/**
+ * Initializes a fresh PoW computation.
+ *
+ * @param key the key to calculate the PoW for.
+ * @param pow the pow object to work with in the calculation.
+ */
+void
+GNUNET_GNSRECORD_pow_init (const struct GNUNET_CRYPTO_PrivateKey *key,
+ struct GNUNET_GNSRECORD_PowP *pow);
+
+
+/**
+ * Starts a proof-of-work calculation given the pow object as well as
+ * target epochs and difficulty.
+ *
+ * @param pow the PoW to based calculations on.
+ * @param epochs the number of epochs for which the PoW must be valid.
+ * @param difficulty the base difficulty of the PoW.
+ * @return a handle for use in PoW rounds
+ */
+struct GNUNET_GNSRECORD_PowCalculationHandle*
+GNUNET_GNSRECORD_pow_start (struct GNUNET_GNSRECORD_PowP *pow,
+ int epochs,
+ unsigned int difficulty);
+
+
+/**
+ * Calculate a single round in the key revocation PoW.
+ *
+ * @param pc handle to the PoW, initially called with NULL.
+ * @return GNUNET_YES if the @a pow is acceptable, GNUNET_NO if not
+ */
+enum GNUNET_GenericReturnValue
+GNUNET_GNSRECORD_pow_round (struct GNUNET_GNSRECORD_PowCalculationHandle *pc);
+
+size_t
+GNUNET_GNSRECORD_proof_get_size (const struct GNUNET_GNSRECORD_PowP *pow);
+
+/**
+ * Stop a PoW calculation
+ *
+ * @param pc the calculation to clean up
+ * @return #GNUNET_YES if pow valid, #GNUNET_NO if pow was set but is not
+ * valid
+ */
+void
+GNUNET_GNSRECORD_pow_stop (struct GNUNET_GNSRECORD_PowCalculationHandle *pc);
+
#if 0 /* keep Emacsens' auto-indent happy */
{
#endif
diff --git a/src/include/gnunet_revocation_service.h
b/src/include/gnunet_revocation_service.h
index de5eedbb9..427be62ac 100644
--- a/src/include/gnunet_revocation_service.h
+++ b/src/include/gnunet_revocation_service.h
@@ -22,6 +22,7 @@
#define GNUNET_REVOCATION_SERVICE_H_
+#include "gnunet_gnsrecord_lib.h"
#include "gnunet_identity_service.h"
/**
@@ -56,71 +57,6 @@ extern "C"
*/
#define GNUNET_REVOCATION_VERSION 0x00000001
-/**
- * Maximum length of a revocation
- */
-#define GNUNET_REVOCATION_MAX_PROOF_SIZE sizeof(struct GNUNET_REVOCATION_PowP)
+\
- sizeof(struct
GNUNET_CRYPTO_PublicKey) +\
- 1024 //FIXME max sig_len
-
-/**
- * The proof-of-work narrowing factor.
- * The number of PoWs that are calculates as part of revocation.
- */
-#define POW_COUNT 32
-
-
-GNUNET_NETWORK_STRUCT_BEGIN
-
-/**
- * Struct for a proof of work as part of the revocation.
- */
-struct GNUNET_REVOCATION_PowP
-{
- /**
- * The timestamp of the revocation
- */
- struct GNUNET_TIME_AbsoluteNBO timestamp;
-
- /**
- * The TTL of this revocation (purely informational)
- */
- struct GNUNET_TIME_RelativeNBO ttl;
-
- /**
- * The PoWs
- */
- uint64_t pow[POW_COUNT] GNUNET_PACKED;
-
- /** followed by the public key type, the key and a signature **/
-};
-
-
-/**
- * The signature object we use for the PoW
- */
-struct GNUNET_REVOCATION_SignaturePurposePS
-{
- /**
- * The signature purpose
- */
- struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
-
- /**
- * The timestamp of the revocation
- */
- struct GNUNET_TIME_AbsoluteNBO timestamp;
-
- /** Followed by the zone public key type and key **/
-};
-
-GNUNET_NETWORK_STRUCT_END
-
-
-/**
- * Handle to a running proof-of-work calculation.
- */
-struct GNUNET_REVOCATION_PowCalculationHandle;
/**
* Handle for the key revocation query.
@@ -176,7 +112,7 @@ struct GNUNET_REVOCATION_Handle;
*
* @param cfg the configuration to use
* @param pow proof of work to use (should have been created by
- * iteratively calling #GNUNET_REVOCATION_pow_round)
+ * iteratively calling #GNUNET_CRYPTO_pow_round)
* @param func function to call with the result of the check
* (called with `is_valid` being #GNUNET_NO if
* the revocation worked).
@@ -185,7 +121,7 @@ struct GNUNET_REVOCATION_Handle;
*/
struct GNUNET_REVOCATION_Handle *
GNUNET_REVOCATION_revoke (const struct GNUNET_CONFIGURATION_Handle *cfg,
- const struct GNUNET_REVOCATION_PowP *pow,
+ const struct GNUNET_GNSRECORD_PowP *pow,
GNUNET_REVOCATION_Callback func, void *func_cls);
@@ -198,68 +134,6 @@ void
GNUNET_REVOCATION_revoke_cancel (struct GNUNET_REVOCATION_Handle *h);
-/**
- * Check if the given proof-of-work is valid.
- *
- * @param pow proof of work
- * @param matching_bits how many bits must match (configuration)
- * @param epoch_duration length of single epoch in configuration
- * @return #GNUNET_YES if the @a pow is acceptable, #GNUNET_NO if not
- */
-enum GNUNET_GenericReturnValue
-GNUNET_REVOCATION_check_pow (const struct GNUNET_REVOCATION_PowP *pow,
- unsigned int matching_bits,
- struct GNUNET_TIME_Relative epoch_duration);
-
-
-/**
- * Initializes a fresh PoW computation.
- *
- * @param key the key to calculate the PoW for.
- * @param pow the pow object to work with in the calculation.
- */
-void
-GNUNET_REVOCATION_pow_init (const struct GNUNET_CRYPTO_PrivateKey *key,
- struct GNUNET_REVOCATION_PowP *pow);
-
-
-/**
- * Starts a proof-of-work calculation given the pow object as well as
- * target epochs and difficulty.
- *
- * @param pow the PoW to based calculations on.
- * @param epochs the number of epochs for which the PoW must be valid.
- * @param difficulty the base difficulty of the PoW.
- * @return a handle for use in PoW rounds
- */
-struct GNUNET_REVOCATION_PowCalculationHandle*
-GNUNET_REVOCATION_pow_start (struct GNUNET_REVOCATION_PowP *pow,
- int epochs,
- unsigned int difficulty);
-
-
-/**
- * Calculate a single round in the key revocation PoW.
- *
- * @param pc handle to the PoW, initially called with NULL.
- * @return GNUNET_YES if the @a pow is acceptable, GNUNET_NO if not
- */
-enum GNUNET_GenericReturnValue
-GNUNET_REVOCATION_pow_round (struct GNUNET_REVOCATION_PowCalculationHandle
*pc);
-
-
-/**
- * Stop a PoW calculation
- *
- * @param pc the calculation to clean up
- * @return #GNUNET_YES if pow valid, #GNUNET_NO if pow was set but is not
- * valid
- */
-void
-GNUNET_REVOCATION_pow_stop (struct GNUNET_REVOCATION_PowCalculationHandle *pc);
-
-size_t
-GNUNET_REVOCATION_proof_get_size (const struct GNUNET_REVOCATION_PowP *pow);
#if 0 /* keep Emacsens' auto-indent happy */
diff --git a/src/lib/gnsrecord/Makefile.am b/src/lib/gnsrecord/Makefile.am
index 57b004847..ab79de900 100644
--- a/src/lib/gnsrecord/Makefile.am
+++ b/src/lib/gnsrecord/Makefile.am
@@ -47,6 +47,7 @@ libgnunetgnsrecord_la_SOURCES = \
gnsrecord.c \
gnsrecord_serialization.c \
gnsrecord_crypto.c \
+ gnsrecord_pow.c \
gnsrecord_misc.c
libgnunetgnsrecord_la_LIBADD = \
$(top_builddir)/src/lib/util/libgnunetutil.la \
diff --git a/src/lib/gnsrecord/gnsrecord_crypto.h
b/src/lib/gnsrecord/gnsrecord_crypto.h
index 4f2e4a5ca..85f2258ab 100644
--- a/src/lib/gnsrecord/gnsrecord_crypto.h
+++ b/src/lib/gnsrecord/gnsrecord_crypto.h
@@ -83,3 +83,12 @@ GNR_derive_block_xsalsa_key (unsigned char *nonce,
uint64_t exp,
const struct GNUNET_CRYPTO_EddsaPublicKey *pub);
+/**
+ * Create the revocation metadata to sign for a revocation message
+ *
+ * @param pow the PoW to sign
+ * @return the signature purpose
+ */
+struct GNUNET_GNSRECORD_SignaturePurposePS *
+GNR_create_signature_message (const struct GNUNET_GNSRECORD_PowP *pow);
+
diff --git a/src/service/revocation/revocation_api.c
b/src/lib/gnsrecord/gnsrecord_pow.c
similarity index 51%
copy from src/service/revocation/revocation_api.c
copy to src/lib/gnsrecord/gnsrecord_pow.c
index 3b7d83710..a40dd7802 100644
--- a/src/service/revocation/revocation_api.c
+++ b/src/lib/gnsrecord/gnsrecord_pow.c
@@ -17,40 +17,19 @@
SPDX-License-Identifier: AGPL3.0-or-later
*/
+
+
/**
- * @file revocation/revocation_api.c
- * @brief API to perform and access key revocations
- * @author Christian Grothoff
+ * @brief API for proof of work
+ * @author Martin Schanzenbach
*/
#include "platform.h"
-#include "gnunet_revocation_service.h"
+#include "gnunet_util_lib.h"
+#include "gnunet_gnsrecord_lib.h"
#include "gnunet_signatures.h"
#include "gnunet_protocols.h"
-#include "revocation.h"
#include <inttypes.h>
-/**
- * Handle for the key revocation query.
- */
-struct GNUNET_REVOCATION_Query
-{
- /**
- * Message queue to the service.
- */
- struct GNUNET_MQ_Handle *mq;
-
- /**
- * Function to call with the result.
- */
- GNUNET_REVOCATION_Callback func;
-
- /**
- * Closure for @e func.
- */
- void *func_cls;
-};
-
-
/**
* Helper struct that holds a found pow nonce
* and the corresponding number of leading zeros.
@@ -73,7 +52,7 @@ struct BestPow
* The handle to a PoW calculation.
* Used in iterative PoW rounds.
*/
-struct GNUNET_REVOCATION_PowCalculationHandle
+struct GNUNET_GNSRECORD_PowCalculationHandle
{
/**
* Current set of found PoWs
@@ -83,7 +62,7 @@ struct GNUNET_REVOCATION_PowCalculationHandle
/**
* The final PoW result data structure.
*/
- struct GNUNET_REVOCATION_PowP *pow;
+ struct GNUNET_GNSRECORD_PowP *pow;
/**
* The current nonce to try
@@ -105,286 +84,6 @@ struct GNUNET_REVOCATION_PowCalculationHandle
static struct GNUNET_CRYPTO_PowSalt salt = { "GnsRevocationPow" };
-/**
- * Generic error handler, called with the appropriate
- * error code and the same closure specified at the creation of
- * the message queue.
- * Not every message queue implementation supports an error handler.
- *
- * @param cls closure with the `struct GNUNET_NSE_Handle *`
- * @param error error code
- */
-static void
-query_mq_error_handler (void *cls,
- enum GNUNET_MQ_Error error)
-{
- struct GNUNET_REVOCATION_Query *q = cls;
-
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Revocation query MQ error\n");
- q->func (q->func_cls,
- GNUNET_SYSERR);
- GNUNET_REVOCATION_query_cancel (q);
-}
-
-
-/**
- * Handle response to our revocation query.
- *
- * @param cls our `struct GNUNET_REVOCATION_Query` handle
- * @param qrm response we got
- */
-static void
-handle_revocation_query_response (void *cls,
- const struct QueryResponseMessage *qrm)
-{
- struct GNUNET_REVOCATION_Query *q = cls;
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Revocation query result: %d\n",
- (uint32_t) ntohl (qrm->is_valid));
- q->func (q->func_cls,
- ntohl (qrm->is_valid));
- GNUNET_REVOCATION_query_cancel (q);
-}
-
-
-/**
- * Check if a key was revoked.
- *
- * @param cfg the configuration to use
- * @param key key to check for revocation
- * @param func function to call with the result of the check
- * @param func_cls closure to pass to @a func
- * @return handle to use in #GNUNET_REVOCATION_query_cancel to stop REVOCATION
from invoking the callback
- */
-struct GNUNET_REVOCATION_Query *
-GNUNET_REVOCATION_query (const struct GNUNET_CONFIGURATION_Handle *cfg,
- const struct GNUNET_CRYPTO_PublicKey *key,
- GNUNET_REVOCATION_Callback func,
- void *func_cls)
-{
- struct GNUNET_REVOCATION_Query *q
- = GNUNET_new (struct GNUNET_REVOCATION_Query);
- struct GNUNET_MQ_MessageHandler handlers[] = {
- GNUNET_MQ_hd_fixed_size (revocation_query_response,
- GNUNET_MESSAGE_TYPE_REVOCATION_QUERY_RESPONSE,
- struct QueryResponseMessage,
- q),
- GNUNET_MQ_handler_end ()
- };
- struct QueryMessage *qm;
- struct GNUNET_MQ_Envelope *env;
- size_t key_len;
-
- q->mq = GNUNET_CLIENT_connect (cfg,
- "revocation",
- handlers,
- &query_mq_error_handler,
- q);
- if (NULL == q->mq)
- {
- GNUNET_free (q);
- return NULL;
- }
- q->func = func;
- q->func_cls = func_cls;
- key_len = GNUNET_CRYPTO_public_key_get_length (key);
- env = GNUNET_MQ_msg_extra (qm, key_len,
- GNUNET_MESSAGE_TYPE_REVOCATION_QUERY);
- GNUNET_CRYPTO_write_public_key_to_buffer (key, &qm[1], key_len);
- qm->key_len = htonl (key_len);
- GNUNET_MQ_send (q->mq,
- env);
- return q;
-}
-
-
-/**
- * Cancel key revocation check.
- *
- * @param q query to cancel
- */
-void
-GNUNET_REVOCATION_query_cancel (struct GNUNET_REVOCATION_Query *q)
-{
- if (NULL != q->mq)
- {
- GNUNET_MQ_destroy (q->mq);
- q->mq = NULL;
- }
- GNUNET_free (q);
-}
-
-
-/**
- * Handle for the key revocation operation.
- */
-struct GNUNET_REVOCATION_Handle
-{
- /**
- * Message queue to the service.
- */
- struct GNUNET_MQ_Handle *mq;
-
- /**
- * Function to call once we are done.
- */
- GNUNET_REVOCATION_Callback func;
-
- /**
- * Closure for @e func.
- */
- void *func_cls;
-};
-
-
-/**
- * Generic error handler, called with the appropriate
- * error code and the same closure specified at the creation of
- * the message queue.
- * Not every message queue implementation supports an error handler.
- *
- * @param cls closure with the `struct GNUNET_NSE_Handle *`
- * @param error error code
- */
-static void
-revocation_mq_error_handler (void *cls,
- enum GNUNET_MQ_Error error)
-{
- struct GNUNET_REVOCATION_Handle *h = cls;
-
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "Revocation MQ error\n");
- h->func (h->func_cls,
- GNUNET_SYSERR);
- GNUNET_REVOCATION_revoke_cancel (h);
-}
-
-
-/**
- * Handle response to our revocation query.
- *
- * @param cls our `struct GNUNET_REVOCATION_Handle` handle
- * @param rrm response we got
- */
-static void
-handle_revocation_response (void *cls,
- const struct RevocationResponseMessage *rrm)
-{
- struct GNUNET_REVOCATION_Handle *h = cls;
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Revocation transmission result: %d\n",
- (uint32_t) ntohl (rrm->is_valid));
- h->func (h->func_cls,
- ntohl (rrm->is_valid));
- GNUNET_REVOCATION_revoke_cancel (h);
-}
-
-
-/**
- * Perform key revocation.
- *
- * @param cfg the configuration to use
- * @param key public key of the key to revoke
- * @param sig signature to use on the revocation (should have been
- * created using #GNUNET_REVOCATION_sign_revocation).
- * @param ts revocation timestamp
- * @param pow proof of work to use (should have been created by
- * iteratively calling #GNUNET_REVOCATION_check_pow)
- * @param func function to call with the result of the check
- * (called with `is_valid` being #GNUNET_NO if
- * the revocation worked).
- * @param func_cls closure to pass to @a func
- * @return handle to use in #GNUNET_REVOCATION_revoke_cancel to stop
REVOCATION from invoking the callback
- */
-struct GNUNET_REVOCATION_Handle *
-GNUNET_REVOCATION_revoke (const struct GNUNET_CONFIGURATION_Handle *cfg,
- const struct GNUNET_REVOCATION_PowP *pow,
- GNUNET_REVOCATION_Callback func,
- void *func_cls)
-{
- struct GNUNET_REVOCATION_Handle *h
- = GNUNET_new (struct GNUNET_REVOCATION_Handle);
- struct GNUNET_MQ_MessageHandler handlers[] = {
- GNUNET_MQ_hd_fixed_size (revocation_response,
- GNUNET_MESSAGE_TYPE_REVOCATION_REVOKE_RESPONSE,
- struct RevocationResponseMessage,
- h),
- GNUNET_MQ_handler_end ()
- };
- unsigned long long matching_bits;
- struct GNUNET_TIME_Relative epoch_duration;
- struct RevokeMessage *rm;
- struct GNUNET_MQ_Envelope *env;
-
- if ((GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_number (cfg,
- "REVOCATION",
- "WORKBITS",
- &matching_bits)))
- {
- GNUNET_break (0);
- GNUNET_free (h);
- return NULL;
- }
- if ((GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_time (cfg,
- "REVOCATION",
- "EPOCH_DURATION",
- &epoch_duration)))
- {
- GNUNET_break (0);
- GNUNET_free (h);
- return NULL;
- }
- if (GNUNET_YES != GNUNET_REVOCATION_check_pow (pow,
- (unsigned int) matching_bits,
- epoch_duration))
- {
- GNUNET_break (0);
- GNUNET_free (h);
- return NULL;
- }
-
-
- h->mq = GNUNET_CLIENT_connect (cfg,
- "revocation",
- handlers,
- &revocation_mq_error_handler,
- h);
- if (NULL == h->mq)
- {
- GNUNET_free (h);
- return NULL;
- }
- h->func = func;
- h->func_cls = func_cls;
- size_t extra_len = GNUNET_REVOCATION_proof_get_size (pow);
- env = GNUNET_MQ_msg_extra (rm,
- extra_len,
- GNUNET_MESSAGE_TYPE_REVOCATION_REVOKE);
- rm->pow_size = htonl (extra_len);
- memcpy (&rm[1], pow, extra_len);
- GNUNET_MQ_send (h->mq,
- env);
- return h;
-}
-
-
-void
-GNUNET_REVOCATION_revoke_cancel (struct GNUNET_REVOCATION_Handle *h)
-{
- if (NULL != h->mq)
- {
- GNUNET_MQ_destroy (h->mq);
- h->mq = NULL;
- }
- GNUNET_free (h);
-}
-
-
/**
* Calculate the average zeros in the pows.
*
@@ -392,7 +91,7 @@ GNUNET_REVOCATION_revoke_cancel (struct
GNUNET_REVOCATION_Handle *h)
* @return the average number of zeros.
*/
static unsigned int
-calculate_score (const struct GNUNET_REVOCATION_PowCalculationHandle *ph)
+calculate_score (const struct GNUNET_GNSRECORD_PowCalculationHandle *ph)
{
double sum = 0.0;
for (unsigned int j = 0; j<POW_COUNT; j++)
@@ -402,10 +101,10 @@ calculate_score (const struct
GNUNET_REVOCATION_PowCalculationHandle *ph)
}
-struct GNUNET_REVOCATION_SignaturePurposePS *
-REV_create_signature_message (const struct GNUNET_REVOCATION_PowP *pow)
+struct GNUNET_GNSRECORD_SignaturePurposePS *
+GNR_create_signature_message (const struct GNUNET_GNSRECORD_PowP *pow)
{
- struct GNUNET_REVOCATION_SignaturePurposePS *spurp;
+ struct GNUNET_GNSRECORD_SignaturePurposePS *spurp;
const struct GNUNET_CRYPTO_PublicKey *pk;
size_t ksize;
@@ -416,23 +115,23 @@ REV_create_signature_message (const struct
GNUNET_REVOCATION_PowP *pow)
spurp->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_GNS_REVOCATION);
spurp->purpose.size = htonl (sizeof(*spurp) + ksize);
GNUNET_CRYPTO_write_public_key_to_buffer (pk,
- (char*) &spurp[1],
- ksize);
+ (char*) &spurp[1],
+ ksize);
return spurp;
}
enum GNUNET_GenericReturnValue
-check_signature_identity (const struct GNUNET_REVOCATION_PowP *pow,
+check_signature_identity (const struct GNUNET_GNSRECORD_PowP *pow,
const struct GNUNET_CRYPTO_PublicKey *key)
{
- struct GNUNET_REVOCATION_SignaturePurposePS *spurp;
+ struct GNUNET_GNSRECORD_SignaturePurposePS *spurp;
unsigned char *sig;
size_t ksize;
int ret;
ksize = GNUNET_CRYPTO_public_key_get_length (key);
- spurp = REV_create_signature_message (pow);
+ spurp = GNR_create_signature_message (pow);
sig = ((unsigned char*) &pow[1] + ksize);
ret =
GNUNET_CRYPTO_signature_verify_raw_ (
@@ -446,7 +145,7 @@ check_signature_identity (const struct
GNUNET_REVOCATION_PowP *pow,
enum GNUNET_GenericReturnValue
-check_signature (const struct GNUNET_REVOCATION_PowP *pow)
+check_signature (const struct GNUNET_GNSRECORD_PowP *pow)
{
const struct GNUNET_CRYPTO_PublicKey *pk;
@@ -464,9 +163,9 @@ check_signature (const struct GNUNET_REVOCATION_PowP *pow)
* @return #GNUNET_YES if the @a pow is acceptable, #GNUNET_NO if not
*/
enum GNUNET_GenericReturnValue
-GNUNET_REVOCATION_check_pow (const struct GNUNET_REVOCATION_PowP *pow,
- unsigned int difficulty,
- struct GNUNET_TIME_Relative epoch_duration)
+GNUNET_GNSRECORD_check_pow (const struct GNUNET_GNSRECORD_PowP *pow,
+ unsigned int difficulty,
+ struct GNUNET_TIME_Relative epoch_duration)
{
char buf[sizeof(struct GNUNET_CRYPTO_PublicKey)
+ sizeof (struct GNUNET_TIME_AbsoluteNBO)
@@ -567,10 +266,10 @@ GNUNET_REVOCATION_check_pow (const struct
GNUNET_REVOCATION_PowP *pow,
enum GNUNET_GenericReturnValue
sign_pow_identity (const struct GNUNET_CRYPTO_PrivateKey *key,
- struct GNUNET_REVOCATION_PowP *pow)
+ struct GNUNET_GNSRECORD_PowP *pow)
{
struct GNUNET_TIME_Absolute ts = GNUNET_TIME_absolute_get ();
- struct GNUNET_REVOCATION_SignaturePurposePS *rp;
+ struct GNUNET_GNSRECORD_SignaturePurposePS *rp;
const struct GNUNET_CRYPTO_PublicKey *pk;
size_t ksize;
char *sig;
@@ -584,11 +283,11 @@ sign_pow_identity (const struct GNUNET_CRYPTO_PrivateKey
*key,
pk = (const struct GNUNET_CRYPTO_PublicKey *) &pow[1];
ksize = GNUNET_CRYPTO_public_key_get_length (pk);
pow->timestamp = GNUNET_TIME_absolute_hton (ts);
- rp = REV_create_signature_message (pow);
+ rp = GNR_create_signature_message (pow);
sig = ((char*) &pow[1]) + ksize;
int result = GNUNET_CRYPTO_sign_raw_ (key,
- &rp->purpose,
- (void*) sig);
+ &rp->purpose,
+ (void*) sig);
GNUNET_free (rp);
if (result == GNUNET_SYSERR)
return GNUNET_NO;
@@ -599,7 +298,7 @@ sign_pow_identity (const struct GNUNET_CRYPTO_PrivateKey
*key,
enum GNUNET_GenericReturnValue
sign_pow (const struct GNUNET_CRYPTO_PrivateKey *key,
- struct GNUNET_REVOCATION_PowP *pow)
+ struct GNUNET_GNSRECORD_PowP *pow)
{
struct GNUNET_CRYPTO_PublicKey *pk;
@@ -616,23 +315,23 @@ sign_pow (const struct GNUNET_CRYPTO_PrivateKey *key,
* @param[out] pow starting point for PoW calculation (not yet valid)
*/
void
-GNUNET_REVOCATION_pow_init (const struct GNUNET_CRYPTO_PrivateKey *key,
- struct GNUNET_REVOCATION_PowP *pow)
+GNUNET_GNSRECORD_pow_init (const struct GNUNET_CRYPTO_PrivateKey *key,
+ struct GNUNET_GNSRECORD_PowP *pow)
{
GNUNET_assert (GNUNET_OK == sign_pow (key, pow));
}
-struct GNUNET_REVOCATION_PowCalculationHandle*
-GNUNET_REVOCATION_pow_start (struct GNUNET_REVOCATION_PowP *pow,
- int epochs,
- unsigned int difficulty)
+struct GNUNET_GNSRECORD_PowCalculationHandle*
+GNUNET_GNSRECORD_pow_start (struct GNUNET_GNSRECORD_PowP *pow,
+ int epochs,
+ unsigned int difficulty)
{
- struct GNUNET_REVOCATION_PowCalculationHandle *pc;
+ struct GNUNET_GNSRECORD_PowCalculationHandle *pc;
struct GNUNET_TIME_Relative ttl;
- pc = GNUNET_new (struct GNUNET_REVOCATION_PowCalculationHandle);
+ pc = GNUNET_new (struct GNUNET_GNSRECORD_PowCalculationHandle);
pc->pow = pow;
ttl = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_YEARS,
epochs);
@@ -670,7 +369,7 @@ cmp_pow_value (const void *a, const void *b)
* @return #GNUNET_YES if the @a pow is acceptable, #GNUNET_NO if not
*/
enum GNUNET_GenericReturnValue
-GNUNET_REVOCATION_pow_round (struct GNUNET_REVOCATION_PowCalculationHandle *pc)
+GNUNET_GNSRECORD_pow_round (struct GNUNET_GNSRECORD_PowCalculationHandle *pc)
{
char buf[sizeof(struct GNUNET_CRYPTO_PublicKey)
+ sizeof (uint64_t)
@@ -731,28 +430,14 @@ GNUNET_REVOCATION_pow_round (struct
GNUNET_REVOCATION_PowCalculationHandle *pc)
}
-/**
- * Stop a PoW calculation
- *
- * @param pc the calculation to clean up
- * @return #GNUNET_YES if pow valid, #GNUNET_NO if pow was set but is not
- * valid
- */
-void
-GNUNET_REVOCATION_pow_stop (struct GNUNET_REVOCATION_PowCalculationHandle *pc)
-{
- GNUNET_free (pc);
-}
-
-
size_t
-GNUNET_REVOCATION_proof_get_size (const struct GNUNET_REVOCATION_PowP *pow)
+GNUNET_GNSRECORD_proof_get_size (const struct GNUNET_GNSRECORD_PowP *pow)
{
size_t size;
size_t ksize;
const struct GNUNET_CRYPTO_PublicKey *pk;
- size = sizeof (struct GNUNET_REVOCATION_PowP);
+ size = sizeof (struct GNUNET_GNSRECORD_PowP);
pk = (const struct GNUNET_CRYPTO_PublicKey *) &pow[1];
ksize = GNUNET_CRYPTO_public_key_get_length (pk);
size += ksize;
@@ -761,4 +446,17 @@ GNUNET_REVOCATION_proof_get_size (const struct
GNUNET_REVOCATION_PowP *pow)
}
-/* end of revocation_api.c */
+/**
+ * Stop a PoW calculation
+ *
+ * @param pc the calculation to clean up
+ * @return #GNUNET_YES if pow valid, #GNUNET_NO if pow was set but is not
+ * valid
+ */
+void
+GNUNET_GNSRECORD_pow_stop (struct GNUNET_GNSRECORD_PowCalculationHandle *pc)
+{
+ GNUNET_free (pc);
+}
+
+
diff --git a/src/lib/gnsrecord/meson.build b/src/lib/gnsrecord/meson.build
index 3e35e0caf..a35d6b66e 100644
--- a/src/lib/gnsrecord/meson.build
+++ b/src/lib/gnsrecord/meson.build
@@ -1,6 +1,7 @@
libgnunetgnsrecord_src = ['gnsrecord.c',
'gnsrecord_serialization.c',
'gnsrecord_crypto.c',
+ 'gnsrecord_pow.c',
'gnsrecord_misc.c']
libgnunetgnsrecordjson_src = ['json_gnsrecord.c']
diff --git a/src/meson.build b/src/meson.build
index 5efd7e97a..0a2dab664 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -4,8 +4,8 @@ endif
subdir('include')
subdir('lib')
-subdir('service')
subdir('plugin')
+subdir('service')
subdir('rest-plugin')
subdir('cli')
subdir('contrib')
diff --git a/src/plugin/Makefile.am b/src/plugin/Makefile.am
index 1a1ecffa7..c04ecd5a6 100644
--- a/src/plugin/Makefile.am
+++ b/src/plugin/Makefile.am
@@ -1,7 +1,6 @@
SUBDIRS = \
block \
gnsrecord \
- dhtu \
namecache \
namestore \
revocation \
diff --git a/src/plugin/fs/Makefile.am b/src/plugin/fs/Makefile.am
index 928997e4d..7c0e55cba 100644
--- a/src/plugin/fs/Makefile.am
+++ b/src/plugin/fs/Makefile.am
@@ -20,7 +20,6 @@ libgnunet_plugin_block_fs_la_SOURCES = \
libgnunet_plugin_block_fs_la_LIBADD = \
$(top_builddir)/src/lib/block/libgnunetblockgroup.la \
$(top_builddir)/src/lib/block/libgnunetblock.la \
- $(top_builddir)/src/service/fs/libgnunetfs.la \
$(top_builddir)/src/lib/util/libgnunetutil.la \
$(LTLIBINTL)
libgnunet_plugin_block_fs_la_LDFLAGS = \
diff --git a/src/plugin/gns/Makefile.am b/src/plugin/gns/Makefile.am
index ebbb9aa51..8dc9ef2b2 100644
--- a/src/plugin/gns/Makefile.am
+++ b/src/plugin/gns/Makefile.am
@@ -34,7 +34,6 @@ libgnunet_plugin_gnsrecord_gns_la_SOURCES = \
plugin_gnsrecord_gns.c
libgnunet_plugin_gnsrecord_gns_la_LIBADD = \
$(top_builddir)/src/lib/gnsrecord/libgnunetgnsrecord.la \
- $(top_builddir)/src/service/identity/libgnunetidentity.la \
$(top_builddir)/src/lib/util/libgnunetutil.la \
$(LTLIBINTL)
libgnunet_plugin_gnsrecord_gns_la_LDFLAGS = \
@@ -47,7 +46,6 @@ libgnunet_plugin_block_gns_la_LIBADD = \
$(top_builddir)/src/lib/util/libgnunetutil.la \
$(top_builddir)/src/lib/block/libgnunetblock.la \
$(top_builddir)/src/lib/block/libgnunetblockgroup.la \
- $(top_builddir)/src/service/identity/libgnunetidentity.la \
$(top_builddir)/src/lib/gnsrecord/libgnunetgnsrecord.la
libgnunet_plugin_block_gns_la_LDFLAGS = \
$(GN_LIBINTL) \
diff --git a/src/plugin/gns/meson.build b/src/plugin/gns/meson.build
index 0e551b22e..2cdf770f8 100644
--- a/src/plugin/gns/meson.build
+++ b/src/plugin/gns/meson.build
@@ -2,7 +2,7 @@ shared_module('gnunet_plugin_gnsrecord_gns',
['plugin_gnsrecord_gns.c'],
dependencies: [libgnunetutil_dep,
libgnunetgnsrecord_dep,
- libgnunetidentity_dep],
+ ],
include_directories: [incdir, configuration_inc],
install: true,
install_dir: get_option('libdir')/'gnunet')
diff --git a/src/plugin/meson.build b/src/plugin/meson.build
index 6ebae59d7..d0e0806da 100644
--- a/src/plugin/meson.build
+++ b/src/plugin/meson.build
@@ -1,5 +1,4 @@
subdir('block')
-subdir('dhtu')
subdir('gnsrecord')
subdir('namecache')
subdir('namestore')
diff --git a/src/plugin/namecache/Makefile.am b/src/plugin/namecache/Makefile.am
index 0ccbf9ea1..bf8fc9b8d 100644
--- a/src/plugin/namecache/Makefile.am
+++ b/src/plugin/namecache/Makefile.am
@@ -56,10 +56,7 @@ plugin_LTLIBRARIES = \
libgnunet_plugin_namecache_flat_la_SOURCES = \
plugin_namecache_flat.c
libgnunet_plugin_namecache_flat_la_LIBADD = \
- $(top_builddir)/src/service/namecache/libgnunetnamecache.la \
- $(top_builddir)/src/service/statistics/libgnunetstatistics.la \
$(top_builddir)/src/lib/gnsrecord/libgnunetgnsrecord.la \
- $(top_builddir)/src/service/identity/libgnunetidentity.la \
$(top_builddir)/src/lib/util/libgnunetutil.la $(XLIBS) \
$(LTLIBINTL)
libgnunet_plugin_namecache_flat_la_LDFLAGS = \
@@ -68,11 +65,8 @@ libgnunet_plugin_namecache_flat_la_LDFLAGS = \
libgnunet_plugin_namecache_sqlite_la_SOURCES = \
plugin_namecache_sqlite.c
libgnunet_plugin_namecache_sqlite_la_LIBADD = \
- $(top_builddir)/src/service/namecache/libgnunetnamecache.la \
$(top_builddir)/src/lib/sq/libgnunetsq.la \
- $(top_builddir)/src/service/statistics/libgnunetstatistics.la \
$(top_builddir)/src/lib/gnsrecord/libgnunetgnsrecord.la \
- $(top_builddir)/src/service/identity/libgnunetidentity.la \
$(top_builddir)/src/lib/util/libgnunetutil.la $(XLIBS) -lsqlite3 \
$(LTLIBINTL)
libgnunet_plugin_namecache_sqlite_la_LDFLAGS = \
@@ -82,11 +76,8 @@ libgnunet_plugin_namecache_sqlite_la_LDFLAGS = \
libgnunet_plugin_namecache_postgres_la_SOURCES = \
plugin_namecache_postgres.c
libgnunet_plugin_namecache_postgres_la_LIBADD = \
- $(top_builddir)/src/service/namecache/libgnunetnamecache.la \
$(top_builddir)/src/lib/pq/libgnunetpq.la \
- $(top_builddir)/src/service/statistics/libgnunetstatistics.la \
$(top_builddir)/src/lib/gnsrecord/libgnunetgnsrecord.la \
- $(top_builddir)/src/service/identity/libgnunetidentity.la \
$(top_builddir)/src/lib/util/libgnunetutil.la $(XLIBS) -lpq \
$(LTLIBINTL)
libgnunet_plugin_namecache_postgres_la_LDFLAGS = \
diff --git a/src/plugin/namestore/Makefile.am b/src/plugin/namestore/Makefile.am
index e413c1b08..03b743d7a 100644
--- a/src/plugin/namestore/Makefile.am
+++ b/src/plugin/namestore/Makefile.am
@@ -76,37 +76,16 @@ TESTS = \
$(check_SCRIPTS)
endif
-REST_PLUGIN = libgnunet_plugin_rest_namestore.la
-
plugin_LTLIBRARIES = \
$(SQLITE_PLUGIN) \
- $(POSTGRES_PLUGIN) \
- $(REST_PLUGIN)
-
-
-libgnunet_plugin_rest_namestore_la_SOURCES = \
- plugin_rest_namestore.c
-libgnunet_plugin_rest_namestore_la_LIBADD = \
- $(top_builddir)/src/service/namestore/libgnunetnamestore.la \
- $(top_builddir)/src/service/rest/libgnunetrest.la \
- $(top_builddir)/src/service/identity/libgnunetidentity.la \
- $(top_builddir)/src/lib/json/libgnunetjson.la \
- $(top_builddir)/src/lib/gnsrecord/libgnunetgnsrecord.la \
- $(top_builddir)/src/lib/gnsrecord/libgnunetgnsrecordjson.la \
- $(top_builddir)/src/lib/util/libgnunetutil.la $(XLIBS) \
- $(LTLIBINTL) -ljansson $(MHD_LIBS)
-libgnunet_plugin_rest_namestore_la_LDFLAGS = \
- $(GN_PLUGIN_LDFLAGS)
-libgnunet_plugin_rest_namestore_la_CFLAGS = $(MHD_CFLAGS) $(AM_CFLAGS)
+ $(POSTGRES_PLUGIN)
libgnunet_plugin_namestore_sqlite_la_SOURCES = \
plugin_namestore_sqlite.c
libgnunet_plugin_namestore_sqlite_la_LIBADD = \
$(top_builddir)/src/lib/gnsrecord/libgnunetgnsrecord.la \
- $(top_builddir)/src/service/identity/libgnunetidentity.la \
$(top_builddir)/src/lib/sq/libgnunetsq.la \
- $(top_builddir)/src/service/statistics/libgnunetstatistics.la \
$(top_builddir)/src/lib/util/libgnunetutil.la $(XLIBS) -lsqlite3 \
$(LTLIBINTL)
libgnunet_plugin_namestore_sqlite_la_LDFLAGS = \
@@ -116,9 +95,7 @@ libgnunet_plugin_namestore_postgres_la_SOURCES = \
plugin_namestore_postgres.c
libgnunet_plugin_namestore_postgres_la_LIBADD = \
$(top_builddir)/src/lib/gnsrecord/libgnunetgnsrecord.la \
- $(top_builddir)/src/service/identity/libgnunetidentity.la \
$(top_builddir)/src/lib/pq/libgnunetpq.la \
- $(top_builddir)/src/service/statistics/libgnunetstatistics.la \
$(top_builddir)/src/lib/util/libgnunetutil.la $(XLIBS) -lpq \
$(LTLIBINTL)
libgnunet_plugin_namestore_postgres_la_LDFLAGS = \
@@ -422,9 +399,6 @@ test_plugin_namestore_postgres_LDADD = \
$(top_builddir)/src/service/testing/libgnunettesting.la \
$(top_builddir)/src/lib/util/libgnunetutil.la
-check_SCRIPTS = \
- test_plugin_rest_namestore.sh
-
EXTRA_DIST = \
test_common.c \
test_namestore_api.conf \
@@ -434,5 +408,4 @@ EXTRA_DIST = \
perf_namestore_api_sqlite.conf \
test_plugin_namestore_sqlite.conf \
test_plugin_namestore_postgres.conf \
- $(check_SCRIPTS) \
$(sql_DATA)
diff --git a/src/plugin/namestore/meson.build b/src/plugin/namestore/meson.build
index 32db8c104..d51b4b730 100644
--- a/src/plugin/namestore/meson.build
+++ b/src/plugin/namestore/meson.build
@@ -1,26 +1,10 @@
-shared_module('gnunet_plugin_rest_namestore',
- ['plugin_rest_namestore.c'],
- dependencies: [libgnunetrest_dep,
- libgnunetidentity_dep,
- libgnunetgnsrecordjson_dep,
- libgnunetgnsrecord_dep,
- libgnunetnamestore_dep,
- libgnunetjson_dep,
- libgnunetutil_dep,
- json_dep,
- mhd_dep],
- include_directories: [incdir, configuration_inc],
- install: true,
- install_dir: get_option('libdir') / 'gnunet')
-
+libgnunetpluginnamestore_sqlite_src = ['plugin_namestore_sqlite.c']
shared_module('gnunet_plugin_namestore_sqlite',
libgnunetpluginnamestore_sqlite_src,
dependencies: [libgnunetutil_dep,
libgnunetgnsrecord_dep,
- libgnunetidentity_dep,
libgnunetsq_dep,
- libgnunetstatistics_dep,
sqlite_dep],
include_directories: [incdir, configuration_inc],
install: true,
@@ -31,9 +15,7 @@ if pq_dep.found()
['plugin_namestore_postgres.c'],
dependencies: [libgnunetutil_dep,
libgnunetgnsrecord_dep,
- libgnunetidentity_dep,
libgnunetpq_dep,
- libgnunetstatistics_dep,
pq_dep],
include_directories: [incdir, configuration_inc],
install: true,
diff --git a/src/plugin/reclaim/Makefile.am b/src/plugin/reclaim/Makefile.am
index 0b5159c6b..e8ac2f94d 100644
--- a/src/plugin/reclaim/Makefile.am
+++ b/src/plugin/reclaim/Makefile.am
@@ -59,11 +59,11 @@ endif
libgnunet_plugin_reclaim_credential_jwt_la_SOURCES = \
- plugin_reclaim_credential_jwt.c
+ plugin_reclaim_credential_jwt.c \
+ $(top_builddir)/src/service/reclaim/reclaim_attribute.c \
+ $(top_builddir)/src/service/reclaim/reclaim_credential.c
libgnunet_plugin_reclaim_credential_jwt_la_LIBADD = \
- $(top_builddir)/src/service/identity/libgnunetidentity.la \
$(top_builddir)/src/lib/util/libgnunetutil.la \
- $(top_builddir)/src/service/reclaim/libgnunetreclaim.la \
-ljansson\
$(LTLIBINTL)
libgnunet_plugin_reclaim_credential_jwt_la_LDFLAGS = \
diff --git a/src/plugin/reclaim/meson.build b/src/plugin/reclaim/meson.build
index 51346b108..df0289ca2 100644
--- a/src/plugin/reclaim/meson.build
+++ b/src/plugin/reclaim/meson.build
@@ -7,9 +7,7 @@ shared_module('gnunet_plugin_gnsrecord_reclaim',
shared_module('gnunet_plugin_reclaim_attribute_basic',
['plugin_reclaim_attribute_basic.c'],
- dependencies: [libgnunetrest_dep,
- libgnunetidentity_dep,
- libgnunetreclaim_dep,
+ dependencies: [
libgnunetjson_dep,
libgnunetutil_dep,
json_dep],
@@ -18,9 +16,7 @@ shared_module('gnunet_plugin_reclaim_attribute_basic',
install_dir: get_option('libdir') / 'gnunet')
shared_module('gnunet_plugin_reclaim_credential_jwt',
['plugin_reclaim_credential_jwt.c'],
- dependencies: [libgnunetrest_dep,
- libgnunetidentity_dep,
- libgnunetreclaim_dep,
+ dependencies: [
libgnunetjson_dep,
libgnunetutil_dep,
json_dep],
diff --git a/src/plugin/revocation/Makefile.am
b/src/plugin/revocation/Makefile.am
index db6df02c9..99373f8d7 100644
--- a/src/plugin/revocation/Makefile.am
+++ b/src/plugin/revocation/Makefile.am
@@ -18,11 +18,10 @@ plugin_LTLIBRARIES = \
libgnunet_plugin_block_revocation_la_SOURCES = \
plugin_block_revocation.c
libgnunet_plugin_block_revocation_la_LIBADD = \
- $(top_builddir)/src/service/revocation/libgnunetrevocation.la \
+ $(top_builddir)/src/lib/gnsrecord/libgnunetgnsrecord.la \
$(top_builddir)/src/lib/block/libgnunetblockgroup.la \
$(top_builddir)/src/lib/block/libgnunetblock.la \
$(top_builddir)/src/lib/util/libgnunetutil.la \
- $(top_builddir)/src/service/identity/libgnunetidentity.la \
$(LTLIBINTL)
libgnunet_plugin_block_revocation_la_LDFLAGS = \
$(GN_PLUGIN_LDFLAGS)
diff --git a/src/plugin/revocation/meson.build
b/src/plugin/revocation/meson.build
index 7f8c8ec5e..c4405e9b8 100644
--- a/src/plugin/revocation/meson.build
+++ b/src/plugin/revocation/meson.build
@@ -1,8 +1,6 @@
shared_module('gnunet_plugin_block_revocation',
['plugin_block_revocation.c'],
dependencies: [libgnunetutil_dep,
- libgnunetidentity_dep,
- libgnunetrevocation_dep,
libgnunetblock_dep],
include_directories: [incdir, configuration_inc],
install: true,
diff --git a/src/plugin/revocation/plugin_block_revocation.c
b/src/plugin/revocation/plugin_block_revocation.c
index 4c5991507..c4332184e 100644
--- a/src/plugin/revocation/plugin_block_revocation.c
+++ b/src/plugin/revocation/plugin_block_revocation.c
@@ -27,8 +27,8 @@
#include "platform.h"
#include "gnunet_signatures.h"
#include "gnunet_block_plugin.h"
+#include "gnunet_gnsrecord_lib.h"
#include "gnunet_block_group_lib.h"
-// FIXME try to avoid this include somehow
#include "../../service/revocation/revocation.h"
#include "gnunet_revocation_service.h"
@@ -93,8 +93,8 @@ block_plugin_revocation_check_block (void *cls,
{
struct InternalContext *ic = cls;
const struct RevokeMessage *rm = block;
- const struct GNUNET_REVOCATION_PowP *pow
- = (const struct GNUNET_REVOCATION_PowP *) &rm[1];
+ const struct GNUNET_GNSRECORD_PowP *pow
+ = (const struct GNUNET_GNSRECORD_PowP *) &rm[1];
struct GNUNET_CRYPTO_PublicKey pk;
size_t pklen;
size_t left;
@@ -117,9 +117,9 @@ block_plugin_revocation_check_block (void *cls,
left = block_size - sizeof (*rm) - sizeof (*pow);
if (GNUNET_SYSERR ==
GNUNET_CRYPTO_read_public_key_from_buffer (&pow[1],
- left,
- &pk,
- &pklen))
+ left,
+ &pk,
+ &pklen))
{
GNUNET_break_op (0);
return GNUNET_NO;
@@ -130,9 +130,9 @@ block_plugin_revocation_check_block (void *cls,
return GNUNET_NO;
}
if (GNUNET_YES !=
- GNUNET_REVOCATION_check_pow (pow,
- ic->matching_bits,
- ic->epoch_duration))
+ GNUNET_GNSRECORD_check_pow (pow,
+ ic->matching_bits,
+ ic->epoch_duration))
{
GNUNET_break_op (0);
return GNUNET_NO;
@@ -203,8 +203,8 @@ block_plugin_revocation_get_key (void *cls,
struct GNUNET_HashCode *key)
{
const struct RevokeMessage *rm = block;
- const struct GNUNET_REVOCATION_PowP *pow
- = (const struct GNUNET_REVOCATION_PowP *) &rm[1];
+ const struct GNUNET_GNSRECORD_PowP *pow
+ = (const struct GNUNET_GNSRECORD_PowP *) &rm[1];
struct GNUNET_CRYPTO_PublicKey pk;
size_t pklen;
size_t left;
@@ -226,9 +226,9 @@ block_plugin_revocation_get_key (void *cls,
}
left = block_size - sizeof (*rm) - sizeof (*pow);
if (GNUNET_SYSERR == GNUNET_CRYPTO_read_public_key_from_buffer (&pow[1],
- left,
- &pk,
- &pklen))
+ left,
+ &pk,
+ &pklen))
{
GNUNET_break_op (0);
return GNUNET_NO;
diff --git a/src/rest-plugin/Makefile.am b/src/rest-plugin/Makefile.am
index d76972b78..3379cb24e 100644
--- a/src/rest-plugin/Makefile.am
+++ b/src/rest-plugin/Makefile.am
@@ -1,5 +1,6 @@
SUBDIRS = \
rest \
identity \
+ namestore \
gns \
reclaim
diff --git a/src/rest-plugin/meson.build b/src/rest-plugin/meson.build
index 31d49864e..09cd2ad8c 100644
--- a/src/rest-plugin/meson.build
+++ b/src/rest-plugin/meson.build
@@ -2,5 +2,6 @@ if get_option('monolith') == false
subdir('rest')
endif
subdir('identity')
+subdir('namestore')
subdir('gns')
subdir('reclaim')
diff --git a/src/rest-plugin/namestore/Makefile.am
b/src/rest-plugin/namestore/Makefile.am
new file mode 100644
index 000000000..93da51dbc
--- /dev/null
+++ b/src/rest-plugin/namestore/Makefile.am
@@ -0,0 +1,53 @@
+# This Makefile.am is in the public domain
+AM_CPPFLAGS = -I$(top_srcdir)/src/include $(POSTGRESQL_CPPFLAGS)
+
+plugindir = $(libdir)/gnunet
+
+pkgcfgdir= $(pkgdatadir)/config.d/
+
+libexecdir= $(pkglibdir)/libexec/
+
+sqldir = $(prefix)/share/gnunet/sql/
+
+if USE_COVERAGE
+ AM_CFLAGS = --coverage -O0
+ XLIBS = -lgcov
+endif
+
+
+if ENABLE_TEST_RUN
+AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export
PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH;unset XDG_DATA_HOME;unset
XDG_CONFIG_HOME;
+TESTS = \
+ $(check_PROGRAMS) \
+ $(check_SCRIPTS)
+endif
+
+REST_PLUGIN = libgnunet_plugin_rest_namestore.la
+
+plugin_LTLIBRARIES = \
+ $(SQLITE_PLUGIN) \
+ $(POSTGRES_PLUGIN) \
+ $(REST_PLUGIN)
+
+
+libgnunet_plugin_rest_namestore_la_SOURCES = \
+ plugin_rest_namestore.c
+libgnunet_plugin_rest_namestore_la_LIBADD = \
+ $(top_builddir)/src/service/namestore/libgnunetnamestore.la \
+ $(top_builddir)/src/service/rest/libgnunetrest.la \
+ $(top_builddir)/src/service/identity/libgnunetidentity.la \
+ $(top_builddir)/src/lib/json/libgnunetjson.la \
+ $(top_builddir)/src/lib/gnsrecord/libgnunetgnsrecord.la \
+ $(top_builddir)/src/lib/gnsrecord/libgnunetgnsrecordjson.la \
+ $(top_builddir)/src/lib/util/libgnunetutil.la $(XLIBS) \
+ $(LTLIBINTL) -ljansson $(MHD_LIBS)
+libgnunet_plugin_rest_namestore_la_LDFLAGS = \
+ $(GN_PLUGIN_LDFLAGS)
+libgnunet_plugin_rest_namestore_la_CFLAGS = $(MHD_CFLAGS) $(AM_CFLAGS)
+
+
+check_SCRIPTS = \
+ test_plugin_rest_namestore.sh
+
+EXTRA_DIST = \
+ $(check_SCRIPTS)
diff --git a/src/rest-plugin/namestore/meson.build
b/src/rest-plugin/namestore/meson.build
new file mode 100644
index 000000000..f96e7cd44
--- /dev/null
+++ b/src/rest-plugin/namestore/meson.build
@@ -0,0 +1,14 @@
+shared_module('gnunet_plugin_rest_namestore',
+ ['plugin_rest_namestore.c'],
+ dependencies: [
+ libgnunetrest_dep,
+ libgnunetgnsrecordjson_dep,
+ libgnunetgnsrecord_dep,
+ libgnunetjson_dep,
+ libgnunetutil_dep,
+ json_dep,
+ mhd_dep],
+ include_directories: [incdir, configuration_inc],
+ install: true,
+ install_dir: get_option('libdir') / 'gnunet')
+
diff --git a/src/plugin/namestore/plugin_rest_namestore.c
b/src/rest-plugin/namestore/plugin_rest_namestore.c
similarity index 100%
rename from src/plugin/namestore/plugin_rest_namestore.c
rename to src/rest-plugin/namestore/plugin_rest_namestore.c
diff --git a/src/service/Makefile.am b/src/service/Makefile.am
index 8e661e432..809f83a0a 100644
--- a/src/service/Makefile.am
+++ b/src/service/Makefile.am
@@ -16,6 +16,7 @@ SUBDIRS = \
rest \
datacache \
datastore \
+ dhtu \
dht \
namecache \
namestore \
diff --git a/src/plugin/dhtu/.gitignore b/src/service/dhtu/.gitignore
similarity index 100%
rename from src/plugin/dhtu/.gitignore
rename to src/service/dhtu/.gitignore
diff --git a/src/plugin/dhtu/Makefile.am b/src/service/dhtu/Makefile.am
similarity index 100%
rename from src/plugin/dhtu/Makefile.am
rename to src/service/dhtu/Makefile.am
diff --git a/src/plugin/dhtu/dhtu.conf b/src/service/dhtu/dhtu.conf
similarity index 100%
rename from src/plugin/dhtu/dhtu.conf
rename to src/service/dhtu/dhtu.conf
diff --git a/src/plugin/dhtu/meson.build b/src/service/dhtu/meson.build
similarity index 100%
rename from src/plugin/dhtu/meson.build
rename to src/service/dhtu/meson.build
diff --git a/src/plugin/dhtu/plugin_dhtu_gnunet.c
b/src/service/dhtu/plugin_dhtu_gnunet.c
similarity index 100%
rename from src/plugin/dhtu/plugin_dhtu_gnunet.c
rename to src/service/dhtu/plugin_dhtu_gnunet.c
diff --git a/src/plugin/dhtu/plugin_dhtu_ip.c
b/src/service/dhtu/plugin_dhtu_ip.c
similarity index 100%
rename from src/plugin/dhtu/plugin_dhtu_ip.c
rename to src/service/dhtu/plugin_dhtu_ip.c
diff --git a/src/plugin/dhtu/test_dhtu_ip.c b/src/service/dhtu/test_dhtu_ip.c
similarity index 100%
rename from src/plugin/dhtu/test_dhtu_ip.c
rename to src/service/dhtu/test_dhtu_ip.c
diff --git a/src/plugin/dhtu/testing_dhtu_cmd_send.c
b/src/service/dhtu/testing_dhtu_cmd_send.c
similarity index 100%
rename from src/plugin/dhtu/testing_dhtu_cmd_send.c
rename to src/service/dhtu/testing_dhtu_cmd_send.c
diff --git a/src/service/meson.build b/src/service/meson.build
index 6acbc3b10..5923fc8a1 100644
--- a/src/service/meson.build
+++ b/src/service/meson.build
@@ -11,6 +11,7 @@ subdir('nat-auto')
subdir('transport')
subdir('core')
subdir('nse')
+subdir('dhtu')
subdir('dht')
subdir('hostlist')
subdir('regex')
diff --git a/src/service/namestore/meson.build
b/src/service/namestore/meson.build
index 879eaef09..912b312fa 100644
--- a/src/service/namestore/meson.build
+++ b/src/service/namestore/meson.build
@@ -1,7 +1,5 @@
libgnunetnamestore_src = ['namestore_api.c', 'namestore_api_monitor.c']
-libgnunetpluginnamestore_sqlite_src = ['plugin_namestore_sqlite.c']
-gnunetnamestore_src = ['gnunet-namestore.c']
gnunetservicenamestore_src = ['gnunet-service-namestore.c']
configure_file(input : 'namestore.conf.in',
diff --git a/src/service/revocation/Makefile.am
b/src/service/revocation/Makefile.am
index 726c75ab6..0f004bdc0 100644
--- a/src/service/revocation/Makefile.am
+++ b/src/service/revocation/Makefile.am
@@ -29,7 +29,7 @@ libgnunetrevocation_la_SOURCES = \
revocation_api.c revocation.h
libgnunetrevocation_la_LIBADD = \
$(top_builddir)/src/lib/util/libgnunetutil.la \
- $(top_builddir)/src/service/identity/libgnunetidentity.la \
+ $(top_builddir)/src/lib/gnsrecord/libgnunetgnsrecord.la \
$(LIBGCRYPT_LIBS) \
$(GN_LIBINTL) $(XLIB) -lgcrypt
libgnunetrevocation_la_LDFLAGS = \
diff --git a/src/service/revocation/gnunet-service-revocation.c
b/src/service/revocation/gnunet-service-revocation.c
index 3755b87e5..8a8610758 100644
--- a/src/service/revocation/gnunet-service-revocation.c
+++ b/src/service/revocation/gnunet-service-revocation.c
@@ -38,6 +38,7 @@
#include "platform.h"
#include <math.h>
#include "gnunet_util_lib.h"
+#include "gnunet_gnsrecord_lib.h"
#include "gnunet_block_lib.h"
#include "gnunet_constants.h"
#include "gnunet_protocols.h"
@@ -172,13 +173,13 @@ new_peer_entry (const struct GNUNET_PeerIdentity *peer)
static enum GNUNET_GenericReturnValue
verify_revoke_message (const struct RevokeMessage *rm)
{
- const struct GNUNET_REVOCATION_PowP *pow
- = (const struct GNUNET_REVOCATION_PowP *) &rm[1];
+ const struct GNUNET_GNSRECORD_PowP *pow
+ = (const struct GNUNET_GNSRECORD_PowP *) &rm[1];
if (GNUNET_YES !=
- GNUNET_REVOCATION_check_pow (pow,
- (unsigned int) revocation_work_required,
- epoch_duration))
+ GNUNET_GNSRECORD_check_pow (pow,
+ (unsigned int) revocation_work_required,
+ epoch_duration))
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Proof of work invalid!\n");
@@ -221,6 +222,7 @@ client_disconnect_cb (void *cls,
GNUNET_assert (client == app_cls);
}
+
static int
check_query_message (void *cls,
const struct QueryMessage *qm)
@@ -261,7 +263,7 @@ handle_query_message (void *cls,
key_len = ntohl (qm->key_len);
if ((GNUNET_SYSERR ==
GNUNET_CRYPTO_read_public_key_from_buffer (&qm[1], key_len,
- &zone, &read)) ||
+ &zone, &read)) ||
(read != key_len))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -342,8 +344,8 @@ publicize_rm (const struct RevokeMessage *rm)
struct GNUNET_HashCode hc;
struct GNUNET_SETU_Element e;
ssize_t pklen;
- const struct GNUNET_REVOCATION_PowP *pow
- = (const struct GNUNET_REVOCATION_PowP *) &rm[1];
+ const struct GNUNET_GNSRECORD_PowP *pow
+ = (const struct GNUNET_GNSRECORD_PowP *) &rm[1];
const struct GNUNET_CRYPTO_PublicKey *pk
= (const struct GNUNET_CRYPTO_PublicKey *) &pow[1];
@@ -980,8 +982,8 @@ run (void *cls,
GNUNET_free (fn);
return;
}
- struct GNUNET_REVOCATION_PowP *pow = (struct
- GNUNET_REVOCATION_PowP *) &rm[1];
+ struct GNUNET_GNSRECORD_PowP *pow = (struct
+ GNUNET_GNSRECORD_PowP *) &rm[1];
ssize_t ksize;
pk = (const struct GNUNET_CRYPTO_PublicKey *) &pow[1];
ksize = GNUNET_CRYPTO_public_key_get_length (pk);
diff --git a/src/service/revocation/meson.build
b/src/service/revocation/meson.build
index 14e352ffa..57f19f115 100644
--- a/src/service/revocation/meson.build
+++ b/src/service/revocation/meson.build
@@ -19,7 +19,9 @@ libgnunetrevocation = library('gnunetrevocation',
libgnunetrevocation_src,
soversion: '0',
version: '0.0.0',
- dependencies: [libgnunetutil_dep, libgnunetidentity_dep],
+ dependencies: [libgnunetutil_dep,
+ libgnunetgnsrecord_dep,
+ libgnunetidentity_dep],
include_directories: [incdir, configuration_inc],
install: true,
install_dir: get_option('libdir'))
@@ -34,6 +36,7 @@ executable ('gnunet-service-revocation',
libgnunetstatistics_dep,
libgnunetcore_dep,
libgnunetsetu_dep,
+ libgnunetgnsrecord_dep,
libgnunetidentity_dep],
include_directories: [incdir, configuration_inc],
install: true,
diff --git a/src/service/revocation/revocation.h
b/src/service/revocation/revocation.h
index 90b8c7da0..cbb36acfb 100644
--- a/src/service/revocation/revocation.h
+++ b/src/service/revocation/revocation.h
@@ -112,13 +112,4 @@ struct RevocationResponseMessage
GNUNET_NETWORK_STRUCT_END
-/**
- * Create the revocation metadata to sign for a revocation message
- *
- * @param pow the PoW to sign
- * @return the signature purpose
- */
-struct GNUNET_REVOCATION_SignaturePurposePS *
-REV_create_signature_message (const struct GNUNET_REVOCATION_PowP *pow);
-
#endif
diff --git a/src/service/revocation/revocation_api.c
b/src/service/revocation/revocation_api.c
index 3b7d83710..0e3641af8 100644
--- a/src/service/revocation/revocation_api.c
+++ b/src/service/revocation/revocation_api.c
@@ -51,60 +51,6 @@ struct GNUNET_REVOCATION_Query
};
-/**
- * Helper struct that holds a found pow nonce
- * and the corresponding number of leading zeros.
- */
-struct BestPow
-{
- /**
- * PoW nonce
- */
- uint64_t pow;
-
- /**
- * Corresponding zero bits in hash
- */
- unsigned int bits;
-};
-
-
-/**
- * The handle to a PoW calculation.
- * Used in iterative PoW rounds.
- */
-struct GNUNET_REVOCATION_PowCalculationHandle
-{
- /**
- * Current set of found PoWs
- */
- struct BestPow best[POW_COUNT];
-
- /**
- * The final PoW result data structure.
- */
- struct GNUNET_REVOCATION_PowP *pow;
-
- /**
- * The current nonce to try
- */
- uint64_t current_pow;
-
- /**
- * Epochs how long the PoW should be valid.
- * This is added on top of the difficulty in the PoW.
- */
- unsigned int epochs;
-
- /**
- * The difficulty (leading zeros) to achieve.
- */
- unsigned int difficulty;
-
-};
-
-static struct GNUNET_CRYPTO_PowSalt salt = { "GnsRevocationPow" };
-
/**
* Generic error handler, called with the appropriate
* error code and the same closure specified at the creation of
@@ -301,7 +247,7 @@ handle_revocation_response (void *cls,
*/
struct GNUNET_REVOCATION_Handle *
GNUNET_REVOCATION_revoke (const struct GNUNET_CONFIGURATION_Handle *cfg,
- const struct GNUNET_REVOCATION_PowP *pow,
+ const struct GNUNET_GNSRECORD_PowP *pow,
GNUNET_REVOCATION_Callback func,
void *func_cls)
{
@@ -339,9 +285,9 @@ GNUNET_REVOCATION_revoke (const struct
GNUNET_CONFIGURATION_Handle *cfg,
GNUNET_free (h);
return NULL;
}
- if (GNUNET_YES != GNUNET_REVOCATION_check_pow (pow,
- (unsigned int) matching_bits,
- epoch_duration))
+ if (GNUNET_YES != GNUNET_GNSRECORD_check_pow (pow,
+ (unsigned int) matching_bits,
+ epoch_duration))
{
GNUNET_break (0);
GNUNET_free (h);
@@ -361,7 +307,7 @@ GNUNET_REVOCATION_revoke (const struct
GNUNET_CONFIGURATION_Handle *cfg,
}
h->func = func;
h->func_cls = func_cls;
- size_t extra_len = GNUNET_REVOCATION_proof_get_size (pow);
+ size_t extra_len = GNUNET_GNSRECORD_proof_get_size (pow);
env = GNUNET_MQ_msg_extra (rm,
extra_len,
GNUNET_MESSAGE_TYPE_REVOCATION_REVOKE);
@@ -385,380 +331,4 @@ GNUNET_REVOCATION_revoke_cancel (struct
GNUNET_REVOCATION_Handle *h)
}
-/**
- * Calculate the average zeros in the pows.
- *
- * @param ph the PowHandle
- * @return the average number of zeros.
- */
-static unsigned int
-calculate_score (const struct GNUNET_REVOCATION_PowCalculationHandle *ph)
-{
- double sum = 0.0;
- for (unsigned int j = 0; j<POW_COUNT; j++)
- sum += ph->best[j].bits;
- double avg = sum / POW_COUNT;
- return avg;
-}
-
-
-struct GNUNET_REVOCATION_SignaturePurposePS *
-REV_create_signature_message (const struct GNUNET_REVOCATION_PowP *pow)
-{
- struct GNUNET_REVOCATION_SignaturePurposePS *spurp;
- const struct GNUNET_CRYPTO_PublicKey *pk;
- size_t ksize;
-
- pk = (const struct GNUNET_CRYPTO_PublicKey *) &pow[1];
- ksize = GNUNET_CRYPTO_public_key_get_length (pk);
- spurp = GNUNET_malloc (sizeof (*spurp) + ksize);
- spurp->timestamp = pow->timestamp;
- spurp->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_GNS_REVOCATION);
- spurp->purpose.size = htonl (sizeof(*spurp) + ksize);
- GNUNET_CRYPTO_write_public_key_to_buffer (pk,
- (char*) &spurp[1],
- ksize);
- return spurp;
-}
-
-
-enum GNUNET_GenericReturnValue
-check_signature_identity (const struct GNUNET_REVOCATION_PowP *pow,
- const struct GNUNET_CRYPTO_PublicKey *key)
-{
- struct GNUNET_REVOCATION_SignaturePurposePS *spurp;
- unsigned char *sig;
- size_t ksize;
- int ret;
-
- ksize = GNUNET_CRYPTO_public_key_get_length (key);
- spurp = REV_create_signature_message (pow);
- sig = ((unsigned char*) &pow[1] + ksize);
- ret =
- GNUNET_CRYPTO_signature_verify_raw_ (
- GNUNET_SIGNATURE_PURPOSE_GNS_REVOCATION,
- &spurp->purpose,
- sig,
- key);
- GNUNET_free (spurp);
- return ret == GNUNET_OK ? GNUNET_OK : GNUNET_SYSERR;
-}
-
-
-enum GNUNET_GenericReturnValue
-check_signature (const struct GNUNET_REVOCATION_PowP *pow)
-{
- const struct GNUNET_CRYPTO_PublicKey *pk;
-
- pk = (const struct GNUNET_CRYPTO_PublicKey *) &pow[1];
- return check_signature_identity (pow, pk);
-}
-
-
-/**
- * Check if the given proof-of-work is valid.
- *
- * @param pow proof of work
- * @param difficulty how many bits must match (configuration) LSD0001: D
- * @param epoch_duration length of single epoch in configuration
- * @return #GNUNET_YES if the @a pow is acceptable, #GNUNET_NO if not
- */
-enum GNUNET_GenericReturnValue
-GNUNET_REVOCATION_check_pow (const struct GNUNET_REVOCATION_PowP *pow,
- unsigned int difficulty,
- struct GNUNET_TIME_Relative epoch_duration)
-{
- char buf[sizeof(struct GNUNET_CRYPTO_PublicKey)
- + sizeof (struct GNUNET_TIME_AbsoluteNBO)
- + sizeof (uint64_t)] GNUNET_ALIGN;
- struct GNUNET_HashCode result;
- struct GNUNET_TIME_Absolute ts;
- struct GNUNET_TIME_Absolute exp;
- struct GNUNET_TIME_Relative ttl;
- struct GNUNET_TIME_Relative buffer;
- /* LSD0001: D' */
- unsigned int score = 0;
- unsigned int tmp_score = 0;
- unsigned int epochs;
- uint64_t pow_val;
- ssize_t pklen;
- const struct GNUNET_CRYPTO_PublicKey *pk;
-
- pk = (const struct GNUNET_CRYPTO_PublicKey *) &pow[1];
-
- /**
- * Check if signature valid
- */
- if (GNUNET_OK != check_signature (pow))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Proof of work signature invalid!\n");
- return GNUNET_SYSERR;
- }
-
- /**
- * First, check if PoW set is strictly monotically increasing
- */
- for (unsigned int i = 0; i < POW_COUNT - 1; i++)
- {
- if (GNUNET_ntohll (pow->pow[i]) >= GNUNET_ntohll (pow->pow[i + 1]))
- return GNUNET_NO;
- }
- GNUNET_memcpy (&buf[sizeof(uint64_t)],
- &pow->timestamp,
- sizeof (uint64_t));
- pklen = GNUNET_CRYPTO_public_key_get_length (pk);
- if (0 > pklen)
- {
- GNUNET_break (0);
- return GNUNET_NO;
- }
- GNUNET_memcpy (&buf[sizeof(uint64_t) * 2],
- pk,
- pklen);
- for (unsigned int i = 0; i < POW_COUNT; i++)
- {
- pow_val = GNUNET_ntohll (pow->pow[i]);
- GNUNET_memcpy (buf, &pow->pow[i], sizeof(uint64_t));
- GNUNET_CRYPTO_pow_hash (&salt,
- buf,
- sizeof(buf),
- &result);
- tmp_score = GNUNET_CRYPTO_hash_count_leading_zeros (&result);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Score %u with %" PRIu64 " (#%u)\n",
- tmp_score, pow_val, i);
-
- score += tmp_score;
-
- }
- score = score / POW_COUNT;
- if (score < difficulty)
- return GNUNET_NO;
- /* LSD0001: (D'-D+1) */
- epochs = score - difficulty + 1;
-
- /**
- * Check expiration
- */
- ts = GNUNET_TIME_absolute_ntoh (pow->timestamp);
- ttl = GNUNET_TIME_relative_multiply (epoch_duration,
- epochs);
- /**
- * Extend by 10% for unsynchronized clocks
- */
- buffer = GNUNET_TIME_relative_divide (epoch_duration,
- 10);
- exp = GNUNET_TIME_absolute_add (ts, ttl);
- exp = GNUNET_TIME_absolute_add (exp,
- buffer);
-
- if (0 != GNUNET_TIME_absolute_get_remaining (ts).rel_value_us)
- return GNUNET_NO; /* Not yet valid. */
- /* Revert to actual start time */
- ts = GNUNET_TIME_absolute_add (ts,
- buffer);
-
- if (0 == GNUNET_TIME_absolute_get_remaining (exp).rel_value_us)
- return GNUNET_NO; /* expired */
- return GNUNET_YES;
-}
-
-
-enum GNUNET_GenericReturnValue
-sign_pow_identity (const struct GNUNET_CRYPTO_PrivateKey *key,
- struct GNUNET_REVOCATION_PowP *pow)
-{
- struct GNUNET_TIME_Absolute ts = GNUNET_TIME_absolute_get ();
- struct GNUNET_REVOCATION_SignaturePurposePS *rp;
- const struct GNUNET_CRYPTO_PublicKey *pk;
- size_t ksize;
- char *sig;
-
- /**
- * Predate the validity period to prevent rejections due to
- * unsynchronized clocks
- */
- ts = GNUNET_TIME_absolute_subtract (ts,
- GNUNET_TIME_UNIT_WEEKS);
- pk = (const struct GNUNET_CRYPTO_PublicKey *) &pow[1];
- ksize = GNUNET_CRYPTO_public_key_get_length (pk);
- pow->timestamp = GNUNET_TIME_absolute_hton (ts);
- rp = REV_create_signature_message (pow);
- sig = ((char*) &pow[1]) + ksize;
- int result = GNUNET_CRYPTO_sign_raw_ (key,
- &rp->purpose,
- (void*) sig);
- GNUNET_free (rp);
- if (result == GNUNET_SYSERR)
- return GNUNET_NO;
- else
- return result;
-}
-
-
-enum GNUNET_GenericReturnValue
-sign_pow (const struct GNUNET_CRYPTO_PrivateKey *key,
- struct GNUNET_REVOCATION_PowP *pow)
-{
- struct GNUNET_CRYPTO_PublicKey *pk;
-
- pk = (struct GNUNET_CRYPTO_PublicKey *) &pow[1];
- GNUNET_CRYPTO_key_get_public (key, pk);
- return sign_pow_identity (key, pow);
-}
-
-
-/**
- * Initializes a fresh PoW computation.
- *
- * @param key the key to calculate the PoW for.
- * @param[out] pow starting point for PoW calculation (not yet valid)
- */
-void
-GNUNET_REVOCATION_pow_init (const struct GNUNET_CRYPTO_PrivateKey *key,
- struct GNUNET_REVOCATION_PowP *pow)
-{
- GNUNET_assert (GNUNET_OK == sign_pow (key, pow));
-}
-
-
-struct GNUNET_REVOCATION_PowCalculationHandle*
-GNUNET_REVOCATION_pow_start (struct GNUNET_REVOCATION_PowP *pow,
- int epochs,
- unsigned int difficulty)
-{
- struct GNUNET_REVOCATION_PowCalculationHandle *pc;
- struct GNUNET_TIME_Relative ttl;
-
-
- pc = GNUNET_new (struct GNUNET_REVOCATION_PowCalculationHandle);
- pc->pow = pow;
- ttl = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_YEARS,
- epochs);
- pc->pow->ttl = GNUNET_TIME_relative_hton (ttl);
- pc->current_pow = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK,
- UINT64_MAX);
- pc->difficulty = difficulty;
- pc->epochs = epochs;
- return pc;
-}
-
-
-/**
- * Comparison function for quicksort
- *
- * @param a left element
- * @param b right element
- * @return a-b
- */
-static int
-cmp_pow_value (const void *a, const void *b)
-{
- return (GNUNET_ntohll (*(uint64_t*) a) - GNUNET_ntohll (*(uint64_t*) b));
-}
-
-
-/**
- * Calculate a key revocation valid for broadcasting for a number
- * of epochs.
- *
- * @param pc handle to the PoW, initially called with NULL.
- * @param epochs number of epochs for which the revocation must be valid.
- * @param pow current pow value to try
- * @param difficulty current base difficulty to achieve
- * @return #GNUNET_YES if the @a pow is acceptable, #GNUNET_NO if not
- */
-enum GNUNET_GenericReturnValue
-GNUNET_REVOCATION_pow_round (struct GNUNET_REVOCATION_PowCalculationHandle *pc)
-{
- char buf[sizeof(struct GNUNET_CRYPTO_PublicKey)
- + sizeof (uint64_t)
- + sizeof (uint64_t)] GNUNET_ALIGN;
- struct GNUNET_HashCode result;
- const struct GNUNET_CRYPTO_PublicKey *pk;
- unsigned int zeros;
- int ret;
- uint64_t pow_nbo;
- ssize_t ksize;
-
- pc->current_pow++;
- pk = (const struct GNUNET_CRYPTO_PublicKey *) &(pc->pow[1]);
-
- /**
- * Do not try duplicates
- */
- for (unsigned int i = 0; i < POW_COUNT; i++)
- if (pc->current_pow == pc->best[i].pow)
- return GNUNET_NO;
- pow_nbo = GNUNET_htonll (pc->current_pow);
- GNUNET_memcpy (buf, &pow_nbo, sizeof(uint64_t));
- GNUNET_memcpy (&buf[sizeof(uint64_t)],
- &pc->pow->timestamp,
- sizeof (uint64_t));
- ksize = GNUNET_CRYPTO_public_key_get_length (pk);
- GNUNET_assert (0 < ksize);
- GNUNET_memcpy (&buf[sizeof(uint64_t) * 2],
- pk,
- ksize);
- GNUNET_CRYPTO_pow_hash (&salt,
- buf,
- sizeof(buf),
- &result);
- zeros = GNUNET_CRYPTO_hash_count_leading_zeros (&result);
- for (unsigned int i = 0; i < POW_COUNT; i++)
- {
- if (pc->best[i].bits < zeros)
- {
- pc->best[i].bits = zeros;
- pc->best[i].pow = pc->current_pow;
- pc->pow->pow[i] = pow_nbo;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "New best score %u with %" PRIu64 " (#%u)\n",
- zeros, pc->current_pow, i);
-
- break;
- }
- }
- ret = calculate_score (pc) >= pc->difficulty + pc->epochs ? GNUNET_YES :
- GNUNET_NO;
- if (GNUNET_YES == ret)
- {
- /* Sort POWs) */
- qsort (pc->pow->pow, POW_COUNT, sizeof (uint64_t), &cmp_pow_value);
- }
- return ret;
-}
-
-
-/**
- * Stop a PoW calculation
- *
- * @param pc the calculation to clean up
- * @return #GNUNET_YES if pow valid, #GNUNET_NO if pow was set but is not
- * valid
- */
-void
-GNUNET_REVOCATION_pow_stop (struct GNUNET_REVOCATION_PowCalculationHandle *pc)
-{
- GNUNET_free (pc);
-}
-
-
-size_t
-GNUNET_REVOCATION_proof_get_size (const struct GNUNET_REVOCATION_PowP *pow)
-{
- size_t size;
- size_t ksize;
- const struct GNUNET_CRYPTO_PublicKey *pk;
-
- size = sizeof (struct GNUNET_REVOCATION_PowP);
- pk = (const struct GNUNET_CRYPTO_PublicKey *) &pow[1];
- ksize = GNUNET_CRYPTO_public_key_get_length (pk);
- size += ksize;
- size += GNUNET_CRYPTO_signature_get_raw_length_by_type (pk->type);
- return size;
-}
-
-
/* end of revocation_api.c */
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnunet] branch master updated: BUILD: Allow plugins to build before higher-level components,
gnunet <=