GNUnet 0.21.2
gnunet-service-revocation.c File Reference

key revocation service More...

#include "platform.h"
#include <math.h>
#include "gnunet_util_lib.h"
#include "gnunet_gnsrecord_lib.h"
#include "gnunet_block_lib.h"
#include "gnunet_constants.h"
#include "gnunet_protocols.h"
#include "gnunet_signatures.h"
#include "gnunet_statistics_service.h"
#include "gnunet_core_service.h"
#include "gnunet_revocation_service.h"
#include "gnunet_setu_service.h"
#include "revocation.h"
#include <gcrypt.h>
Include dependency graph for gnunet-service-revocation.c:

Go to the source code of this file.

Data Structures

struct  PeerEntry
 Per-peer information. More...
 

Functions

static struct PeerEntrynew_peer_entry (const struct GNUNET_PeerIdentity *peer)
 Create a new PeerEntry and add it to the peers multipeermap. More...
 
static enum GNUNET_GenericReturnValue verify_revoke_message (const struct RevokeMessage *rm)
 An revoke message has been received, check that it is well-formed. More...
 
static void * client_connect_cb (void *cls, struct GNUNET_SERVICE_Client *client, struct GNUNET_MQ_Handle *mq)
 Handle client connecting to the service. More...
 
static void client_disconnect_cb (void *cls, struct GNUNET_SERVICE_Client *client, void *app_cls)
 Handle client connecting to the service. More...
 
static int check_query_message (void *cls, const struct QueryMessage *qm)
 
static void handle_query_message (void *cls, const struct QueryMessage *qm)
 Handle QUERY message from client. More...
 
static enum GNUNET_GenericReturnValue do_flood (void *cls, const struct GNUNET_PeerIdentity *target, void *value)
 Flood the given revocation message to all neighbours. More...
 
static enum GNUNET_GenericReturnValue publicize_rm (const struct RevokeMessage *rm)
 Publicize revocation message. More...
 
static int check_revoke_message (void *cls, const struct RevokeMessage *rm)
 
static void handle_revoke_message (void *cls, const struct RevokeMessage *rm)
 Handle REVOKE message from client. More...
 
static int check_p2p_revoke (void *cls, const struct RevokeMessage *rm)
 
static void handle_p2p_revoke (void *cls, const struct RevokeMessage *rm)
 Core handler for flooded revocation messages. More...
 
static void add_revocation (void *cls, const struct GNUNET_SETU_Element *element, uint64_t current_size, enum GNUNET_SETU_Status status)
 Callback for set operation results. More...
 
static void transmit_task_cb (void *cls)
 The timeout for performing the set union has expired, run the set operation on the revocation certificates. More...
 
static void * handle_core_connect (void *cls, const struct GNUNET_PeerIdentity *peer, struct GNUNET_MQ_Handle *mq)
 Method called whenever a peer connects. More...
 
static void handle_core_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer, void *internal_cls)
 Method called whenever a peer disconnects. More...
 
static int free_entry (void *cls, const struct GNUNET_HashCode *key, void *value)
 Free all values in a hash map. More...
 
static void shutdown_task (void *cls)
 Task run during shutdown. More...
 
static void core_init (void *cls, const struct GNUNET_PeerIdentity *identity)
 Called on core init/fail. More...
 
static void handle_revocation_union_request (void *cls, const struct GNUNET_PeerIdentity *other_peer, const struct GNUNET_MessageHeader *context_msg, struct GNUNET_SETU_Request *request)
 Called when another peer wants to do a set operation with the local peer. More...
 
static void run (void *cls, const struct GNUNET_CONFIGURATION_Handle *c, struct GNUNET_SERVICE_Handle *service)
 Handle network size estimate clients. More...
 
 GNUNET_SERVICE_MAIN ("revocation", GNUNET_SERVICE_OPTION_NONE, &run, &client_connect_cb, &client_disconnect_cb, NULL, GNUNET_MQ_hd_var_size(query_message, GNUNET_MESSAGE_TYPE_REVOCATION_QUERY, struct QueryMessage, NULL), GNUNET_MQ_hd_var_size(revoke_message, GNUNET_MESSAGE_TYPE_REVOCATION_REVOKE, struct RevokeMessage, NULL), GNUNET_MQ_handler_end())
 Define "main" method using service macro. More...
 

Variables

static struct GNUNET_SETU_Handlerevocation_set
 Set from all revocations known to us. More...
 
static struct GNUNET_CONTAINER_MultiHashMaprevocation_map
 Hash map with all revoked keys, maps the hash of the public key to the respective struct RevokeMessage. More...
 
static const struct GNUNET_CONFIGURATION_Handlecfg
 Handle to our current configuration. More...
 
static struct GNUNET_STATISTICS_Handlestats
 Handle to the statistics service. More...
 
static struct GNUNET_CORE_Handlecore_api
 Handle to the core service (for flooding) More...
 
static struct GNUNET_CONTAINER_MultiPeerMappeers
 Map of all connected peers. More...
 
static struct GNUNET_PeerIdentity my_identity
 The peer identity of this peer. More...
 
static struct GNUNET_DISK_FileHandlerevocation_db
 File handle for the revocation database. More...
 
static struct GNUNET_SETU_ListenHandlerevocation_union_listen_handle
 Handle for us listening to incoming revocation set union requests. More...
 
static unsigned long long revocation_work_required
 Amount of work required (W-bit collisions) for REVOCATION proofs, in collision-bits. More...
 
static struct GNUNET_TIME_Relative epoch_duration
 Length of an expiration expoch. More...
 
static struct GNUNET_HashCode revocation_set_union_app_id
 Our application ID for set union operations. More...
 

Detailed Description

key revocation service

Author
Christian Grothoff

The purpose of this service is to allow users to permanently revoke (compromised) keys. This is done by flooding the network with the revocation requests. To reduce the attack potential offered by such flooding, revocations must include a proof of work. We use the set service for efficiently computing the union of revocations of peers that connect.

TODO:

  • optimization: avoid sending revocation back to peer that we got it from;
  • optimization: have randomized delay in sending revocations to other peers to make it rare to traverse each link twice (NSE-style)

Definition in file gnunet-service-revocation.c.

Function Documentation

◆ new_peer_entry()

static struct PeerEntry * new_peer_entry ( const struct GNUNET_PeerIdentity peer)
static

Create a new PeerEntry and add it to the peers multipeermap.

Parameters
peerthe peer identity
Returns
a pointer to the new PeerEntry

Definition at line 151 of file gnunet-service-revocation.c.

