[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [gnunet] branch master updated: implement revocation block
From: |
gnunet |
Subject: |
[GNUnet-SVN] [gnunet] branch master updated: implement revocation block plugin, get revocation test to pass again |
Date: |
Mon, 27 Feb 2017 15:28:02 +0100 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository gnunet.
The following commit(s) were added to refs/heads/master by this push:
new 830137e31 implement revocation block plugin, get revocation test to
pass again
830137e31 is described below
commit 830137e312e8e565c9113a20411aa3073fbd1cbd
Author: Christian Grothoff <address@hidden>
AuthorDate: Mon Feb 27 15:28:00 2017 +0100
implement revocation block plugin, get revocation test to pass again
---
src/block/block.c | 2 +-
src/block/plugin_block_template.c | 4 +-
src/consensus/plugin_block_consensus.c | 2 +-
src/dht/plugin_block_dht.c | 2 +-
src/fs/plugin_block_fs.c | 2 +-
src/gns/plugin_block_gns.c | 2 +-
src/include/gnunet_block_lib.h | 5 +
src/include/gnunet_plugin_lib.h | 2 +-
src/regex/plugin_block_regex.c | 2 +-
src/revocation/Makefile.am | 17 ++-
src/revocation/gnunet-service-revocation.c | 16 ++-
.../plugin_block_revocation.c} | 143 +++++++++++++++------
src/set/plugin_block_set_test.c | 2 +-
13 files changed, 145 insertions(+), 56 deletions(-)
diff --git a/src/block/block.c b/src/block/block.c
index d6e61acf6..4b6f3826d 100644
--- a/src/block/block.c
+++ b/src/block/block.c
@@ -136,7 +136,7 @@ GNUNET_BLOCK_context_create (const struct
GNUNET_CONFIGURATION_Handle *cfg)
ctx = GNUNET_new (struct GNUNET_BLOCK_Context);
ctx->cfg = cfg;
GNUNET_PLUGIN_load_all ("libgnunet_plugin_block_",
- NULL,
+ (void *) cfg,
&add_plugin,
ctx);
return ctx;
diff --git a/src/block/plugin_block_template.c
b/src/block/plugin_block_template.c
index 2edca17ec..0105fac38 100644
--- a/src/block/plugin_block_template.c
+++ b/src/block/plugin_block_template.c
@@ -157,6 +157,8 @@ block_plugin_template_get_key (void *cls,
/**
* Entry point for the plugin.
+ *
+ * @param cls a `const struct GNUNET_CONFIGURATION_Handle`
*/
void *
libgnunet_plugin_block_template_init (void *cls)
@@ -183,7 +185,7 @@ libgnunet_plugin_block_template_init (void *cls)
void *
libgnunet_plugin_block_template_done (void *cls)
{
- struct GNUNET_TRANSPORT_PluginFunctions *api = cls;
+ struct GNUNET_BLOCK_PluginFunctions *api = cls;
GNUNET_free (api);
return NULL;
diff --git a/src/consensus/plugin_block_consensus.c
b/src/consensus/plugin_block_consensus.c
index 0cb64867e..de0f0886f 100644
--- a/src/consensus/plugin_block_consensus.c
+++ b/src/consensus/plugin_block_consensus.c
@@ -128,7 +128,7 @@ libgnunet_plugin_block_consensus_init (void *cls)
void *
libgnunet_plugin_block_consensus_done (void *cls)
{
- struct GNUNET_TRANSPORT_PluginFunctions *api = cls;
+ struct GNUNET_BLOCK_PluginFunctions *api = cls;
GNUNET_free (api);
return NULL;
diff --git a/src/dht/plugin_block_dht.c b/src/dht/plugin_block_dht.c
index 96349ae9d..24f8b21b2 100644
--- a/src/dht/plugin_block_dht.c
+++ b/src/dht/plugin_block_dht.c
@@ -237,7 +237,7 @@ libgnunet_plugin_block_dht_init (void *cls)
void *
libgnunet_plugin_block_dht_done (void *cls)
{
- struct GNUNET_TRANSPORT_PluginFunctions *api = cls;
+ struct GNUNET_BLOCK_PluginFunctions *api = cls;
GNUNET_free (api);
return NULL;
diff --git a/src/fs/plugin_block_fs.c b/src/fs/plugin_block_fs.c
index c5e63c9e2..902519f15 100644
--- a/src/fs/plugin_block_fs.c
+++ b/src/fs/plugin_block_fs.c
@@ -276,7 +276,7 @@ libgnunet_plugin_block_fs_init (void *cls)
void *
libgnunet_plugin_block_fs_done (void *cls)
{
- struct GNUNET_TRANSPORT_PluginFunctions *api = cls;
+ struct GNUNET_BLOCK_PluginFunctions *api = cls;
GNUNET_free (api);
return NULL;
diff --git a/src/gns/plugin_block_gns.c b/src/gns/plugin_block_gns.c
index 558ded6f4..a42fef953 100644
--- a/src/gns/plugin_block_gns.c
+++ b/src/gns/plugin_block_gns.c
@@ -238,7 +238,7 @@ libgnunet_plugin_block_gns_init (void *cls)
void *
libgnunet_plugin_block_gns_done (void *cls)
{
- struct GNUNET_TRANSPORT_PluginFunctions *api = cls;
+ struct GNUNET_BLOCK_PluginFunctions *api = cls;
GNUNET_free (api);
return NULL;
diff --git a/src/include/gnunet_block_lib.h b/src/include/gnunet_block_lib.h
index 3e36f11f0..d8ee68c21 100644
--- a/src/include/gnunet_block_lib.h
+++ b/src/include/gnunet_block_lib.h
@@ -112,6 +112,11 @@ enum GNUNET_BLOCK_Type
GNUNET_BLOCK_TYPE_GNS_NAMERECORD = 11,
/**
+ * Block type for a revocation message by which a key is revoked.
+ */
+ GNUNET_BLOCK_TYPE_REVOCATION = 12,
+
+ /**
* Block to store a cadet regex state
*/
GNUNET_BLOCK_TYPE_REGEX = 22,
diff --git a/src/include/gnunet_plugin_lib.h b/src/include/gnunet_plugin_lib.h
index b76b9f9cf..9e3e72a21 100644
--- a/src/include/gnunet_plugin_lib.h
+++ b/src/include/gnunet_plugin_lib.h
@@ -87,7 +87,7 @@ GNUNET_PLUGIN_load (const char *library_name,
/**
- * Signature of a function called by 'GNUNET_PLUGIN_load_all'.
+ * Signature of a function called by #GNUNET_PLUGIN_load_all().
*
* @param cls closure
* @param library_name full name of the library (to be used with
diff --git a/src/regex/plugin_block_regex.c b/src/regex/plugin_block_regex.c
index 0b3ef703e..287ecf905 100644
--- a/src/regex/plugin_block_regex.c
+++ b/src/regex/plugin_block_regex.c
@@ -395,7 +395,7 @@ libgnunet_plugin_block_regex_init (void *cls)
void *
libgnunet_plugin_block_regex_done (void *cls)
{
- struct GNUNET_TRANSPORT_PluginFunctions *api = cls;
+ struct GNUNET_BLOCK_PluginFunctions *api = cls;
GNUNET_free (api);
return NULL;
diff --git a/src/revocation/Makefile.am b/src/revocation/Makefile.am
index 541c7120d..82755b485 100644
--- a/src/revocation/Makefile.am
+++ b/src/revocation/Makefile.am
@@ -1,6 +1,8 @@
# This Makefile.am is in the public domain
AM_CPPFLAGS = -I$(top_srcdir)/src/include
+plugindir = $(libdir)/gnunet
+
if MINGW
WINFLAGS = -Wl,--no-undefined -Wl,--export-all-symbols
endif
@@ -21,6 +23,20 @@ bin_PROGRAMS = \
gnunet-revocation
+plugin_LTLIBRARIES = \
+ libgnunet_plugin_block_revocation.la
+
+libgnunet_plugin_block_revocation_la_SOURCES = \
+ plugin_block_revocation.c
+libgnunet_plugin_block_revocation_la_LIBADD = \
+ libgnunetrevocation.la \
+ $(top_builddir)/src/block/libgnunetblockgroup.la \
+ $(top_builddir)/src/util/libgnunetutil.la \
+ $(LTLIBINTL)
+libgnunet_plugin_block_revocation_la_LDFLAGS = \
+ $(GN_PLUGIN_LDFLAGS)
+
+
gnunet_revocation_SOURCES = \
gnunet-revocation.c
gnunet_revocation_LDADD = \
@@ -86,4 +102,3 @@ test_local_revocation.py: test_local_revocation.py.in
Makefile
EXTRA_DIST = test_revocation.conf \
test_local_revocation.py.in
-
diff --git a/src/revocation/gnunet-service-revocation.c
b/src/revocation/gnunet-service-revocation.c
index 99bec1fc8..9d077f874 100644
--- a/src/revocation/gnunet-service-revocation.c
+++ b/src/revocation/gnunet-service-revocation.c
@@ -38,6 +38,7 @@
#include "platform.h"
#include <math.h>
#include "gnunet_util_lib.h"
+#include "gnunet_block_lib.h"
#include "gnunet_constants.h"
#include "gnunet_protocols.h"
#include "gnunet_signatures.h"
@@ -215,7 +216,7 @@ client_connect_cb (void *cls,
* @param client the new client
* @param app_cls must alias @a client
*/
-static void
+static void
client_disconnect_cb (void *cls,
struct GNUNET_SERVICE_Client *client,
void *app_cls)
@@ -352,7 +353,7 @@ publicize_rm (const struct RevokeMessage *rm)
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
/* add to set for future connections */
e.size = htons (rm->header.size);
- e.element_type = 0;
+ e.element_type = GNUNET_BLOCK_TYPE_REVOCATION;
e.data = rm;
if (GNUNET_OK !=
GNUNET_SET_add_element (revocation_set,
@@ -452,11 +453,12 @@ add_revocation (void *cls,
GNUNET_break_op (0);
return;
}
- if (0 != element->element_type)
+ if (GNUNET_BLOCK_TYPE_REVOCATION != element->element_type)
{
GNUNET_STATISTICS_update (stats,
gettext_noop ("# unsupported revocations
received via set union"),
- 1, GNUNET_NO);
+ 1,
+ GNUNET_NO);
return;
}
rm = element->data;
@@ -604,12 +606,12 @@ handle_core_disconnect (void *cls,
void *internal_cls)
{
struct PeerEntry *peer_entry = internal_cls;
-
+
if (0 == memcmp (peer,
&my_identity,
sizeof (my_identity)))
return;
- GNUNET_assert (NULL != peer_entry);
+ GNUNET_assert (NULL != peer_entry);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Peer `%s' disconnected from us\n",
GNUNET_i2s (peer));
@@ -783,7 +785,7 @@ handle_revocation_union_request (void *cls,
static void
run (void *cls,
const struct GNUNET_CONFIGURATION_Handle *c,
- struct GNUNET_SERVICE_Handle *service)
+ struct GNUNET_SERVICE_Handle *service)
{
struct GNUNET_MQ_MessageHandler core_handlers[] = {
GNUNET_MQ_hd_fixed_size (p2p_revoke,
diff --git a/src/block/plugin_block_template.c
b/src/revocation/plugin_block_revocation.c
similarity index 52%
copy from src/block/plugin_block_template.c
copy to src/revocation/plugin_block_revocation.c
index 2edca17ec..eb0766b81 100644
--- a/src/block/plugin_block_template.c
+++ b/src/revocation/plugin_block_revocation.c
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet
- Copyright (C) 2010 GNUnet e.V.
+ Copyright (C) 2017 GNUnet e.V.
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
@@ -19,16 +19,19 @@
*/
/**
- * @file block/plugin_block_template.c
- * @brief template for a block plugin
+ * @file block/plugin_block_revocation.c
+ * @brief revocation for a block plugin
* @author Christian Grothoff
*/
#include "platform.h"
+#include "gnunet_signatures.h"
#include "gnunet_block_plugin.h"
#include "gnunet_block_group_lib.h"
+#include "revocation.h"
+#include "gnunet_revocation_service.h"
-#define DEBUG_TEMPLATE GNUNET_EXTRA_LOGGING
+#define DEBUG_REVOCATION GNUNET_EXTRA_LOGGING
/**
* Number of bits we set per entry in the bloomfilter.
@@ -40,7 +43,18 @@
/**
* How big is the BF we use for DHT blocks?
*/
-#define TEMPLATE_BF_SIZE 8
+#define REVOCATION_BF_SIZE 8
+
+
+/**
+ * Context used inside the plugin.
+ */
+struct InternalContext
+{
+
+ unsigned int matching_bits;
+
+};
/**
@@ -56,12 +70,12 @@
* by this @a type of block (this is not an error)
*/
static struct GNUNET_BLOCK_Group *
-block_plugin_template_create_group (void *cls,
- enum GNUNET_BLOCK_Type type,
- uint32_t nonce,
- const void *raw_data,
- size_t raw_data_size,
- va_list va)
+block_plugin_revocation_create_group (void *cls,
+ enum GNUNET_BLOCK_Type type,
+ uint32_t nonce,
+ const void *raw_data,
+ size_t raw_data_size,
+ va_list va)
{
unsigned int bf_size;
const char *guard;
@@ -77,7 +91,7 @@ block_plugin_template_create_group (void *cls,
else
{
GNUNET_break (0);
- bf_size = TEMPLATE_BF_SIZE;
+ bf_size = REVOCATION_BF_SIZE;
}
GNUNET_break (NULL == va_arg (va, const char *));
return GNUNET_BLOCK_GROUP_bf_create (cls,
@@ -94,7 +108,7 @@ block_plugin_template_create_group (void *cls,
* Function called to validate a reply or a request. For
* request evaluation, simply pass "NULL" for the reply_block.
*
- * @param cls closure
+ * @param cls our `struct InternalContext`
* @param ctx context
* @param type block type
* @param group block group to use
@@ -107,23 +121,47 @@ block_plugin_template_create_group (void *cls,
* @return characterization of result
*/
static enum GNUNET_BLOCK_EvaluationResult
-block_plugin_template_evaluate (void *cls,
- struct GNUNET_BLOCK_Context *ctx,
- enum GNUNET_BLOCK_Type type,
- struct GNUNET_BLOCK_Group *group,
- enum GNUNET_BLOCK_EvaluationOptions eo,
- const struct GNUNET_HashCode *query,
- const void *xquery,
- size_t xquery_size,
- const void *reply_block,
- size_t reply_block_size)
+block_plugin_revocation_evaluate (void *cls,
+ struct GNUNET_BLOCK_Context *ctx,
+ enum GNUNET_BLOCK_Type type,
+ struct GNUNET_BLOCK_Group *group,
+ enum GNUNET_BLOCK_EvaluationOptions eo,
+ const struct GNUNET_HashCode *query,
+ const void *xquery,
+ size_t xquery_size,
+ const void *reply_block,
+ size_t reply_block_size)
{
+ struct InternalContext *ic = cls;
struct GNUNET_HashCode chash;
+ const struct RevokeMessage *rm = reply_block;
if (NULL == reply_block)
return GNUNET_BLOCK_EVALUATION_REQUEST_VALID;
- GNUNET_CRYPTO_hash (reply_block,
- reply_block_size,
+ if (reply_block_size != sizeof (*rm))
+ {
+ GNUNET_break_op (0);
+ return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
+ }
+ if (GNUNET_YES !=
+ GNUNET_REVOCATION_check_pow (&rm->public_key,
+ rm->proof_of_work,
+ ic->matching_bits))
+ {
+ GNUNET_break_op (0);
+ return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
+ }
+ if (GNUNET_OK !=
+ GNUNET_CRYPTO_ecdsa_verify (GNUNET_SIGNATURE_PURPOSE_REVOCATION,
+ &rm->purpose,
+ &rm->signature,
+ &rm->public_key))
+ {
+ GNUNET_break_op (0);
+ return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
+ }
+ GNUNET_CRYPTO_hash (&rm->public_key,
+ sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey),
&chash);
if (GNUNET_YES ==
GNUNET_BLOCK_GROUP_bf_test_and_set (group,
@@ -145,34 +183,59 @@ block_plugin_template_evaluate (void *cls,
* (or if extracting a key from a block of this type does not work)
*/
static int
-block_plugin_template_get_key (void *cls,
- enum GNUNET_BLOCK_Type type,
- const void *block,
- size_t block_size,
- struct GNUNET_HashCode *key)
+block_plugin_revocation_get_key (void *cls,
+ enum GNUNET_BLOCK_Type type,
+ const void *block,
+ size_t block_size,
+ struct GNUNET_HashCode *key)
{
- return GNUNET_SYSERR;
+ const struct RevokeMessage *rm = block;
+
+ if (block_size != sizeof (*rm))
+ {
+ GNUNET_break_op (0);
+ return GNUNET_SYSERR;
+ }
+ GNUNET_CRYPTO_hash (&rm->public_key,
+ sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey),
+ key);
+ return GNUNET_OK;
}
/**
* Entry point for the plugin.
+ *
+ * @param cls the configuration to use
*/
void *
-libgnunet_plugin_block_template_init (void *cls)
+libgnunet_plugin_block_revocation_init (void *cls)
{
static enum GNUNET_BLOCK_Type types[] =
{
- /* FIXME: insert supported block types here */
+ GNUNET_BLOCK_TYPE_REVOCATION,
GNUNET_BLOCK_TYPE_ANY /* end of list */
};
+ const struct GNUNET_CONFIGURATION_Handle *cfg = cls;
struct GNUNET_BLOCK_PluginFunctions *api;
+ struct InternalContext *ic;
+ unsigned long long matching_bits;
+
+ if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_number (cfg,
+ "REVOCATION",
+ "WORKBITS",
+ &matching_bits))
+ return NULL;
api = GNUNET_new (struct GNUNET_BLOCK_PluginFunctions);
- api->evaluate = &block_plugin_template_evaluate;
- api->get_key = &block_plugin_template_get_key;
- api->create_group = &block_plugin_template_create_group;
+ api->evaluate = &block_plugin_revocation_evaluate;
+ api->get_key = &block_plugin_revocation_get_key;
+ api->create_group = &block_plugin_revocation_create_group;
api->types = types;
+ ic = GNUNET_new (struct InternalContext);
+ ic->matching_bits = (unsigned int) matching_bits;
+ api->cls = ic;
return api;
}
@@ -181,12 +244,14 @@ libgnunet_plugin_block_template_init (void *cls)
* Exit point from the plugin.
*/
void *
-libgnunet_plugin_block_template_done (void *cls)
+libgnunet_plugin_block_revocation_done (void *cls)
{
- struct GNUNET_TRANSPORT_PluginFunctions *api = cls;
+ struct GNUNET_BLOCK_PluginFunctions *api = cls;
+ struct InternalContext *ic = api->cls;
+ GNUNET_free (ic);
GNUNET_free (api);
return NULL;
}
-/* end of plugin_block_template.c */
+/* end of plugin_block_revocation.c */
diff --git a/src/set/plugin_block_set_test.c b/src/set/plugin_block_set_test.c
index c4f73abe0..01b0c8602 100644
--- a/src/set/plugin_block_set_test.c
+++ b/src/set/plugin_block_set_test.c
@@ -114,7 +114,7 @@ libgnunet_plugin_block_set_test_init (void *cls)
void *
libgnunet_plugin_block_set_test_done (void *cls)
{
- struct GNUNET_TRANSPORT_PluginFunctions *api = cls;
+ struct GNUNET_BLOCK_PluginFunctions *api = cls;
GNUNET_free (api);
return NULL;
--
To stop receiving notification emails like this one, please contact
address@hidden
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] [gnunet] branch master updated: implement revocation block plugin, get revocation test to pass again,
gnunet <=