GNUnet 0.21.1
plugin_block_revocation.c File Reference
#include "platform.h"
#include "gnunet_signatures.h"
#include "gnunet_block_plugin.h"
#include "gnunet_gnsrecord_lib.h"
#include "gnunet_block_group_lib.h"
#include "../../service/revocation/revocation.h"
#include "gnunet_revocation_service.h"
Include dependency graph for plugin_block_revocation.c:

Go to the source code of this file.

Data Structures

struct  InternalContext
 Context used inside the plugin. More...
 

Macros

#define DEBUG_REVOCATION   GNUNET_EXTRA_LOGGING
 

Functions

static enum GNUNET_GenericReturnValue block_plugin_revocation_check_query (void *cls, enum GNUNET_BLOCK_Type type, const struct GNUNET_HashCode *query, const void *xquery, size_t xquery_size)
 Function called to validate a query. More...
 
static enum GNUNET_GenericReturnValue block_plugin_revocation_check_block (void *cls, enum GNUNET_BLOCK_Type type, const void *block, size_t block_size)
 Function called to validate a block for storage. More...
 
static enum GNUNET_BLOCK_ReplyEvaluationResult block_plugin_revocation_check_reply (void *cls, enum GNUNET_BLOCK_Type type, struct GNUNET_BLOCK_Group *group, const struct GNUNET_HashCode *query, const void *xquery, size_t xquery_size, const void *reply_block, size_t reply_block_size)
 Function called to validate a reply to a request. More...
 
static enum GNUNET_GenericReturnValue block_plugin_revocation_get_key (void *cls, enum GNUNET_BLOCK_Type type, const void *block, size_t block_size, struct GNUNET_HashCode *key)
 Function called to obtain the key for a block. More...
 
void * libgnunet_plugin_block_revocation_init (void *cls)
 Entry point for the plugin. More...
 
void * libgnunet_plugin_block_revocation_done (void *cls)
 Exit point from the plugin. More...
 

Macro Definition Documentation

◆ DEBUG_REVOCATION

#define DEBUG_REVOCATION   GNUNET_EXTRA_LOGGING

Definition at line 35 of file plugin_block_revocation.c.

Function Documentation

◆ block_plugin_revocation_check_query()

static enum GNUNET_GenericReturnValue block_plugin_revocation_check_query ( void *  cls,
enum GNUNET_BLOCK_Type  type,
const struct GNUNET_HashCode query,
const void *  xquery,
size_t  xquery_size 
)
static

Function called to validate a query.

Parameters
clsclosure
ctxblock context
typeblock type
queryoriginal query (hash)
xqueryextrended query data (can be NULL, depending on type)
xquery_sizenumber of bytes in xquery
Returns
GNUNET_OK if the query is fine, GNUNET_NO if not

Definition at line 59 of file plugin_block_revocation.c.

64{
65 (void) cls;
66 (void) query;
67 (void) xquery;
69 {
70 GNUNET_break (0);
71 return GNUNET_SYSERR;
72 }
73 if (0 != xquery_size)
74 return GNUNET_NO;
75 return GNUNET_OK;
76}
static uint32_t type
Type string converted to DNS type value.
@ GNUNET_OK
@ GNUNET_NO
@ GNUNET_SYSERR
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
@ GNUNET_BLOCK_TYPE_REVOCATION
Block type for a revocation message by which a key is revoked.

References GNUNET_BLOCK_TYPE_REVOCATION, GNUNET_break, GNUNET_NO, GNUNET_OK, GNUNET_SYSERR, and type.

Referenced by libgnunet_plugin_block_revocation_init().

Here is the caller graph for this function:

◆ block_plugin_revocation_check_block()

static enum GNUNET_GenericReturnValue block_plugin_revocation_check_block ( void *  cls,
enum GNUNET_BLOCK_Type  type,
const void *  block,
size_t  block_size 
)
static

Function called to validate a block for storage.

Parameters
clsclosure
typeblock type
blockblock data to validate
block_sizenumber of bytes in block
Returns
GNUNET_OK if the block is fine, GNUNET_NO if not