152{
153 struct PeerEntry *peer_entry;
154
155 peer_entry = GNUNET_new (struct PeerEntry);
156 peer_entry->id = *peer;
159 &peer_entry->id,
160 peer_entry,
162 return peer_entry;
163}
static struct GNUNET_CONTAINER_MultiPeerMap * peers
Map of all connected peers.
int GNUNET_CONTAINER_multipeermap_put(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY
There must only be one value per key; storing a value should fail if a value under the same key alrea...
@ GNUNET_OK
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
Per-peer information.
Definition: peer.c:34
struct GNUNET_PeerIdentity id
The identifier itself.
Definition: peer.c:38

References GNUNET_assert, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY, GNUNET_CONTAINER_multipeermap_put(), GNUNET_new, GNUNET_OK, PeerEntry::id, and peers.

Referenced by handle_core_connect(), and handle_revocation_union_request().

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

◆ verify_revoke_message()

static enum GNUNET_GenericReturnValue verify_revoke_message ( const struct RevokeMessage rm)
static

An revoke message has been received, check that it is well-formed.

Parameters
rmthe message to verify
Returns
GNUNET_YES if the message is verified GNUNET_NO if the key/signature don't verify

Definition at line 174 of file gnunet-service-revocation.c.

175{
176 const struct GNUNET_GNSRECORD_PowP *pow
177 = (const struct GNUNET_GNSRECORD_PowP *) &rm[1];
178
179 if (GNUNET_YES !=
181 (unsigned int) revocation_work_required,
183 {
185 "Proof of work invalid!\n");
186 GNUNET_break_op (0);
187 return GNUNET_NO;
188 }
189 return GNUNET_YES;
190}
static struct GNUNET_TIME_Relative epoch_duration
Length of an expiration expoch.
static unsigned long long revocation_work_required
Amount of work required (W-bit collisions) for REVOCATION proofs, in collision-bits.
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.
#define GNUNET_log(kind,...)
@ GNUNET_YES
@ GNUNET_NO
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
@ GNUNET_ERROR_TYPE_DEBUG
Struct for a proof of work as part of the revocation.
uint64_t pow[32]
The PoWs.

References epoch_duration, GNUNET_break_op, GNUNET_ERROR_TYPE_DEBUG, GNUNET_GNSRECORD_check_pow(), GNUNET_log, GNUNET_NO, GNUNET_YES, GNUNET_GNSRECORD_PowP::pow, and revocation_work_required.

Referenced by publicize_rm().

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

◆ client_connect_cb()

static void * client_connect_cb ( void *  cls,
struct GNUNET_SERVICE_Client client,
struct GNUNET_MQ_Handle mq 
)
static

Handle client connecting to the service.

Parameters
clsNULL
clientthe new client
mqthe message queue of client
Returns
client

Definition at line 202 of file gnunet-service-revocation.c.

205{
206 return client;
207}

◆ client_disconnect_cb()

static void client_disconnect_cb ( void *  cls,
struct GNUNET_SERVICE_Client client,
void *  app_cls 
)
static

Handle client connecting to the service.

Parameters
clsNULL
clientthe new client
app_clsmust alias client

Definition at line 218 of file gnunet-service-revocation.c.

221{
222 GNUNET_assert (client == app_cls);
223}

References GNUNET_assert.

◆ check_query_message()

static int check_query_message ( void *  cls,
const struct QueryMessage qm 
)
static

Definition at line 227 of file gnunet-service-revocation.c.

229{
230 uint16_t size;
231
232 size = ntohs (qm->header.size);
233 if (size <= sizeof(struct RevokeMessage) ||
234 (size > UINT16_MAX))
235 {
236 GNUNET_break (0);
237 return GNUNET_SYSERR;
238 }
239 return GNUNET_OK;
240
241}
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
@ GNUNET_SYSERR
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
static unsigned int size
Size of the "table".
Definition: peer.c:68
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_REVOCATION_QUERY.
Definition: revocation.h:42
Revoke key.
Definition: revocation.h:80

References GNUNET_break, GNUNET_OK, GNUNET_SYSERR, QueryMessage::header, GNUNET_MessageHeader::size, and size.

◆ handle_query_message()

static void handle_query_message ( void *  cls,
const struct QueryMessage qm 
)
static

Handle QUERY message from client.

Parameters
clsclient who sent the message
qmthe message received

Definition at line 251 of file gnunet-service-revocation.c.

253{
254 struct GNUNET_SERVICE_Client *client = cls;
255 struct GNUNET_CRYPTO_PublicKey zone;
256 struct GNUNET_MQ_Envelope *env;
257 struct QueryResponseMessage *qrm;
258 struct GNUNET_HashCode hc;
259 int res;
260 size_t key_len;
261 size_t read;
262
263 key_len = ntohl (qm->key_len);
264 if ((GNUNET_SYSERR ==
266 &zone, &read)) ||
267 (read != key_len))
268 {
270 "Unable to parse query public key\n");
272 return;
273 }
274 GNUNET_CRYPTO_hash (&qm[1],
275 key_len,
276 &hc);
278 &hc);
280 (GNUNET_NO == res)
281 ? "Received revocation check for valid key `%s' from client\n"
282 : "Received revocation check for revoked key `%s' from client\n",
283 GNUNET_h2s (&hc));
284 env = GNUNET_MQ_msg (qrm,
286 qrm->is_valid = htonl ((GNUNET_YES == res) ? GNUNET_NO : GNUNET_YES);
288 env);
290}
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
static char * res
Currently read line or NULL on EOF.
static struct GNUNET_CONTAINER_MultiHashMap * revocation_map
Hash map with all revoked keys, maps the hash of the public key to the respective struct RevokeMessag...
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
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_contains(const struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Check if the map contains any value under the given key (including values that are NULL).
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:120
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
@ GNUNET_ERROR_TYPE_ERROR
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:305
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:78
#define GNUNET_MESSAGE_TYPE_REVOCATION_QUERY_RESPONSE
Service to client: answer if key was revoked!
void GNUNET_SERVICE_client_drop(struct GNUNET_SERVICE_Client *c)
Ask the server to disconnect from the given client.
Definition: service.c:2484
struct GNUNET_MQ_Handle * GNUNET_SERVICE_client_get_mq(struct GNUNET_SERVICE_Client *c)
Obtain the message queue of c.
Definition: service.c:2566
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2455
An identity key as per LSD0001.
A 512-bit hashcode.
Handle to a client that is connected to a service.
Definition: service.c:246
uint32_t key_len
Key length.
Definition: revocation.h:47
Key revocation response.
Definition: revocation.h:59
uint32_t is_valid
GNUNET_NO if revoked, GNUNET_YES if valid.
Definition: revocation.h:68

References env, GNUNET_CONTAINER_multihashmap_contains(), GNUNET_CRYPTO_hash(), GNUNET_CRYPTO_read_public_key_from_buffer(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_h2s(), GNUNET_log, GNUNET_MESSAGE_TYPE_REVOCATION_QUERY_RESPONSE, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_NO, GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_drop(), GNUNET_SERVICE_client_get_mq(), GNUNET_SYSERR, GNUNET_YES, QueryResponseMessage::is_valid, QueryMessage::key_len, res, and revocation_map.

Here is the call graph for this function:

◆ do_flood()

static enum GNUNET_GenericReturnValue do_flood ( void *  cls,
const struct GNUNET_PeerIdentity target,
void *  value 
)
static

Flood the given revocation message to all neighbours.

Parameters
clsthe struct RevokeMessage to flood
targeta neighbour
valueour struct PeerEntry for the neighbour
Returns
GNUNET_OK (continue to iterate)

Definition at line 302 of file gnunet-service-revocation.c.

305{
306 const struct RevokeMessage *rm = cls;
307 struct PeerEntry *pe = value;
308 struct GNUNET_MQ_Envelope *e;
309 struct RevokeMessage *cp;
310
311 if (NULL == pe->mq)
312 return GNUNET_OK; /* peer connected to us via SET,
313 but we have no direct CORE
314 connection for flooding */
315 e = GNUNET_MQ_msg_extra (cp,
316 htonl (rm->pow_size),
318 *cp = *rm;
319 memcpy (&cp[1],
320 &rm[1],
321 htonl (rm->pow_size));
323 "Flooding revocation to `%s'\n",
324 GNUNET_i2s (target));
325 GNUNET_MQ_send (pe->mq,
326 e);
327 return GNUNET_OK;
328}
static char * value
Value of the record to add/remove.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct.
Definition: gnunet_mq_lib.h:63
#define GNUNET_MESSAGE_TYPE_REVOCATION_REVOKE
Client to service OR peer-to-peer: revoke this key!
struct GNUNET_MQ_Handle * mq
Queue for sending messages to this peer.
uint32_t pow_size
Length of PoW with signature.
Definition: revocation.h:89

References GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_log, GNUNET_MESSAGE_TYPE_REVOCATION_REVOKE, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_OK, PeerEntry::mq, RevokeMessage::pow_size, and value.

Referenced by publicize_rm().

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

◆ publicize_rm()

static enum GNUNET_GenericReturnValue publicize_rm ( const struct RevokeMessage rm)
static

Publicize revocation message.

Stores the message locally in the database and passes it to all connected neighbours (and adds it to the set for future connections).

Parameters
rmmessage to publicize
Returns
GNUNET_OK on success, GNUNET_NO if we encountered an error, GNUNET_SYSERR if the message was malformed

FIXME yeah this works, but should we have a key length somewhere?

Definition at line 341 of file gnunet-service-revocation.c.

342{
343 struct RevokeMessage *cp;
344 struct GNUNET_HashCode hc;
345 struct GNUNET_SETU_Element e;
346 ssize_t pklen;
347 const struct GNUNET_GNSRECORD_PowP *pow
348 = (const struct GNUNET_GNSRECORD_PowP *) &rm[1];
349 const struct GNUNET_CRYPTO_PublicKey *pk
350 = (const struct GNUNET_CRYPTO_PublicKey *) &pow[1];
351
354 if (0 > pklen)
355 {
356 GNUNET_break_op (0);
357 return GNUNET_SYSERR;
358 }
360 pklen,
361 &hc);
362 if (GNUNET_YES ==
364 &hc))
365 {
367 "Duplicate revocation received from peer. Ignored.\n");
368 return GNUNET_OK;
369 }
370 if (GNUNET_OK !=
372 {
373 GNUNET_break_op (0);
374 return GNUNET_SYSERR;
375 }
376 /* write to disk */
377 if (sizeof(struct RevokeMessage) !=
379 rm,
380 sizeof(struct RevokeMessage)))
381 {
383 "write");
384 return GNUNET_NO;
385 }
386 if (GNUNET_OK !=
388 {
390 "sync");
391 return GNUNET_NO;
392 }
393 /* keep copy in memory */
394 cp = (struct RevokeMessage *) GNUNET_copy_message (&rm->header);
397 &hc,
398 cp,
400 /* add to set for future connections */
401 e.size = htons (rm->header.size);
402 e.element_type = GNUNET_BLOCK_TYPE_REVOCATION;
403 e.data = rm;
404 if (GNUNET_OK !=
406 &e,
407 NULL,
408 NULL))
409 {
410 GNUNET_break (0);
411 return GNUNET_OK;
412 }
413 else
414 {
416 "Added revocation info to SET\n");
417 }
418 /* flood to neighbours */
420 &do_flood,
421 cp);
422 return GNUNET_OK;
423}
struct GNUNET_CRYPTO_PrivateKey pk
Private key from command line option, or NULL.
static struct GNUNET_DISK_FileHandle * revocation_db
File handle for the revocation database.
static struct GNUNET_SETU_Handle * revocation_set
Set from all revocations known to us.
static enum GNUNET_GenericReturnValue do_flood(void *cls, const struct GNUNET_PeerIdentity *target, void *value)
Flood the given revocation message to all neighbours.
static enum GNUNET_GenericReturnValue verify_revoke_message(const struct RevokeMessage *rm)
An revoke message has been received, check that it is well-formed.
ssize_t GNUNET_DISK_file_write(const struct GNUNET_DISK_FileHandle *h, const void *buffer, size_t n)
Write a buffer to a file.
Definition: disk.c:686
enum GNUNET_GenericReturnValue GNUNET_DISK_file_sync(const struct GNUNET_DISK_FileHandle *h)
Write file changes to disk.
Definition: disk.c:1427
int GNUNET_CONTAINER_multipeermap_iterate(struct GNUNET_CONTAINER_MultiPeerMap *map, GNUNET_CONTAINER_PeerMapIterator it, void *it_cls)
Iterate over all entries in the map.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_put(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
ssize_t GNUNET_CRYPTO_public_key_get_length(const struct GNUNET_CRYPTO_PublicKey *key)
Get the compacted length of a GNUNET_CRYPTO_PublicKey.
Definition: crypto_pkey.c:85
#define GNUNET_log_strerror(level, cmd)
Log an error message at log-level 'level' that indicates a failure of the command 'cmd' with the mess...
struct GNUNET_MessageHeader * GNUNET_copy_message(const struct GNUNET_MessageHeader *msg)
Create a copy of the given message.
int GNUNET_SETU_add_element(struct GNUNET_SETU_Handle *set, const struct GNUNET_SETU_Element *element, GNUNET_SCHEDULER_TaskCallback cb, void *cb_cls)
Add an element to the given set.
Definition: setu_api.c:429
@ GNUNET_BLOCK_TYPE_REVOCATION
Block type for a revocation message by which a key is revoked.
Element stored in a set.
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_REVOCATION_REVOKE.
Definition: revocation.h:84

References GNUNET_SETU_Element::data, do_flood(), GNUNET_SETU_Element::element_type, GNUNET_BLOCK_TYPE_REVOCATION, GNUNET_break, GNUNET_break_op, GNUNET_CONTAINER_multihashmap_contains(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY, GNUNET_CONTAINER_multipeermap_iterate(), GNUNET_copy_message(), GNUNET_CRYPTO_hash(), GNUNET_CRYPTO_public_key_get_length(), GNUNET_DISK_file_sync(), GNUNET_DISK_file_write(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_log_strerror, GNUNET_NO, GNUNET_OK, GNUNET_SETU_add_element(), GNUNET_SYSERR, GNUNET_YES, RevokeMessage::header, peers, pk, GNUNET_GNSRECORD_PowP::pow, revocation_db, revocation_map, revocation_set, GNUNET_MessageHeader::size, GNUNET_SETU_Element::size, and verify_revoke_message().

Referenced by handle_p2p_revoke(), and handle_revoke_message().

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

◆ check_revoke_message()

static int check_revoke_message ( void *  cls,
const struct RevokeMessage rm 
)
static

Definition at line 427 of file gnunet-service-revocation.c.

429{
430 uint16_t size;
431
432 size = ntohs (rm->header.size);
433 if (size <= sizeof(struct RevokeMessage) ||
434 (size > UINT16_MAX))
435 {
436 GNUNET_break (0);
437 return GNUNET_SYSERR;
438 }
439 return GNUNET_OK;
440
441}

References GNUNET_break, GNUNET_OK, GNUNET_SYSERR, RevokeMessage::header, GNUNET_MessageHeader::size, and size.

◆ handle_revoke_message()

static void handle_revoke_message ( void *  cls,
const struct RevokeMessage rm 
)
static

Handle REVOKE message from client.

Parameters
clsclient who sent the message
rmthe message received

Definition at line 451 of file gnunet-service-revocation.c.

453{
454 struct GNUNET_SERVICE_Client *client = cls;
455 struct GNUNET_MQ_Envelope *env;
456 struct RevocationResponseMessage *rrm;
457 int ret;
458
460 "Received REVOKE message from client\n");
461 if (GNUNET_SYSERR == (ret = publicize_rm (rm)))
462 {
463 GNUNET_break_op (0);
465 return;
466 }
467 env = GNUNET_MQ_msg (rrm,
469 rrm->is_valid = htonl ((GNUNET_OK == ret) ? GNUNET_NO : GNUNET_YES);
471 env);
473}
static int ret
Final status code.
Definition: gnunet-arm.c:94
static enum GNUNET_GenericReturnValue publicize_rm(const struct RevokeMessage *rm)
Publicize revocation message.
#define GNUNET_MESSAGE_TYPE_REVOCATION_REVOKE_RESPONSE
Service to client: revocation confirmed.
Key revocation response.
Definition: revocation.h:99
uint32_t is_valid
GNUNET_NO if revocation failed for internal reasons (e.g.
Definition: revocation.h:109

References env, GNUNET_break_op, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_MESSAGE_TYPE_REVOCATION_REVOKE_RESPONSE, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_NO, GNUNET_OK, GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_drop(), GNUNET_SERVICE_client_get_mq(), GNUNET_SYSERR, GNUNET_YES, RevocationResponseMessage::is_valid, publicize_rm(), and ret.

Here is the call graph for this function:

◆ check_p2p_revoke()

static int check_p2p_revoke ( void *  cls,
const struct RevokeMessage rm 
)
static

Definition at line 477 of file gnunet-service-revocation.c.

479{
480 uint16_t size;
481
482 size = ntohs (rm->header.size);
483 if (size <= sizeof(struct RevokeMessage))
484 {
485 GNUNET_break (0);
486 return GNUNET_SYSERR;
487 }
488 return GNUNET_OK;
489
490}

References GNUNET_break, GNUNET_OK, GNUNET_SYSERR, RevokeMessage::header, GNUNET_MessageHeader::size, and size.

◆ handle_p2p_revoke()

static void handle_p2p_revoke ( void *  cls,
const struct RevokeMessage rm 
)
static

Core handler for flooded revocation messages.

Parameters
clsclosure unused
rmrevocation message

Definition at line 500 of file gnunet-service-revocation.c.

502{
504 "Received REVOKE message\n");
506 publicize_rm (rm));
507}

References GNUNET_break_op, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_SYSERR, and publicize_rm().

Referenced by add_revocation().

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

◆ add_revocation()

static void add_revocation ( void *  cls,
const struct GNUNET_SETU_Element element,
uint64_t  current_size,
enum GNUNET_SETU_Status  status 
)
static

Callback for set operation results.

Called for each element in the result set. Each element contains a revocation, which we should validate and then add to our revocation list (and set).

Parameters
clsclosure
elementa result element, only valid if status is #GNUNET_SETU_STATUS_OK
current_sizecurrent set size
statussee enum GNUNET_SETU_Status

Definition at line 521 of file gnunet-service-revocation.c.

525{
526 struct PeerEntry *peer_entry = cls;
527 const struct RevokeMessage *rm;
528
529 switch (status)
530 {
532 if (element->size != sizeof(struct RevokeMessage))
533 {
534 GNUNET_break_op (0);
535 return;
536 }
538 {
541 "# unsupported revocations received via set union"),
542 1,
543 GNUNET_NO);
544 return;
545 }
546 rm = element->data;
547 (void) handle_p2p_revoke (NULL,
548 rm);
551 "# revocation messages received via set union"),
552 1, GNUNET_NO);
553 break;
556 _ ("Error computing revocation set union with %s\n"),
557 GNUNET_i2s (&peer_entry->id));
558 peer_entry->so = NULL;
560 gettext_noop ("# revocation set unions failed"),
561 1,
562 GNUNET_NO);
563 break;
565 peer_entry->so = NULL;
568 "# revocation set unions completed"),
569 1,
570 GNUNET_NO);
571 break;
572 default:
573 GNUNET_break (0);
574 break;
575 }
576}
#define gettext_noop(String)
Definition: gettext.h:74
static int status
The program status; 0 for success.
Definition: gnunet-nse.c:39
static struct GNUNET_STATISTICS_Handle * stats
Handle to the statistics service.
static void handle_p2p_revoke(void *cls, const struct RevokeMessage *rm)
Core handler for flooded revocation messages.
@ GNUNET_ERROR_TYPE_WARNING
@ GNUNET_SETU_STATUS_DONE
Success, all elements have been sent (and received).
@ GNUNET_SETU_STATUS_FAILURE
The other peer refused to do the operation with us, or something went wrong.
@ GNUNET_SETU_STATUS_ADD_LOCAL
Element should be added to the result set of the local peer, i.e.
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
#define _(String)
GNU gettext support macro.
Definition: platform.h:178
uint16_t element_type
Application-specific element type.
uint16_t size
Number of bytes in the buffer pointed to by data.
const void * data
Actual data of the element.
struct GNUNET_SETU_OperationHandle * so
Handle to active set union operation (over revocation sets).

