diff options
author | Christian Grothoff <christian@grothoff.org> | 2017-02-27 15:28:00 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2017-02-27 15:28:00 +0100 |
commit | 830137e312e8e565c9113a20411aa3073fbd1cbd (patch) | |
tree | c5c85eb38dc28a353c087ce2058e4cd5c11534ea /src | |
parent | ee3327de8fd04b2b8ce8692560c9f1d01a822baa (diff) | |
download | gnunet-830137e312e8e565c9113a20411aa3073fbd1cbd.tar.gz gnunet-830137e312e8e565c9113a20411aa3073fbd1cbd.zip |
implement revocation block plugin, get revocation test to pass again
Diffstat (limited to 'src')
-rw-r--r-- | src/block/block.c | 2 | ||||
-rw-r--r-- | src/block/plugin_block_template.c | 4 | ||||
-rw-r--r-- | src/consensus/plugin_block_consensus.c | 2 | ||||
-rw-r--r-- | src/dht/plugin_block_dht.c | 2 | ||||
-rw-r--r-- | src/fs/plugin_block_fs.c | 2 | ||||
-rw-r--r-- | src/gns/plugin_block_gns.c | 2 | ||||
-rw-r--r-- | src/include/gnunet_block_lib.h | 5 | ||||
-rw-r--r-- | src/include/gnunet_plugin_lib.h | 2 | ||||
-rw-r--r-- | src/regex/plugin_block_regex.c | 2 | ||||
-rw-r--r-- | src/revocation/Makefile.am | 17 | ||||
-rw-r--r-- | src/revocation/gnunet-service-revocation.c | 16 | ||||
-rw-r--r-- | src/revocation/plugin_block_revocation.c | 257 | ||||
-rw-r--r-- | src/set/plugin_block_set_test.c | 2 |
13 files changed, 298 insertions, 17 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) | |||
136 | ctx = GNUNET_new (struct GNUNET_BLOCK_Context); | 136 | ctx = GNUNET_new (struct GNUNET_BLOCK_Context); |
137 | ctx->cfg = cfg; | 137 | ctx->cfg = cfg; |
138 | GNUNET_PLUGIN_load_all ("libgnunet_plugin_block_", | 138 | GNUNET_PLUGIN_load_all ("libgnunet_plugin_block_", |
139 | NULL, | 139 | (void *) cfg, |
140 | &add_plugin, | 140 | &add_plugin, |
141 | ctx); | 141 | ctx); |
142 | return ctx; | 142 | 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, | |||
157 | 157 | ||
158 | /** | 158 | /** |
159 | * Entry point for the plugin. | 159 | * Entry point for the plugin. |
160 | * | ||
161 | * @param cls a `const struct GNUNET_CONFIGURATION_Handle` | ||
160 | */ | 162 | */ |
161 | void * | 163 | void * |
162 | libgnunet_plugin_block_template_init (void *cls) | 164 | libgnunet_plugin_block_template_init (void *cls) |
@@ -183,7 +185,7 @@ libgnunet_plugin_block_template_init (void *cls) | |||
183 | void * | 185 | void * |
184 | libgnunet_plugin_block_template_done (void *cls) | 186 | libgnunet_plugin_block_template_done (void *cls) |
185 | { | 187 | { |
186 | struct GNUNET_TRANSPORT_PluginFunctions *api = cls; | 188 | struct GNUNET_BLOCK_PluginFunctions *api = cls; |
187 | 189 | ||
188 | GNUNET_free (api); | 190 | GNUNET_free (api); |
189 | return NULL; | 191 | 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) | |||
128 | void * | 128 | void * |
129 | libgnunet_plugin_block_consensus_done (void *cls) | 129 | libgnunet_plugin_block_consensus_done (void *cls) |
130 | { | 130 | { |
131 | struct GNUNET_TRANSPORT_PluginFunctions *api = cls; | 131 | struct GNUNET_BLOCK_PluginFunctions *api = cls; |
132 | 132 | ||
133 | GNUNET_free (api); | 133 | GNUNET_free (api); |
134 | return NULL; | 134 | 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) | |||
237 | void * | 237 | void * |
238 | libgnunet_plugin_block_dht_done (void *cls) | 238 | libgnunet_plugin_block_dht_done (void *cls) |
239 | { | 239 | { |
240 | struct GNUNET_TRANSPORT_PluginFunctions *api = cls; | 240 | struct GNUNET_BLOCK_PluginFunctions *api = cls; |
241 | 241 | ||
242 | GNUNET_free (api); | 242 | GNUNET_free (api); |
243 | return NULL; | 243 | 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) | |||
276 | void * | 276 | void * |
277 | libgnunet_plugin_block_fs_done (void *cls) | 277 | libgnunet_plugin_block_fs_done (void *cls) |
278 | { | 278 | { |
279 | struct GNUNET_TRANSPORT_PluginFunctions *api = cls; | 279 | struct GNUNET_BLOCK_PluginFunctions *api = cls; |
280 | 280 | ||
281 | GNUNET_free (api); | 281 | GNUNET_free (api); |
282 | return NULL; | 282 | 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) | |||
238 | void * | 238 | void * |
239 | libgnunet_plugin_block_gns_done (void *cls) | 239 | libgnunet_plugin_block_gns_done (void *cls) |
240 | { | 240 | { |
241 | struct GNUNET_TRANSPORT_PluginFunctions *api = cls; | 241 | struct GNUNET_BLOCK_PluginFunctions *api = cls; |
242 | 242 | ||
243 | GNUNET_free (api); | 243 | GNUNET_free (api); |
244 | return NULL; | 244 | 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 | |||
112 | GNUNET_BLOCK_TYPE_GNS_NAMERECORD = 11, | 112 | GNUNET_BLOCK_TYPE_GNS_NAMERECORD = 11, |
113 | 113 | ||
114 | /** | 114 | /** |
115 | * Block type for a revocation message by which a key is revoked. | ||
116 | */ | ||
117 | GNUNET_BLOCK_TYPE_REVOCATION = 12, | ||
118 | |||
119 | /** | ||
115 | * Block to store a cadet regex state | 120 | * Block to store a cadet regex state |
116 | */ | 121 | */ |
117 | GNUNET_BLOCK_TYPE_REGEX = 22, | 122 | 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, | |||
87 | 87 | ||
88 | 88 | ||
89 | /** | 89 | /** |
90 | * Signature of a function called by 'GNUNET_PLUGIN_load_all'. | 90 | * Signature of a function called by #GNUNET_PLUGIN_load_all(). |
91 | * | 91 | * |
92 | * @param cls closure | 92 | * @param cls closure |
93 | * @param library_name full name of the library (to be used with | 93 | * @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) | |||
395 | void * | 395 | void * |
396 | libgnunet_plugin_block_regex_done (void *cls) | 396 | libgnunet_plugin_block_regex_done (void *cls) |
397 | { | 397 | { |
398 | struct GNUNET_TRANSPORT_PluginFunctions *api = cls; | 398 | struct GNUNET_BLOCK_PluginFunctions *api = cls; |
399 | 399 | ||
400 | GNUNET_free (api); | 400 | GNUNET_free (api); |
401 | return NULL; | 401 | 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 @@ | |||
1 | # This Makefile.am is in the public domain | 1 | # This Makefile.am is in the public domain |
2 | AM_CPPFLAGS = -I$(top_srcdir)/src/include | 2 | AM_CPPFLAGS = -I$(top_srcdir)/src/include |
3 | 3 | ||
4 | plugindir = $(libdir)/gnunet | ||
5 | |||
4 | if MINGW | 6 | if MINGW |
5 | WINFLAGS = -Wl,--no-undefined -Wl,--export-all-symbols | 7 | WINFLAGS = -Wl,--no-undefined -Wl,--export-all-symbols |
6 | endif | 8 | endif |
@@ -21,6 +23,20 @@ bin_PROGRAMS = \ | |||
21 | gnunet-revocation | 23 | gnunet-revocation |
22 | 24 | ||
23 | 25 | ||
26 | plugin_LTLIBRARIES = \ | ||
27 | libgnunet_plugin_block_revocation.la | ||
28 | |||
29 | libgnunet_plugin_block_revocation_la_SOURCES = \ | ||
30 | plugin_block_revocation.c | ||
31 | libgnunet_plugin_block_revocation_la_LIBADD = \ | ||
32 | libgnunetrevocation.la \ | ||
33 | $(top_builddir)/src/block/libgnunetblockgroup.la \ | ||
34 | $(top_builddir)/src/util/libgnunetutil.la \ | ||
35 | $(LTLIBINTL) | ||
36 | libgnunet_plugin_block_revocation_la_LDFLAGS = \ | ||
37 | $(GN_PLUGIN_LDFLAGS) | ||
38 | |||
39 | |||
24 | gnunet_revocation_SOURCES = \ | 40 | gnunet_revocation_SOURCES = \ |
25 | gnunet-revocation.c | 41 | gnunet-revocation.c |
26 | gnunet_revocation_LDADD = \ | 42 | gnunet_revocation_LDADD = \ |
@@ -86,4 +102,3 @@ test_local_revocation.py: test_local_revocation.py.in Makefile | |||
86 | 102 | ||
87 | EXTRA_DIST = test_revocation.conf \ | 103 | EXTRA_DIST = test_revocation.conf \ |
88 | test_local_revocation.py.in | 104 | test_local_revocation.py.in |
89 | |||
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 @@ | |||
38 | #include "platform.h" | 38 | #include "platform.h" |
39 | #include <math.h> | 39 | #include <math.h> |
40 | #include "gnunet_util_lib.h" | 40 | #include "gnunet_util_lib.h" |
41 | #include "gnunet_block_lib.h" | ||
41 | #include "gnunet_constants.h" | 42 | #include "gnunet_constants.h" |
42 | #include "gnunet_protocols.h" | 43 | #include "gnunet_protocols.h" |
43 | #include "gnunet_signatures.h" | 44 | #include "gnunet_signatures.h" |
@@ -215,7 +216,7 @@ client_connect_cb (void *cls, | |||
215 | * @param client the new client | 216 | * @param client the new client |
216 | * @param app_cls must alias @a client | 217 | * @param app_cls must alias @a client |
217 | */ | 218 | */ |
218 | static void | 219 | static void |
219 | client_disconnect_cb (void *cls, | 220 | client_disconnect_cb (void *cls, |
220 | struct GNUNET_SERVICE_Client *client, | 221 | struct GNUNET_SERVICE_Client *client, |
221 | void *app_cls) | 222 | void *app_cls) |
@@ -352,7 +353,7 @@ publicize_rm (const struct RevokeMessage *rm) | |||
352 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | 353 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); |
353 | /* add to set for future connections */ | 354 | /* add to set for future connections */ |
354 | e.size = htons (rm->header.size); | 355 | e.size = htons (rm->header.size); |
355 | e.element_type = 0; | 356 | e.element_type = GNUNET_BLOCK_TYPE_REVOCATION; |
356 | e.data = rm; | 357 | e.data = rm; |
357 | if (GNUNET_OK != | 358 | if (GNUNET_OK != |
358 | GNUNET_SET_add_element (revocation_set, | 359 | GNUNET_SET_add_element (revocation_set, |
@@ -452,11 +453,12 @@ add_revocation (void *cls, | |||
452 | GNUNET_break_op (0); | 453 | GNUNET_break_op (0); |
453 | return; | 454 | return; |
454 | } | 455 | } |
455 | if (0 != element->element_type) | 456 | if (GNUNET_BLOCK_TYPE_REVOCATION != element->element_type) |
456 | { | 457 | { |
457 | GNUNET_STATISTICS_update (stats, | 458 | GNUNET_STATISTICS_update (stats, |
458 | gettext_noop ("# unsupported revocations received via set union"), | 459 | gettext_noop ("# unsupported revocations received via set union"), |
459 | 1, GNUNET_NO); | 460 | 1, |
461 | GNUNET_NO); | ||
460 | return; | 462 | return; |
461 | } | 463 | } |
462 | rm = element->data; | 464 | rm = element->data; |
@@ -604,12 +606,12 @@ handle_core_disconnect (void *cls, | |||
604 | void *internal_cls) | 606 | void *internal_cls) |
605 | { | 607 | { |
606 | struct PeerEntry *peer_entry = internal_cls; | 608 | struct PeerEntry *peer_entry = internal_cls; |
607 | 609 | ||
608 | if (0 == memcmp (peer, | 610 | if (0 == memcmp (peer, |
609 | &my_identity, | 611 | &my_identity, |
610 | sizeof (my_identity))) | 612 | sizeof (my_identity))) |
611 | return; | 613 | return; |
612 | GNUNET_assert (NULL != peer_entry); | 614 | GNUNET_assert (NULL != peer_entry); |
613 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 615 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
614 | "Peer `%s' disconnected from us\n", | 616 | "Peer `%s' disconnected from us\n", |
615 | GNUNET_i2s (peer)); | 617 | GNUNET_i2s (peer)); |
@@ -783,7 +785,7 @@ handle_revocation_union_request (void *cls, | |||
783 | static void | 785 | static void |
784 | run (void *cls, | 786 | run (void *cls, |
785 | const struct GNUNET_CONFIGURATION_Handle *c, | 787 | const struct GNUNET_CONFIGURATION_Handle *c, |
786 | struct GNUNET_SERVICE_Handle *service) | 788 | struct GNUNET_SERVICE_Handle *service) |
787 | { | 789 | { |
788 | struct GNUNET_MQ_MessageHandler core_handlers[] = { | 790 | struct GNUNET_MQ_MessageHandler core_handlers[] = { |
789 | GNUNET_MQ_hd_fixed_size (p2p_revoke, | 791 | GNUNET_MQ_hd_fixed_size (p2p_revoke, |
diff --git a/src/revocation/plugin_block_revocation.c b/src/revocation/plugin_block_revocation.c new file mode 100644 index 000000000..eb0766b81 --- /dev/null +++ b/src/revocation/plugin_block_revocation.c | |||
@@ -0,0 +1,257 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2017 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published | ||
7 | by the Free Software Foundation; either version 3, or (at your | ||
8 | option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with GNUnet; see the file COPYING. If not, write to the | ||
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301, USA. | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file block/plugin_block_revocation.c | ||
23 | * @brief revocation for a block plugin | ||
24 | * @author Christian Grothoff | ||
25 | */ | ||
26 | |||
27 | #include "platform.h" | ||
28 | #include "gnunet_signatures.h" | ||
29 | #include "gnunet_block_plugin.h" | ||
30 | #include "gnunet_block_group_lib.h" | ||
31 | #include "revocation.h" | ||
32 | #include "gnunet_revocation_service.h" | ||
33 | |||
34 | #define DEBUG_REVOCATION GNUNET_EXTRA_LOGGING | ||
35 | |||
36 | /** | ||
37 | * Number of bits we set per entry in the bloomfilter. | ||
38 | * Do not change! | ||
39 | */ | ||
40 | #define BLOOMFILTER_K 16 | ||
41 | |||
42 | |||
43 | /** | ||
44 | * How big is the BF we use for DHT blocks? | ||
45 | */ | ||
46 | #define REVOCATION_BF_SIZE 8 | ||
47 | |||
48 | |||
49 | /** | ||
50 | * Context used inside the plugin. | ||
51 | */ | ||
52 | struct InternalContext | ||
53 | { | ||
54 | |||
55 | unsigned int matching_bits; | ||
56 | |||
57 | }; | ||
58 | |||
59 | |||
60 | /** | ||
61 | * Create a new block group. | ||
62 | * | ||
63 | * @param ctx block context in which the block group is created | ||
64 | * @param type type of the block for which we are creating the group | ||
65 | * @param nonce random value used to seed the group creation | ||
66 | * @param raw_data optional serialized prior state of the group, NULL if unavailable/fresh | ||
67 | * @param raw_data_size number of bytes in @a raw_data, 0 if unavailable/fresh | ||
68 | * @param va variable arguments specific to @a type | ||
69 | * @return block group handle, NULL if block groups are not supported | ||
70 | * by this @a type of block (this is not an error) | ||
71 | */ | ||
72 | static struct GNUNET_BLOCK_Group * | ||
73 | block_plugin_revocation_create_group (void *cls, | ||
74 | enum GNUNET_BLOCK_Type type, | ||
75 | uint32_t nonce, | ||
76 | const void *raw_data, | ||
77 | size_t raw_data_size, | ||
78 | va_list va) | ||
79 | { | ||
80 | unsigned int bf_size; | ||
81 | const char *guard; | ||
82 | |||
83 | guard = va_arg (va, const char *); | ||
84 | if (0 == strcmp (guard, | ||
85 | "seen-set-size")) | ||
86 | bf_size = GNUNET_BLOCK_GROUP_compute_bloomfilter_size (va_arg (va, unsigned int), | ||
87 | BLOOMFILTER_K); | ||
88 | else if (0 == strcmp (guard, | ||
89 | "filter-size")) | ||
90 | bf_size = va_arg (va, unsigned int); | ||
91 | else | ||
92 | { | ||
93 | GNUNET_break (0); | ||
94 | bf_size = REVOCATION_BF_SIZE; | ||
95 | } | ||
96 | GNUNET_break (NULL == va_arg (va, const char *)); | ||
97 | return GNUNET_BLOCK_GROUP_bf_create (cls, | ||
98 | bf_size, | ||
99 | BLOOMFILTER_K, | ||
100 | type, | ||
101 | nonce, | ||
102 | raw_data, | ||
103 | raw_data_size); | ||
104 | } | ||
105 | |||
106 | |||
107 | /** | ||
108 | * Function called to validate a reply or a request. For | ||
109 | * request evaluation, simply pass "NULL" for the reply_block. | ||
110 | * | ||
111 | * @param cls our `struct InternalContext` | ||
112 | * @param ctx context | ||
113 | * @param type block type | ||
114 | * @param group block group to use | ||
115 | * @param eo control flags | ||
116 | * @param query original query (hash) | ||
117 | * @param xquery extrended query data (can be NULL, depending on type) | ||
118 | * @param xquery_size number of bytes in xquery | ||
119 | * @param reply_block response to validate | ||
120 | * @param reply_block_size number of bytes in reply block | ||
121 | * @return characterization of result | ||
122 | */ | ||
123 | static enum GNUNET_BLOCK_EvaluationResult | ||
124 | block_plugin_revocation_evaluate (void *cls, | ||
125 | struct GNUNET_BLOCK_Context *ctx, | ||
126 | enum GNUNET_BLOCK_Type type, | ||
127 | struct GNUNET_BLOCK_Group *group, | ||
128 | enum GNUNET_BLOCK_EvaluationOptions eo, | ||
129 | const struct GNUNET_HashCode *query, | ||
130 | const void *xquery, | ||
131 | size_t xquery_size, | ||
132 | const void *reply_block, | ||
133 | size_t reply_block_size) | ||
134 | { | ||
135 | struct InternalContext *ic = cls; | ||
136 | struct GNUNET_HashCode chash; | ||
137 | const struct RevokeMessage *rm = reply_block; | ||
138 | |||
139 | if (NULL == reply_block) | ||
140 | return GNUNET_BLOCK_EVALUATION_REQUEST_VALID; | ||
141 | if (reply_block_size != sizeof (*rm)) | ||
142 | { | ||
143 | GNUNET_break_op (0); | ||
144 | return GNUNET_BLOCK_EVALUATION_RESULT_INVALID; | ||
145 | } | ||
146 | if (GNUNET_YES != | ||
147 | GNUNET_REVOCATION_check_pow (&rm->public_key, | ||
148 | rm->proof_of_work, | ||
149 | ic->matching_bits)) | ||
150 | { | ||
151 | GNUNET_break_op (0); | ||
152 | return GNUNET_BLOCK_EVALUATION_RESULT_INVALID; | ||
153 | } | ||
154 | if (GNUNET_OK != | ||
155 | GNUNET_CRYPTO_ecdsa_verify (GNUNET_SIGNATURE_PURPOSE_REVOCATION, | ||
156 | &rm->purpose, | ||
157 | &rm->signature, | ||
158 | &rm->public_key)) | ||
159 | { | ||
160 | GNUNET_break_op (0); | ||
161 | return GNUNET_BLOCK_EVALUATION_RESULT_INVALID; | ||
162 | } | ||
163 | GNUNET_CRYPTO_hash (&rm->public_key, | ||
164 | sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey), | ||
165 | &chash); | ||
166 | if (GNUNET_YES == | ||
167 | GNUNET_BLOCK_GROUP_bf_test_and_set (group, | ||
168 | &chash)) | ||
169 | return GNUNET_BLOCK_EVALUATION_OK_DUPLICATE; | ||
170 | return GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED; | ||
171 | } | ||
172 | |||
173 | |||
174 | /** | ||
175 | * Function called to obtain the key for a block. | ||
176 | * | ||
177 | * @param cls closure | ||
178 | * @param type block type | ||
179 | * @param block block to get the key for | ||
180 | * @param block_size number of bytes in block | ||
181 | * @param key set to the key (query) for the given block | ||
182 | * @return #GNUNET_OK on success, #GNUNET_SYSERR if type not supported | ||
183 | * (or if extracting a key from a block of this type does not work) | ||
184 | */ | ||
185 | static int | ||
186 | block_plugin_revocation_get_key (void *cls, | ||
187 | enum GNUNET_BLOCK_Type type, | ||
188 | const void *block, | ||
189 | size_t block_size, | ||
190 | struct GNUNET_HashCode *key) | ||
191 | { | ||
192 | const struct RevokeMessage *rm = block; | ||
193 | |||
194 | if (block_size != sizeof (*rm)) | ||
195 | { | ||
196 | GNUNET_break_op (0); | ||
197 | return GNUNET_SYSERR; | ||
198 | } | ||
199 | GNUNET_CRYPTO_hash (&rm->public_key, | ||
200 | sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey), | ||
201 | key); | ||
202 | return GNUNET_OK; | ||
203 | } | ||
204 | |||
205 | |||
206 | /** | ||
207 | * Entry point for the plugin. | ||
208 | * | ||
209 | * @param cls the configuration to use | ||
210 | */ | ||
211 | void * | ||
212 | libgnunet_plugin_block_revocation_init (void *cls) | ||
213 | { | ||
214 | static enum GNUNET_BLOCK_Type types[] = | ||
215 | { | ||
216 | GNUNET_BLOCK_TYPE_REVOCATION, | ||
217 | GNUNET_BLOCK_TYPE_ANY /* end of list */ | ||
218 | }; | ||
219 | const struct GNUNET_CONFIGURATION_Handle *cfg = cls; | ||
220 | struct GNUNET_BLOCK_PluginFunctions *api; | ||
221 | struct InternalContext *ic; | ||
222 | unsigned long long matching_bits; | ||
223 | |||
224 | if (GNUNET_OK != | ||
225 | GNUNET_CONFIGURATION_get_value_number (cfg, | ||
226 | "REVOCATION", | ||
227 | "WORKBITS", | ||
228 | &matching_bits)) | ||
229 | return NULL; | ||
230 | |||
231 | api = GNUNET_new (struct GNUNET_BLOCK_PluginFunctions); | ||
232 | api->evaluate = &block_plugin_revocation_evaluate; | ||
233 | api->get_key = &block_plugin_revocation_get_key; | ||
234 | api->create_group = &block_plugin_revocation_create_group; | ||
235 | api->types = types; | ||
236 | ic = GNUNET_new (struct InternalContext); | ||
237 | ic->matching_bits = (unsigned int) matching_bits; | ||
238 | api->cls = ic; | ||
239 | return api; | ||
240 | } | ||
241 | |||
242 | |||
243 | /** | ||
244 | * Exit point from the plugin. | ||
245 | */ | ||
246 | void * | ||
247 | libgnunet_plugin_block_revocation_done (void *cls) | ||
248 | { | ||
249 | struct GNUNET_BLOCK_PluginFunctions *api = cls; | ||
250 | struct InternalContext *ic = api->cls; | ||
251 | |||
252 | GNUNET_free (ic); | ||
253 | GNUNET_free (api); | ||
254 | return NULL; | ||
255 | } | ||
256 | |||
257 | /* 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) | |||
114 | void * | 114 | void * |
115 | libgnunet_plugin_block_set_test_done (void *cls) | 115 | libgnunet_plugin_block_set_test_done (void *cls) |
116 | { | 116 | { |
117 | struct GNUNET_TRANSPORT_PluginFunctions *api = cls; | 117 | struct GNUNET_BLOCK_PluginFunctions *api = cls; |
118 | 118 | ||
119 | GNUNET_free (api); | 119 | GNUNET_free (api); |
120 | return NULL; | 120 | return NULL; |