Definition at line 89 of file plugin_block_revocation.c.

93{
94 struct InternalContext *ic = cls;
95 const struct RevokeMessage *rm = block;
96 const struct GNUNET_GNSRECORD_PowP *pow
97 = (const struct GNUNET_GNSRECORD_PowP *) &rm[1];
99 size_t pklen;
100 size_t left;
101
103 {
104 GNUNET_break (0);
105 return GNUNET_SYSERR;
106 }
107 if (block_size < sizeof(*rm) + sizeof(*pow))
108 {
109 GNUNET_break_op (0);
110 return GNUNET_NO;
111 }
112 if (block_size != sizeof(*rm) + ntohl (rm->pow_size))
113 {
114 GNUNET_break_op (0);
115 return GNUNET_NO;
116 }
117 left = block_size - sizeof (*rm) - sizeof (*pow);
118 if (GNUNET_SYSERR ==
120 left,
121 &pk,
122 &pklen))
123 {
124 GNUNET_break_op (0);
125 return GNUNET_NO;
126 }
127 if (0 == pklen)
128 {
129 GNUNET_break_op (0);
130 return GNUNET_NO;
131 }
132 if (GNUNET_YES !=
134 ic->matching_bits,
135 ic->epoch_duration))
136 {
137 GNUNET_break_op (0);
138 return GNUNET_NO;
139 }
140 return GNUNET_OK;
141}
struct GNUNET_CRYPTO_PrivateKey pk
Private key from command line option, or NULL.
enum GNUNET_GenericReturnValue GNUNET_GNSRECORD_check_pow(const struct GNUNET_GNSRECORD_PowP *pow, unsigned int matching_bits, struct GNUNET_TIME_Relative epoch_duration)
Check if the given proof-of-work is valid.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_read_public_key_from_buffer(const void *buffer, size_t len, struct GNUNET_CRYPTO_PublicKey *key, size_t *read)
Reads a GNUNET_CRYPTO_PublicKey from a compact buffer.
Definition: crypto_pkey.c:103
@ GNUNET_YES
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
An identity key as per LSD0001.
Struct for a proof of work as part of the revocation.
uint64_t pow[32]
The PoWs.
Context used inside the plugin.
struct GNUNET_TIME_Relative epoch_duration
Revoke key.
Definition: revocation.h:80
uint32_t pow_size
Length of PoW with signature.
Definition: revocation.h:89

References InternalContext::epoch_duration, GNUNET_BLOCK_TYPE_REVOCATION, GNUNET_break, GNUNET_break_op, GNUNET_CRYPTO_read_public_key_from_buffer(), GNUNET_GNSRECORD_check_pow(), GNUNET_NO, GNUNET_OK, GNUNET_SYSERR, GNUNET_YES, InternalContext::matching_bits, pk, GNUNET_GNSRECORD_PowP::pow, RevokeMessage::pow_size, and type.

Referenced by libgnunet_plugin_block_revocation_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ block_plugin_revocation_check_reply()

static enum GNUNET_BLOCK_ReplyEvaluationResult block_plugin_revocation_check_reply ( void *  cls,
enum GNUNET_BLOCK_Type  type,
struct GNUNET_BLOCK_Group group,
const struct GNUNET_HashCode query,
const void *  xquery,
size_t  xquery_size,
const void *  reply_block,
size_t  reply_block_size 
)
static

Function called to validate a reply to a request.

Note that it is assumed that the reply has already been matched to the key (and signatures checked) as it would be done with the GetKeyFunction and the BlockEvaluationFunction.

Parameters
clsclosure
typeblock type
groupwhich block group to use for evaluation
queryoriginal query (hash)
xqueryextrended query data (can be NULL, depending on type)
xquery_sizenumber of bytes in xquery
reply_blockresponse to validate
reply_block_sizenumber of bytes in reply_block
Returns
characterization of result

Definition at line 161 of file plugin_block_revocation.c.