References _, GNUNET_SETU_Element::data, GNUNET_SETU_Element::element_type, gettext_noop, GNUNET_BLOCK_TYPE_REVOCATION, GNUNET_break, GNUNET_break_op, GNUNET_ERROR_TYPE_WARNING, GNUNET_i2s(), GNUNET_log, GNUNET_NO, GNUNET_SETU_STATUS_ADD_LOCAL, GNUNET_SETU_STATUS_DONE, GNUNET_SETU_STATUS_FAILURE, GNUNET_STATISTICS_update(), handle_p2p_revoke(), PeerEntry::id, GNUNET_SETU_Element::size, PeerEntry::so, stats, and status.

Referenced by handle_revocation_union_request().

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

◆ transmit_task_cb()

static void transmit_task_cb ( void *  cls)
static

The timeout for performing the set union has expired, run the set operation on the revocation certificates.

Parameters
clsNULL

Definition at line 586 of file gnunet-service-revocation.c.

587{
588 struct PeerEntry *peer_entry = cls;
589
591 "Starting set exchange with peer `%s'\n",
592 GNUNET_i2s (&peer_entry->id));
593 peer_entry->transmit_task = NULL;
594 GNUNET_assert (NULL == peer_entry->so);
595 peer_entry->so = GNUNET_SETU_prepare (&peer_entry->id,
597 NULL,
598 (struct GNUNET_SETU_Option[]) { { 0 } },
600 peer_entry);
601 if (GNUNET_OK !=
602 GNUNET_SETU_commit (peer_entry->so,
604 {
606 _ ("SET service crashed, terminating revocation service\n"));
608 return;
609 }
610}
static struct GNUNET_HashCode revocation_set_union_app_id
Our application ID for set union operations.
static void add_revocation(void *cls, const struct GNUNET_SETU_Element *element, uint64_t current_size, enum GNUNET_SETU_Status status)
Callback for set operation results.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:567
struct GNUNET_SETU_OperationHandle * GNUNET_SETU_prepare(const struct GNUNET_PeerIdentity *other_peer, const struct GNUNET_HashCode *app_id, const struct GNUNET_MessageHeader *context_msg, const struct GNUNET_SETU_Option options[], GNUNET_SETU_ResultIterator result_cb, void *result_cls)
Prepare a set operation to be evaluated with another peer.
Definition: setu_api.c:497
int GNUNET_SETU_commit(struct GNUNET_SETU_OperationHandle *oh, struct GNUNET_SETU_Handle *set)
Commit a set to be used with a set operation.
Definition: setu_api.c:851
Option for set operations.
struct GNUNET_SCHEDULER_Task * transmit_task
Tasked used to trigger the set union operation.

References GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_log, GNUNET_SETU_prepare(), PeerEntry::id, revocation_set_union_app_id, PeerEntry::so, and PeerEntry::transmit_task.

Referenced by handle_core_connect().

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

◆ handle_core_connect()

static void * handle_core_connect ( void *  cls,
const struct GNUNET_PeerIdentity peer,
struct GNUNET_MQ_Handle mq 
)
static

Method called whenever a peer connects.

Sets up the PeerEntry and schedules the initial revocation set exchange with this peer.

Parameters
clsclosure
peerpeer identity this notification is about

Definition at line 621 of file gnunet-service-revocation.c.

624{
625 struct PeerEntry *peer_entry;
626 struct GNUNET_HashCode my_hash;
627 struct GNUNET_HashCode peer_hash;
628
629 if (0 == GNUNET_memcmp (peer,
630 &my_identity))
631 {
632 return NULL;
633 }
634
636 "Peer `%s' connected to us\n",
637 GNUNET_i2s (peer));
639 "# peers connected",
640 1,
641 GNUNET_NO);
643 peer);
644 if (NULL != peer_entry)
645 {
646 /* This can happen if "core"'s notification is a tad late
647 and CADET+SET were faster and already produced a
648 #handle_revocation_union_request() for us to deal
649 with. This should be rare, but isn't impossible. */
650 peer_entry->mq = mq;
651 return peer_entry;
652 }
653 peer_entry = new_peer_entry (peer);
654 peer_entry->mq = mq;
656 sizeof(my_identity),
657 &my_hash);
658 GNUNET_CRYPTO_hash (peer,
659 sizeof(*peer),
660 &peer_hash);
661 if (0 < GNUNET_CRYPTO_hash_cmp (&my_hash,
662 &peer_hash))
663 {
665 "Starting SET operation with peer `%s'\n",
666 GNUNET_i2s (peer));
667 peer_entry->transmit_task =
670 peer_entry);
671 }
672 return peer_entry;
673}
struct GNUNET_MQ_Handle * mq
Definition: 003.c:5
static void transmit_task_cb(void *cls)
The timeout for performing the set union has expired, run the set operation on the revocation certifi...
static struct GNUNET_PeerIdentity my_identity
The peer identity of this peer.
static struct PeerEntry * new_peer_entry(const struct GNUNET_PeerIdentity *peer)
Create a new PeerEntry and add it to the peers multipeermap.
int GNUNET_CRYPTO_hash_cmp(const struct GNUNET_HashCode *h1, const struct GNUNET_HashCode *h2)
Compare function for HashCodes, producing a total ordering of all hashcodes.
Definition: crypto_hash.c:221
void * GNUNET_CONTAINER_multipeermap_get(const struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key)
Given a key find a value in the map matching the key.
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
Definition: scheduler.c:1278
#define GNUNET_TIME_UNIT_SECONDS
One second.

