GNUnet  0.17.6
Data Structures | Macros | Functions
plugin_block_revocation.c File Reference
#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"
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 34 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 1 of file plugin_block_revocation.c.

63 {
64  (void) cls;
65  (void) query;
66  (void) xquery;
68  {
69  GNUNET_break (0);
70  return GNUNET_SYSERR;
71  }
72  if (0 != xquery_size)
73  return GNUNET_NO;
74  return GNUNET_OK;
75 }
@ GNUNET_BLOCK_TYPE_REVOCATION
Block type for a revocation message by which a key is revoked.
@ GNUNET_OK
Definition: gnunet_common.h:99
@ GNUNET_NO
Definition: gnunet_common.h:98
@ GNUNET_SYSERR
Definition: gnunet_common.h:97
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model

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 1 of file plugin_block_revocation.c.

92 {
93  struct InternalContext *ic = cls;
94  const struct RevokeMessage *rm = block;
95  const struct GNUNET_REVOCATION_PowP *pow
96  = (const struct GNUNET_REVOCATION_PowP *) &rm[1];
98  ssize_t pklen;
99  size_t left;
100 
102  {
103  GNUNET_break (0);
104  return GNUNET_SYSERR;
105  }
106  if (block_size < sizeof(*rm) + sizeof(*pow))
107  {
108  GNUNET_break_op (0);
109  return GNUNET_NO;
110  }
111  if (block_size != sizeof(*rm) + ntohl (rm->pow_size))
112  {
113  GNUNET_break_op (0);
114  return GNUNET_NO;
115  }
116  left = block_size - sizeof (*rm) - sizeof (*pow);
118  &pow[1],
119  left);
120  if (0 > pklen)
121  {
122  GNUNET_break_op (0);
123  return GNUNET_NO;
124  }
125  if (GNUNET_YES !=
127  ic->matching_bits,
128  ic->epoch_duration))
129  {
130  GNUNET_break_op (0);
131  return GNUNET_NO;
132  }
133  return GNUNET_OK;
134 }
struct GNUNET_IDENTITY_PrivateKey pk
Private key from command line option, or NULL.
ssize_t GNUNET_IDENTITY_read_key_from_buffer(struct GNUNET_IDENTITY_PublicKey *key, const void *buffer, size_t len)
Reads a GNUNET_IDENTITY_PublicKey from a compact buffer.
@ GNUNET_YES
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
enum GNUNET_GenericReturnValue GNUNET_REVOCATION_check_pow(const struct GNUNET_REVOCATION_PowP *pow, unsigned int matching_bits, struct GNUNET_TIME_Relative epoch_duration)
Check if the given proof-of-work is valid.
An identity key as per LSD0001.
Struct for a proof of work as part of the revocation.
Context used inside the plugin.
struct GNUNET_TIME_Relative epoch_duration
Revoke key.
Definition: revocation.h:81
uint32_t pow_size
Length of PoW with signature.
Definition: revocation.h:90

Referenced by libgnunet_plugin_block_revocation_init().

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 1 of file plugin_block_revocation.c.

163 {
164  (void) cls;
165  (void) group;
166  (void) query;
167  (void) xquery;
168  (void) xquery_size;
169  (void) reply_block;
170  (void) reply_block_size;
172  {
173  GNUNET_break (0);
175  }
177 }
@ GNUNET_BLOCK_REPLY_OK_LAST
Last possible valid result.
@ GNUNET_BLOCK_REPLY_TYPE_NOT_SUPPORTED
Specified block type not supported by any plugin.

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 1 of file plugin_block_revocation.c.

197 {
198  const struct RevokeMessage *rm = block;
199  const struct GNUNET_REVOCATION_PowP *pow
200  = (const struct GNUNET_REVOCATION_PowP *) &rm[1];
202  ssize_t pklen;
203  size_t left;
204 
206  {
207  GNUNET_break (0);
208  return GNUNET_SYSERR;
209  }
210  if (block_size < sizeof(*rm) + sizeof(*pow))
211  {
212  GNUNET_break_op (0);
213  return GNUNET_NO;
214  }
215  if (block_size != sizeof(*rm) + ntohl (rm->pow_size))
216  {
217  GNUNET_break_op (0);
218  return GNUNET_NO;
219  }
220  left = block_size - sizeof (*rm) - sizeof (*pow);
222  &pow[1],
223  left);
224  if (0 > pklen)
225  {
226  GNUNET_break_op (0);
227  return GNUNET_NO;
228  }
229  GNUNET_CRYPTO_hash (&pow[1],
230  pklen,
231  key);
232  return GNUNET_OK;
233 }
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

Referenced by libgnunet_plugin_block_revocation_init().

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 242 of file plugin_block_revocation.c.

243 {
244  static const enum GNUNET_BLOCK_Type types[] = {
246  GNUNET_BLOCK_TYPE_ANY /* end of list */
247  };
248  const struct GNUNET_CONFIGURATION_Handle *cfg = cls;
249  struct GNUNET_BLOCK_PluginFunctions *api;
250  struct InternalContext *ic;
251  unsigned long long matching_bits;
253 
254  if (GNUNET_OK !=
256  "REVOCATION",
257  "WORKBITS",
258  &matching_bits))
259  return NULL;
260  if (GNUNET_OK !=
262  "REVOCATION",
263  "EPOCH_DURATION",
264  &epoch_duration))
265  return NULL;
266 
272  api->create_group = NULL;
273  api->types = types;
274  ic = GNUNET_new (struct InternalContext);
275  ic->matching_bits = (unsigned int) matching_bits;
277  api->cls = ic;
278  return api;
279 }
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
static struct GNUNET_TIME_Relative epoch_duration
Epoch length.
static unsigned long long matching_bits
Number of matching bits required for revocation.
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.
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.
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 286 of file plugin_block_revocation.c.

287 {
288  struct GNUNET_BLOCK_PluginFunctions *api = cls;
289  struct InternalContext *ic = api->cls;
290 
291  GNUNET_free (ic);
292  GNUNET_free (api);
293  return NULL;
294 }
#define GNUNET_free(ptr)
Wrapper around free.

References GNUNET_BLOCK_PluginFunctions::cls, and GNUNET_free.