170{
171 (void) cls;
172 (void) group;
173 (void) query;
174 (void) xquery;
175 (void) xquery_size;
176 (void) reply_block;
177 (void) reply_block_size;
179 {
180 GNUNET_break (0);
182 }
184}
@ GNUNET_BLOCK_REPLY_OK_LAST
Last possible valid result.
@ GNUNET_BLOCK_REPLY_TYPE_NOT_SUPPORTED
Specified block type not supported by any plugin.

References GNUNET_BLOCK_REPLY_OK_LAST, GNUNET_BLOCK_REPLY_TYPE_NOT_SUPPORTED, GNUNET_BLOCK_TYPE_REVOCATION, GNUNET_break, and type.

Referenced by libgnunet_plugin_block_revocation_init().

Here is the caller graph for this function:

◆ block_plugin_revocation_get_key()

static enum GNUNET_GenericReturnValue block_plugin_revocation_get_key ( void *  cls,
enum GNUNET_BLOCK_Type  type,
const void *  block,
size_t  block_size,
struct GNUNET_HashCode key 
)
static

Function called to obtain the key for a block.

Parameters
clsclosure
typeblock type
blockblock to get the key for
block_sizenumber of bytes in block
keyset to the key (query) for the given block
Returns
GNUNET_OK on success, GNUNET_SYSERR if type not supported (or if extracting a key from a block of this type does not work)

Definition at line 199 of file plugin_block_revocation.c.

204{
205 const struct RevokeMessage *rm = block;
206 const struct GNUNET_GNSRECORD_PowP *pow
207 = (const struct GNUNET_GNSRECORD_PowP *) &rm[1];
209 size_t pklen;
210 size_t left;
211
213 {
214 GNUNET_break (0);
215 return GNUNET_SYSERR;
216 }
217 if (block_size < sizeof(*rm) + sizeof(*pow))
218 {
219 GNUNET_break_op (0);
220 return GNUNET_NO;
221 }
222 if (block_size != sizeof(*rm) + ntohl (rm->pow_size))
223 {
224 GNUNET_break_op (0);
225 return GNUNET_NO;
226 }
227 left = block_size - sizeof (*rm) - sizeof (*pow);
229 left,
230 &pk,
231 &pklen))
232 {
233 GNUNET_break_op (0);
234 return GNUNET_NO;
235 }
236 if (0 == pklen)
237 {
238 GNUNET_break_op (0);
239 return GNUNET_NO;
240 }
241 GNUNET_CRYPTO_hash (&pow[1],
242 pklen,
243 key);
244 return GNUNET_OK;
245}
struct GNUNET_HashCode key
The key used in the DHT.
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition: crypto_hash.c:41

References GNUNET_BLOCK_TYPE_REVOCATION, GNUNET_break, GNUNET_break_op, GNUNET_CRYPTO_hash(), GNUNET_CRYPTO_read_public_key_from_buffer(), GNUNET_NO, GNUNET_OK, GNUNET_SYSERR, key, pk, GNUNET_GNSRECORD_PowP::pow, RevokeMessage::pow_size, and type.

Referenced by libgnunet_plugin_block_revocation_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ libgnunet_plugin_block_revocation_init()

void * libgnunet_plugin_block_revocation_init ( void *  cls)

Entry point for the plugin.

Parameters
clsthe configuration to use

Definition at line 254 of file plugin_block_revocation.c.