References GNUNET_CONTAINER_multipeermap_get(), GNUNET_CRYPTO_hash(), GNUNET_CRYPTO_hash_cmp(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_log, GNUNET_memcmp, GNUNET_NO, GNUNET_SCHEDULER_add_delayed(), GNUNET_STATISTICS_update(), GNUNET_TIME_UNIT_SECONDS, mq, PeerEntry::mq, my_identity, new_peer_entry(), peers, stats, PeerEntry::transmit_task, and transmit_task_cb().

Referenced by run().

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

◆ handle_core_disconnect()

static void handle_core_disconnect ( void *  cls,
const struct GNUNET_PeerIdentity peer,
void *  internal_cls 
)
static

Method called whenever a peer disconnects.

Deletes the PeerEntry and cancels any pending transmission requests to that peer.

Parameters
clsclosure
peerpeer identity this notification is about
internal_clsour struct PeerEntry for this peer

Definition at line 685 of file gnunet-service-revocation.c.

688{
689 struct PeerEntry *peer_entry = internal_cls;
690
691 if (0 == GNUNET_memcmp (peer,
692 &my_identity))
693 return;
694 GNUNET_assert (NULL != peer_entry);
696 "Peer `%s' disconnected from us\n",
697 GNUNET_i2s (peer));
700 peer,
701 peer_entry));
702 if (NULL != peer_entry->transmit_task)
703 {
705 peer_entry->transmit_task = NULL;
706 }
707 if (NULL != peer_entry->so)
708 {
709 GNUNET_SETU_operation_cancel (peer_entry->so);
710 peer_entry->so = NULL;
711 }
712 GNUNET_free (peer_entry);
714 "# peers connected",
715 -1,
716 GNUNET_NO);
717}
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multipeermap_remove(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, const void *value)
Remove the given key-value pair from the map.
#define GNUNET_free(ptr)
Wrapper around free.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:981
void GNUNET_SETU_operation_cancel(struct GNUNET_SETU_OperationHandle *oh)
Cancel the given set operation.
Definition: setu_api.c:320

