diff options
Diffstat (limited to 'src/revocation/plugin_block_revocation.c')
-rw-r--r-- | src/revocation/plugin_block_revocation.c | 74 |
1 files changed, 12 insertions, 62 deletions
diff --git a/src/revocation/plugin_block_revocation.c b/src/revocation/plugin_block_revocation.c index 3beae60bb..12ec555e4 100644 --- a/src/revocation/plugin_block_revocation.c +++ b/src/revocation/plugin_block_revocation.c | |||
@@ -44,65 +44,6 @@ struct InternalContext | |||
44 | 44 | ||
45 | 45 | ||
46 | /** | 46 | /** |
47 | * Function called to validate a reply or a request. For | ||
48 | * request evaluation, simply pass "NULL" for the reply_block. | ||
49 | * | ||
50 | * @param cls our `struct InternalContext` | ||
51 | * @param ctx context | ||
52 | * @param type block type | ||
53 | * @param group block group to use | ||
54 | * @param eo control flags | ||
55 | * @param query original query (hash) | ||
56 | * @param xquery extrended query data (can be NULL, depending on type) | ||
57 | * @param xquery_size number of bytes in xquery | ||
58 | * @param reply_block response to validate | ||
59 | * @param reply_block_size number of bytes in reply block | ||
60 | * @return characterization of result | ||
61 | */ | ||
62 | static enum GNUNET_BLOCK_EvaluationResult | ||
63 | block_plugin_revocation_evaluate (void *cls, | ||
64 | struct GNUNET_BLOCK_Context *ctx, | ||
65 | enum GNUNET_BLOCK_Type type, | ||
66 | struct GNUNET_BLOCK_Group *group, | ||
67 | enum GNUNET_BLOCK_EvaluationOptions eo, | ||
68 | const struct GNUNET_HashCode *query, | ||
69 | const void *xquery, | ||
70 | size_t xquery_size, | ||
71 | const void *reply_block, | ||
72 | size_t reply_block_size) | ||
73 | { | ||
74 | struct InternalContext *ic = cls; | ||
75 | ssize_t pklen; | ||
76 | const struct RevokeMessage *rm = reply_block; | ||
77 | |||
78 | if (NULL == reply_block) | ||
79 | return GNUNET_BLOCK_EVALUATION_REQUEST_VALID; | ||
80 | if (reply_block_size != sizeof(*rm)) | ||
81 | { | ||
82 | GNUNET_break_op (0); | ||
83 | return GNUNET_BLOCK_EVALUATION_RESULT_INVALID; | ||
84 | } | ||
85 | struct GNUNET_REVOCATION_PowP *pow = (struct GNUNET_REVOCATION_PowP *) &rm[1]; | ||
86 | const struct GNUNET_IDENTITY_PublicKey *pk; | ||
87 | pk = (const struct GNUNET_IDENTITY_PublicKey *) &pow[1]; | ||
88 | if (GNUNET_YES != GNUNET_REVOCATION_check_pow (pow, | ||
89 | ic->matching_bits, | ||
90 | ic->epoch_duration)) | ||
91 | { | ||
92 | GNUNET_break_op (0); | ||
93 | return GNUNET_BLOCK_EVALUATION_RESULT_INVALID; | ||
94 | } | ||
95 | pklen = GNUNET_IDENTITY_key_get_length (pk); | ||
96 | if (0 > pklen) | ||
97 | { | ||
98 | GNUNET_break_op (0); | ||
99 | return GNUNET_BLOCK_EVALUATION_RESULT_INVALID; | ||
100 | } | ||
101 | return GNUNET_BLOCK_EVALUATION_OK_LAST; | ||
102 | } | ||
103 | |||
104 | |||
105 | /** | ||
106 | * Function called to validate a query. | 47 | * Function called to validate a query. |
107 | * | 48 | * |
108 | * @param cls closure | 49 | * @param cls closure |
@@ -124,7 +65,10 @@ block_plugin_revocation_check_query (void *cls, | |||
124 | (void) query; | 65 | (void) query; |
125 | (void) xquery; | 66 | (void) xquery; |
126 | if (GNUNET_BLOCK_TYPE_REVOCATION != type) | 67 | if (GNUNET_BLOCK_TYPE_REVOCATION != type) |
68 | { | ||
69 | GNUNET_break (0); | ||
127 | return GNUNET_SYSERR; | 70 | return GNUNET_SYSERR; |
71 | } | ||
128 | if (0 != xquery_size) | 72 | if (0 != xquery_size) |
129 | return GNUNET_NO; | 73 | return GNUNET_NO; |
130 | return GNUNET_OK; | 74 | return GNUNET_OK; |
@@ -136,7 +80,6 @@ block_plugin_revocation_check_query (void *cls, | |||
136 | * | 80 | * |
137 | * @param cls closure | 81 | * @param cls closure |
138 | * @param type block type | 82 | * @param type block type |
139 | * @param query key for the block (hash), must match exactly | ||
140 | * @param block block data to validate | 83 | * @param block block data to validate |
141 | * @param block_size number of bytes in @a block | 84 | * @param block_size number of bytes in @a block |
142 | * @return #GNUNET_OK if the block is fine, #GNUNET_NO if not | 85 | * @return #GNUNET_OK if the block is fine, #GNUNET_NO if not |
@@ -144,7 +87,6 @@ block_plugin_revocation_check_query (void *cls, | |||
144 | static enum GNUNET_GenericReturnValue | 87 | static enum GNUNET_GenericReturnValue |
145 | block_plugin_revocation_check_block (void *cls, | 88 | block_plugin_revocation_check_block (void *cls, |
146 | enum GNUNET_BLOCK_Type type, | 89 | enum GNUNET_BLOCK_Type type, |
147 | const struct GNUNET_HashCode *query, | ||
148 | const void *block, | 90 | const void *block, |
149 | size_t block_size) | 91 | size_t block_size) |
150 | { | 92 | { |
@@ -157,7 +99,10 @@ block_plugin_revocation_check_block (void *cls, | |||
157 | size_t left; | 99 | size_t left; |
158 | 100 | ||
159 | if (GNUNET_BLOCK_TYPE_REVOCATION != type) | 101 | if (GNUNET_BLOCK_TYPE_REVOCATION != type) |
102 | { | ||
103 | GNUNET_break (0); | ||
160 | return GNUNET_SYSERR; | 104 | return GNUNET_SYSERR; |
105 | } | ||
161 | if (block_size < sizeof(*rm) + sizeof(*pow)) | 106 | if (block_size < sizeof(*rm) + sizeof(*pow)) |
162 | { | 107 | { |
163 | GNUNET_break_op (0); | 108 | GNUNET_break_op (0); |
@@ -224,7 +169,10 @@ block_plugin_revocation_check_reply ( | |||
224 | (void) reply_block; | 169 | (void) reply_block; |
225 | (void) reply_block_size; | 170 | (void) reply_block_size; |
226 | if (GNUNET_BLOCK_TYPE_REVOCATION != type) | 171 | if (GNUNET_BLOCK_TYPE_REVOCATION != type) |
172 | { | ||
173 | GNUNET_break (0); | ||
227 | return GNUNET_BLOCK_REPLY_TYPE_NOT_SUPPORTED; | 174 | return GNUNET_BLOCK_REPLY_TYPE_NOT_SUPPORTED; |
175 | } | ||
228 | return GNUNET_BLOCK_REPLY_OK_LAST; | 176 | return GNUNET_BLOCK_REPLY_OK_LAST; |
229 | } | 177 | } |
230 | 178 | ||
@@ -255,7 +203,10 @@ block_plugin_revocation_get_key (void *cls, | |||
255 | size_t left; | 203 | size_t left; |
256 | 204 | ||
257 | if (GNUNET_BLOCK_TYPE_REVOCATION != type) | 205 | if (GNUNET_BLOCK_TYPE_REVOCATION != type) |
206 | { | ||
207 | GNUNET_break (0); | ||
258 | return GNUNET_SYSERR; | 208 | return GNUNET_SYSERR; |
209 | } | ||
259 | if (block_size < sizeof(*rm) + sizeof(*pow)) | 210 | if (block_size < sizeof(*rm) + sizeof(*pow)) |
260 | { | 211 | { |
261 | GNUNET_break_op (0); | 212 | GNUNET_break_op (0); |
@@ -314,7 +265,6 @@ libgnunet_plugin_block_revocation_init (void *cls) | |||
314 | return NULL; | 265 | return NULL; |
315 | 266 | ||
316 | api = GNUNET_new (struct GNUNET_BLOCK_PluginFunctions); | 267 | api = GNUNET_new (struct GNUNET_BLOCK_PluginFunctions); |
317 | api->evaluate = &block_plugin_revocation_evaluate; | ||
318 | api->get_key = &block_plugin_revocation_get_key; | 268 | api->get_key = &block_plugin_revocation_get_key; |
319 | api->check_query = &block_plugin_revocation_check_query; | 269 | api->check_query = &block_plugin_revocation_check_query; |
320 | api->check_block = &block_plugin_revocation_check_block; | 270 | api->check_block = &block_plugin_revocation_check_block; |