255{
256 static const enum GNUNET_BLOCK_Type types[] = {
258 GNUNET_BLOCK_TYPE_ANY /* end of list */
259 };
260 const struct GNUNET_CONFIGURATION_Handle *cfg = cls;
262 struct InternalContext *ic;
263 unsigned long long matching_bits;
265
266 if (GNUNET_OK !=
268 "REVOCATION",
269 "WORKBITS",
271 return NULL;
272 if (GNUNET_OK !=
274 "REVOCATION",
275 "EPOCH_DURATION",
277 return NULL;
278
284 api->create_group = NULL;
285 api->types = types;
286 ic = GNUNET_new (struct InternalContext);
287 ic->matching_bits = (unsigned int) matching_bits;
289 api->cls = ic;
290 return api;
291}
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:109
static struct GNUNET_TIME_Relative epoch_duration
Epoch length.
static unsigned long long matching_bits
Number of matching bits required for revocation.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_number(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, unsigned long long *number)
Get a configuration value that should be a number.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_time(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, struct GNUNET_TIME_Relative *time)
Get a configuration value that should be a relative time.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
static enum GNUNET_GenericReturnValue block_plugin_revocation_check_query(void *cls, enum GNUNET_BLOCK_Type type, const struct GNUNET_HashCode *query, const void *xquery, size_t xquery_size)
Function called to validate a query.
static enum GNUNET_BLOCK_ReplyEvaluationResult block_plugin_revocation_check_reply(void *cls, enum GNUNET_BLOCK_Type type, struct GNUNET_BLOCK_Group *group, const struct GNUNET_HashCode *query, const void *xquery, size_t xquery_size, const void *reply_block, size_t reply_block_size)
Function called to validate a reply to a request.
static enum GNUNET_GenericReturnValue block_plugin_revocation_get_key(void *cls, enum GNUNET_BLOCK_Type type, const void *block, size_t block_size, struct GNUNET_HashCode *key)
Function called to obtain the key for a block.
static enum GNUNET_GenericReturnValue block_plugin_revocation_check_block(void *cls, enum GNUNET_BLOCK_Type type, const void *block, size_t block_size)
Function called to validate a block for storage.
GNUNET_BLOCK_Type
WARNING: This header is generated! In order to add DHT block types, you must register them in GANA,...
@ GNUNET_BLOCK_TYPE_ANY
Identifier for any block.
Each plugin is required to return a pointer to a struct of this type as the return value from its ent...
enum GNUNET_BLOCK_Type * types
0-terminated array of block types supported by this plugin.
GNUNET_BLOCK_QueryEvaluationFunction check_query
Check that a query is well-formed.
GNUNET_BLOCK_BlockEvaluationFunction check_block
Check that a block is well-formed.
GNUNET_BLOCK_GetKeyFunction get_key
Obtain the key for a given block (if possible).
GNUNET_BLOCK_ReplyEvaluationFunction check_reply
Check that a reply block matches a query.
GNUNET_BLOCK_GroupCreateFunction create_group
Create a block group to process a bunch of blocks in a shared context (i.e.
void * cls
Closure for all of the callbacks.
Time for relative time used by GNUnet, in microseconds.

References block_plugin_revocation_check_block(), block_plugin_revocation_check_query(), block_plugin_revocation_check_reply(), block_plugin_revocation_get_key(), cfg, GNUNET_BLOCK_PluginFunctions::check_block, GNUNET_BLOCK_PluginFunctions::check_query, GNUNET_BLOCK_PluginFunctions::check_reply, GNUNET_BLOCK_PluginFunctions::cls, GNUNET_BLOCK_PluginFunctions::create_group, epoch_duration, InternalContext::epoch_duration, GNUNET_BLOCK_PluginFunctions::get_key, GNUNET_BLOCK_TYPE_ANY, GNUNET_BLOCK_TYPE_REVOCATION, GNUNET_CONFIGURATION_get_value_number(), GNUNET_CONFIGURATION_get_value_time(), GNUNET_new, GNUNET_OK, consensus-simulation::int, matching_bits, InternalContext::matching_bits, and GNUNET_BLOCK_PluginFunctions::types.

Here is the call graph for this function:

◆ libgnunet_plugin_block_revocation_done()

void * libgnunet_plugin_block_revocation_done ( void *  cls)

Exit point from the plugin.

Definition at line 298 of file plugin_block_revocation.c.

299{
300 struct GNUNET_BLOCK_PluginFunctions *api = cls;
301 struct InternalContext *ic = api->cls;
302
303 GNUNET_free (ic);
304 GNUNET_free (api);
305 return NULL;
306}
#define GNUNET_free(ptr)
Wrapper around free.

References GNUNET_BLOCK_PluginFunctions::cls, and GNUNET_free.