References GNUNET_assert, GNUNET_CONTAINER_multipeermap_remove(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_i2s(), GNUNET_log, GNUNET_memcmp, GNUNET_NO, GNUNET_SCHEDULER_cancel(), GNUNET_SETU_operation_cancel(), GNUNET_STATISTICS_update(), GNUNET_YES, my_identity, peers, PeerEntry::so, stats, and PeerEntry::transmit_task.

Referenced by run().

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

◆ free_entry()

static int free_entry ( void *  cls,
const struct GNUNET_HashCode key,
void *  value 
)
static

Free all values in a hash map.

Parameters
clsNULL
keythe key
valuevalue to free
Returns
GNUNET_OK (continue to iterate)

Definition at line 729 of file gnunet-service-revocation.c.

732{
734 return GNUNET_OK;
735}

References GNUNET_free, GNUNET_OK, and value.

Referenced by shutdown_task().

Here is the caller graph for this function:

◆ shutdown_task()

static void shutdown_task ( void *  cls)
static

Task run during shutdown.

Parameters
clsunused

Definition at line 744 of file gnunet-service-revocation.c.

745{
746 if (NULL != revocation_set)
747 {
749 revocation_set = NULL;
750 }
752 {
755 }
756 if (NULL != core_api)
757 {
759 core_api = NULL;
760 }
761 if (NULL != stats)
762 {
764 stats = NULL;
765 }
766 if (NULL != peers)
767 {
769 peers = NULL;
770 }
771 if (NULL != revocation_db)
772 {
774 revocation_db = NULL;
775 }
777 &free_entry,
778 NULL);
780}
static struct GNUNET_SETU_ListenHandle * revocation_union_listen_handle
Handle for us listening to incoming revocation set union requests.
static int free_entry(void *cls, const struct GNUNET_HashCode *key, void *value)
Free all values in a hash map.
static struct GNUNET_CORE_Handle * core_api
Handle to the core service (for flooding)
void GNUNET_CORE_disconnect(struct GNUNET_CORE_Handle *handle)
Disconnect from the core service.
Definition: core_api.c:729
enum GNUNET_GenericReturnValue GNUNET_DISK_file_close(struct GNUNET_DISK_FileHandle *h)
Close an open file.
Definition: disk.c:1308
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MultiHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
void GNUNET_CONTAINER_multipeermap_destroy(struct GNUNET_CONTAINER_MultiPeerMap *map)
Destroy a hash map.
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
void GNUNET_SETU_destroy(struct GNUNET_SETU_Handle *set)
Destroy the set handle, and free all associated resources.
Definition: setu_api.c:471
void GNUNET_SETU_listen_cancel(struct GNUNET_SETU_ListenHandle *lh)
Cancel the given listen operation.
Definition: setu_api.c:749
void GNUNET_STATISTICS_destroy(struct GNUNET_STATISTICS_Handle *h, int sync_first)
Destroy a handle (free all state associated with it).

References core_api, free_entry(), GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_CONTAINER_multipeermap_destroy(), GNUNET_CORE_disconnect(), GNUNET_DISK_file_close(), GNUNET_NO, GNUNET_SETU_destroy(), GNUNET_SETU_listen_cancel(), GNUNET_STATISTICS_destroy(), peers, revocation_db, revocation_map, revocation_set, revocation_union_listen_handle, and stats.

Referenced by run().

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

◆ core_init()

static void core_init ( void *  cls,
const struct GNUNET_PeerIdentity identity 
)
static

Called on core init/fail.

Parameters
clsservice closure
identitythe public identity of this peer

Definition at line 790 of file gnunet-service-revocation.c.

792{
793 if (NULL == identity)
794 {
796 "Connection to core FAILED!\n");
798 return;
799 }
801}
static struct GNUNET_IDENTITY_Handle * identity
Which namespace do we publish to? NULL if we do not publish to a namespace.

References GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_SCHEDULER_shutdown(), identity, and my_identity.

Referenced by run().

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

◆ handle_revocation_union_request()

static void handle_revocation_union_request ( void *  cls,
const struct GNUNET_PeerIdentity other_peer,
const struct GNUNET_MessageHeader context_msg,
struct GNUNET_SETU_Request request 
)
static

Called when another peer wants to do a set operation with the local peer.

If a listen error occurs, the 'request' is NULL.

Parameters
clsclosure
other_peerthe other peer
context_msgmessage with application specific information from the other peer
requestrequest from the other peer (never NULL), use GNUNET_SETU_accept() to accept it, otherwise the request will be refused Note that we can't just return value from the listen callback, as it is also necessary to specify the set we want to do the operation with, which sometimes can be derived from the context message. It's necessary to specify the timeout.

Definition at line 820 of file gnunet-service-revocation.c.

824{
825 struct PeerEntry *peer_entry;
826
827 if (NULL == request)
828 {
829 GNUNET_break (0);
830 return;
831 }
833 "Received set exchange request from peer `%s'\n",
834 GNUNET_i2s (other_peer));
836 other_peer);
837 if (NULL == peer_entry)
838 {
839 peer_entry = new_peer_entry (other_peer);
840 }
841 if (NULL != peer_entry->so)
842 {
843 GNUNET_break_op (0);
844 return;
845 }
846 peer_entry->so = GNUNET_SETU_accept (request,
847 (struct GNUNET_SETU_Option[]) { { 0 } },
849 peer_entry);
850 if (GNUNET_OK !=
851 GNUNET_SETU_commit (peer_entry->so,
853 {
854 GNUNET_break (0);
856 return;
857 }
858}
static struct GNUNET_VPN_RedirectionRequest * request
Opaque redirection request handle.
Definition: gnunet-vpn.c:40
struct GNUNET_SETU_OperationHandle * GNUNET_SETU_accept(struct GNUNET_SETU_Request *request, const struct GNUNET_SETU_Option options[], GNUNET_SETU_ResultIterator result_cb, void *result_cls)
Accept a request we got via GNUNET_SETU_listen().
Definition: setu_api.c:769

References add_revocation(), GNUNET_break, GNUNET_break_op, GNUNET_CONTAINER_multipeermap_get(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_log, GNUNET_OK, GNUNET_SCHEDULER_shutdown(), GNUNET_SETU_accept(), GNUNET_SETU_commit(), new_peer_entry(), peers, request, revocation_set, and PeerEntry::so.

Referenced by run().

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

◆ run()

static void run ( void *  cls,
const struct GNUNET_CONFIGURATION_Handle c,
struct GNUNET_SERVICE_Handle service 
)
static

Handle network size estimate clients.

Parameters
clsclosure
serverthe initialized server
cconfiguration to use

Definition at line 869 of file gnunet-service-revocation.c.

872{
873 struct GNUNET_MQ_MessageHandler core_handlers[] = {
874 GNUNET_MQ_hd_var_size (p2p_revoke,
876 struct RevokeMessage,
877 NULL),
879 };
880 char *fn;
881 uint64_t left;
882 struct RevokeMessage *rm;
883 struct GNUNET_HashCode hc;
884 const struct GNUNET_CRYPTO_PublicKey *pk;
885
886 GNUNET_CRYPTO_hash ("revocation-set-union-application-id",
887 strlen ("revocation-set-union-application-id"),
889 if (GNUNET_OK !=
891 "REVOCATION",
892 "DATABASE",
893 &fn))
894 {
896 "REVOCATION",
897 "DATABASE");
899 return;
900 }
901 cfg = c;
903 GNUNET_NO);
905 NULL);
906 if (GNUNET_OK !=
908 "REVOCATION",
909 "WORKBITS",
911 {
913 "REVOCATION",
914 "WORKBITS");
916 GNUNET_free (fn);
917 return;
918 }
919 if (revocation_work_required >= sizeof(struct GNUNET_HashCode) * 8)
920 {
922 "REVOCATION",
923 "WORKBITS",
924 _ ("Value is too large.\n"));
926 GNUNET_free (fn);
927 return;
928 }
929 if (GNUNET_OK !=
931 "REVOCATION",
932 "EPOCH_DURATION",
934 {
936 "REVOCATION",
937 "EPOCH_DURATION");
939 GNUNET_free (fn);
940 return;
941 }
942
948 NULL);
956 if (NULL == revocation_db)
957 {
959 "REVOCATION",
960 "DATABASE",
961 _ ("Could not open revocation database file!"));
963 GNUNET_free (fn);
964 return;
965 }
966 if (GNUNET_OK !=
968 left = 0;
969 while (left > sizeof(struct RevokeMessage))
970 {
971 rm = GNUNET_new (struct RevokeMessage);
972 if (sizeof(struct RevokeMessage) !=
974 rm,
975 sizeof(struct RevokeMessage)))
976 {
978 "read",
979 fn);
980 GNUNET_free (rm);
982 GNUNET_free (fn);
983 return;
984 }
985 struct GNUNET_GNSRECORD_PowP *pow = (struct
986 GNUNET_GNSRECORD_PowP *) &rm[1];
987 ssize_t ksize;
988 pk = (const struct GNUNET_CRYPTO_PublicKey *) &pow[1];
990 if (0 > ksize)
991 {
992 GNUNET_break_op (0);
993 GNUNET_free (rm);
994 GNUNET_free (fn);
995 return;
996 }
998 ksize,
999 &hc);
1002 &hc,
1003 rm,
1005 }
1006 GNUNET_free (fn);
1007
1009 GNUNET_YES);
1010 /* Connect to core service and register core handlers */
1011 core_api = GNUNET_CORE_connect (cfg, /* Main configuration */
1012 NULL, /* Closure passed to functions */
1013 &core_init, /* Call core_init once connected */
1014 &handle_core_connect, /* Handle connects */
1015 &handle_core_disconnect, /* Handle disconnects */
1016 core_handlers); /* Register these handlers */
1017 if (NULL == core_api)
1018 {
1020 return;
1021 }
1022 stats = GNUNET_STATISTICS_create ("revocation",
1023 cfg);
1024}
static void core_init(void *cls, const struct GNUNET_PeerIdentity *identity)
Called on core init/fail.
static const struct GNUNET_CONFIGURATION_Handle * cfg
Handle to our current configuration.
static void * handle_core_connect(void *cls, const struct GNUNET_PeerIdentity *peer, struct GNUNET_MQ_Handle *mq)
Method called whenever a peer connects.
static void shutdown_task(void *cls)
Task run during shutdown.
static void handle_core_disconnect(void *cls, const struct GNUNET_PeerIdentity *peer, void *internal_cls)
Method called whenever a peer disconnects.
static void handle_revocation_union_request(void *cls, const struct GNUNET_PeerIdentity *other_peer, const struct GNUNET_MessageHeader *context_msg, struct GNUNET_SETU_Request *request)
Called when another peer wants to do a set operation with the local peer.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_filename(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be the name of a file or directory.
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.
struct GNUNET_CORE_Handle * GNUNET_CORE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, void *cls, GNUNET_CORE_StartupCallback init, GNUNET_CORE_ConnectEventHandler connects, GNUNET_CORE_DisconnectEventHandler disconnects, const struct GNUNET_MQ_MessageHandler *handlers)
Connect to the core service.
Definition: core_api.c:691
struct GNUNET_DISK_FileHandle * GNUNET_DISK_file_open(const char *fn, enum GNUNET_DISK_OpenFlags flags, enum GNUNET_DISK_AccessPermissions perm)
Open a file.
Definition: disk.c:1237
enum GNUNET_GenericReturnValue GNUNET_DISK_file_size(const char *filename, uint64_t *size, int include_symbolic_links, int single_file_mode)
Get the size of the file (or directory) of the given file (in bytes).
Definition: disk.c:221
ssize_t GNUNET_DISK_file_read(const struct GNUNET_DISK_FileHandle *h, void *result, size_t len)
Read the contents of a binary file into a buffer.
Definition: disk.c:622
@ GNUNET_DISK_OPEN_CREATE
Create file if it doesn't exist.
@ GNUNET_DISK_OPEN_READWRITE
Open the file for both reading and writing.
@ GNUNET_DISK_PERM_USER_READ
Owner can read.
@ GNUNET_DISK_PERM_GROUP_READ
Group can read.
@ GNUNET_DISK_PERM_USER_WRITE
Owner can write.
@ GNUNET_DISK_PERM_OTHER_READ
Everybody can read.
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
struct GNUNET_CONTAINER_MultiPeerMap * GNUNET_CONTAINER_multipeermap_create(unsigned int len, int do_not_copy_keys)
Create a multi peer map (hash map for public keys of peers).
void GNUNET_log_config_invalid(enum GNUNET_ErrorType kind, const char *section, const char *option, const char *required)
Log error message about invalid configuration option value.
void GNUNET_log_config_missing(enum GNUNET_ErrorType kind, const char *section, const char *option)
Log error message about missing configuration option.
#define GNUNET_log_strerror_file(level, cmd, filename)
Log an error message at log-level 'level' that indicates a failure of the command 'cmd' with the mess...
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_shutdown(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run on shutdown, that is when a CTRL-C signal is received,...
Definition: scheduler.c:1340
struct GNUNET_SETU_Handle * GNUNET_SETU_create(const struct GNUNET_CONFIGURATION_Handle *cfg)
Create an empty set, supporting the specified operation.
Definition: setu_api.c:384
struct GNUNET_SETU_ListenHandle * GNUNET_SETU_listen(const struct GNUNET_CONFIGURATION_Handle *cfg, const struct GNUNET_HashCode *app_id, GNUNET_SETU_ListenCallback listen_cb, void *listen_cls)
Wait for set operation requests for the given application ID.
Definition: setu_api.c:717
struct GNUNET_STATISTICS_Handle * GNUNET_STATISTICS_create(const char *subsystem, const struct GNUNET_CONFIGURATION_Handle *cfg)
Get handle for the statistics service.
Message handler for a specific message type.

References _, cfg, core_api, core_init(), epoch_duration, GNUNET_break, GNUNET_break_op, GNUNET_CONFIGURATION_get_value_filename(), GNUNET_CONFIGURATION_get_value_number(), GNUNET_CONFIGURATION_get_value_time(), GNUNET_CONTAINER_multihashmap_create(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY, GNUNET_CONTAINER_multipeermap_create(), GNUNET_CORE_connect(), GNUNET_CRYPTO_hash(), GNUNET_CRYPTO_public_key_get_length(), GNUNET_DISK_file_open(), GNUNET_DISK_file_read(), GNUNET_DISK_file_size(), GNUNET_DISK_OPEN_CREATE, GNUNET_DISK_OPEN_READWRITE, GNUNET_DISK_PERM_GROUP_READ, GNUNET_DISK_PERM_OTHER_READ, GNUNET_DISK_PERM_USER_READ, GNUNET_DISK_PERM_USER_WRITE, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_log_config_invalid(), GNUNET_log_config_missing(), GNUNET_log_strerror_file, GNUNET_MESSAGE_TYPE_REVOCATION_REVOKE, GNUNET_MQ_handler_end, GNUNET_MQ_hd_var_size, GNUNET_new, GNUNET_NO, GNUNET_OK, GNUNET_SCHEDULER_add_shutdown(), GNUNET_SCHEDULER_shutdown(), GNUNET_SETU_create(), GNUNET_SETU_listen(), GNUNET_STATISTICS_create(), GNUNET_YES, handle_core_connect(), handle_core_disconnect(), handle_revocation_union_request(), peers, pk, GNUNET_GNSRECORD_PowP::pow, revocation_db, revocation_map, revocation_set, revocation_set_union_app_id, revocation_union_listen_handle, revocation_work_required, shutdown_task(), and stats.

Here is the call graph for this function:

◆ GNUNET_SERVICE_MAIN()

GNUNET_SERVICE_MAIN ( "revocation"  ,
GNUNET_SERVICE_OPTION_NONE  ,
run,
client_connect_cb,
client_disconnect_cb,
NULL  ,
GNUNET_MQ_hd_var_size(query_message, GNUNET_MESSAGE_TYPE_REVOCATION_QUERY, struct QueryMessage, NULL)  ,
GNUNET_MQ_hd_var_size(revoke_message, GNUNET_MESSAGE_TYPE_REVOCATION_REVOKE, struct RevokeMessage, NULL)  ,
GNUNET_MQ_handler_end()   
)

Define "main" method using service macro.

Variable Documentation

◆ revocation_set

struct GNUNET_SETU_Handle* revocation_set
static

Set from all revocations known to us.

Definition at line 84 of file gnunet-service-revocation.c.

Referenced by handle_revocation_union_request(), publicize_rm(), run(), and shutdown_task().

◆ revocation_map

struct GNUNET_CONTAINER_MultiHashMap* revocation_map
static

Hash map with all revoked keys, maps the hash of the public key to the respective struct RevokeMessage.

Definition at line 90 of file gnunet-service-revocation.c.

Referenced by handle_query_message(), publicize_rm(), run(), and shutdown_task().

◆ cfg

const struct GNUNET_CONFIGURATION_Handle* cfg
static

Handle to our current configuration.

Definition at line 95 of file gnunet-service-revocation.c.

Referenced by run().

◆ stats

struct GNUNET_STATISTICS_Handle* stats
static

Handle to the statistics service.

Definition at line 100 of file gnunet-service-revocation.c.

Referenced by add_revocation(), handle_core_connect(), handle_core_disconnect(), run(), and shutdown_task().

◆ core_api

struct GNUNET_CORE_Handle* core_api
static

Handle to the core service (for flooding)

Definition at line 105 of file gnunet-service-revocation.c.

Referenced by run(), and shutdown_task().

◆ peers

◆ my_identity

struct GNUNET_PeerIdentity my_identity
static

The peer identity of this peer.

Definition at line 115 of file gnunet-service-revocation.c.

Referenced by core_init(), handle_core_connect(), and handle_core_disconnect().

◆ revocation_db

struct GNUNET_DISK_FileHandle* revocation_db
static

File handle for the revocation database.

Definition at line 120 of file gnunet-service-revocation.c.

Referenced by publicize_rm(), run(), and shutdown_task().

◆ revocation_union_listen_handle

struct GNUNET_SETU_ListenHandle* revocation_union_listen_handle
static

Handle for us listening to incoming revocation set union requests.

Definition at line 125 of file gnunet-service-revocation.c.

Referenced by run(), and shutdown_task().

◆ revocation_work_required

unsigned long long revocation_work_required
static

Amount of work required (W-bit collisions) for REVOCATION proofs, in collision-bits.

Definition at line 130 of file gnunet-service-revocation.c.

Referenced by run(), and verify_revoke_message().

◆ epoch_duration

struct GNUNET_TIME_Relative epoch_duration
static

Length of an expiration expoch.

Definition at line 135 of file gnunet-service-revocation.c.

Referenced by run(), and verify_revoke_message().

◆ revocation_set_union_app_id

struct GNUNET_HashCode revocation_set_union_app_id
static

Our application ID for set union operations.

Must be the same for all (compatible) peers.

Definition at line 141 of file gnunet-service-revocation.c.

Referenced by run(), and transmit_task_cb().