GNUnet  0.10.x
Data Structures | Functions | Variables
gnunet-service-revocation.c File Reference

key revocation service More...

#include "platform.h"
#include <math.h>
#include "gnunet_util_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_set_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 int 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 void handle_query_message (void *cls, const struct QueryMessage *qm)
 Handle QUERY message from client. More...
 
static int do_flood (void *cls, const struct GNUNET_PeerIdentity *target, void *value)
 Flood the given revocation message to all neighbours. More...
 
static int publicize_rm (const struct RevokeMessage *rm)
 Publicize revocation message. More...
 
static void handle_revoke_message (void *cls, const struct RevokeMessage *rm)
 Handle REVOKE message from client. More...
 
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_SET_Element *element, uint64_t current_size, enum GNUNET_SET_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_SET_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_fixed_size(query_message, GNUNET_MESSAGE_TYPE_REVOCATION_QUERY, struct QueryMessage, NULL), GNUNET_MQ_hd_fixed_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_SET_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_SET_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_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:

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 147 of file gnunet-service-revocation.c.

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

Referenced by handle_core_connect(), and handle_revocation_union_request().

148 {
149  struct PeerEntry *peer_entry;
150 
151  peer_entry = GNUNET_new (struct PeerEntry);
152  peer_entry->id = *peer;
155  &peer_entry->id,
156  peer_entry,
158  return peer_entry;
159 }
Per-peer information.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
static struct GNUNET_CONTAINER_MultiPeerMap * peers
Map of all connected peers.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
#define GNUNET_new(type)
Allocate a struct or union of the given type.
There must only be one value per key; storing a value should fail if a value under the same key alrea...
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
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.
struct GNUNET_PeerIdentity id
What is the identity of the peer?
Here is the call graph for this function:
Here is the caller graph for this function:

◆ verify_revoke_message()

static int 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 170 of file gnunet-service-revocation.c.

References GNUNET_break_op, GNUNET_CRYPTO_ecdsa_verify(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NO, GNUNET_OK, GNUNET_REVOCATION_check_pow(), GNUNET_SIGNATURE_PURPOSE_REVOCATION, GNUNET_YES, RevokeMessage::proof_of_work, RevokeMessage::public_key, RevokeMessage::purpose, revocation_work_required, and RevokeMessage::signature.

Referenced by publicize_rm().

171 {
172  if (GNUNET_YES !=
174  rm->proof_of_work,
175  (unsigned int) revocation_work_required))
176  {
178  "Proof of work invalid!\n");
179  GNUNET_break_op (0);
180  return GNUNET_NO;
181  }
182  if (GNUNET_OK !=
184  &rm->purpose,
185  &rm->signature,
186  &rm->public_key))
187  {
188  GNUNET_break_op (0);
189  return GNUNET_NO;
190  }
191  return GNUNET_YES;
192 }
struct GNUNET_CRYPTO_EcdsaSignature signature
Signature confirming revocation.
Definition: revocation.h:101
int GNUNET_CRYPTO_ecdsa_verify(uint32_t purpose, const struct GNUNET_CRYPTO_EccSignaturePurpose *validate, const struct GNUNET_CRYPTO_EcdsaSignature *sig, const struct GNUNET_CRYPTO_EcdsaPublicKey *pub)
Verify ECDSA signature.
Definition: crypto_ecc.c:1048
struct GNUNET_CRYPTO_EccSignaturePurpose purpose
Must have purpose GNUNET_SIGNATURE_PURPOSE_REVOCATION, size expands over the public key...
Definition: revocation.h:107
#define GNUNET_NO
Definition: gnunet_common.h:81
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
uint64_t proof_of_work
Number that causes a hash collision with the public_key.
Definition: revocation.h:96
#define GNUNET_SIGNATURE_PURPOSE_REVOCATION
Signature for confirming a key revocation.
static unsigned long long revocation_work_required
Amount of work required (W-bit collisions) for REVOCATION proofs, in collision-bits.
#define GNUNET_log(kind,...)
struct GNUNET_CRYPTO_EcdsaPublicKey public_key
Key to revoke.
Definition: revocation.h:112
#define GNUNET_YES
Definition: gnunet_common.h:80
int GNUNET_REVOCATION_check_pow(const struct GNUNET_CRYPTO_EcdsaPublicKey *key, uint64_t pow, unsigned int matching_bits)
Check if the given proof-of-work value would be acceptable for revoking the given key...
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 204 of file gnunet-service-revocation.c.

Referenced by run().

207 {
208  return client;
209 }
Here is the caller graph for this function:

◆ 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 220 of file gnunet-service-revocation.c.

References GNUNET_assert.

Referenced by run().

223 {
224  GNUNET_assert (client == app_cls);
225 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
Here is the caller graph for this function:

◆ 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 235 of file gnunet-service-revocation.c.

References env, GNUNET_CONTAINER_multihashmap_contains(), GNUNET_CRYPTO_hash(), GNUNET_ERROR_TYPE_DEBUG, 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_get_mq(), GNUNET_YES, QueryResponseMessage::is_valid, QueryMessage::key, and res.

237 {
238  struct GNUNET_SERVICE_Client *client = cls;
239  struct GNUNET_MQ_Envelope *env;
240  struct QueryResponseMessage *qrm;
241  struct GNUNET_HashCode hc;
242  int res;
243 
244  GNUNET_CRYPTO_hash (&qm->key,
245  sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey),
246  &hc);
248  &hc);
250  (GNUNET_NO == res)
251  ? "Received revocation check for valid key `%s' from client\n"
252  : "Received revocation check for revoked key `%s' from client\n",
253  GNUNET_h2s (&hc));
254  env = GNUNET_MQ_msg (qrm,
256  qrm->is_valid = htonl ((GNUNET_YES == res) ? GNUNET_NO : GNUNET_YES);
258  env);
260 }
struct GNUNET_MQ_Handle * GNUNET_SERVICE_client_get_mq(struct GNUNET_SERVICE_Client *c)
Obtain the message queue of c.
Definition: service.c:2734
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...
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
#define GNUNET_NO
Definition: gnunet_common.h:81
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
int 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)...
Handle to a client that is connected to a service.
Definition: service.c:249
#define GNUNET_MESSAGE_TYPE_REVOCATION_QUERY_RESPONSE
Service to client: answer if key was revoked!
Key revocation response.
Definition: revocation.h:59
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition: crypto_hash.c:44
A 512-bit hashcode.
static int res
uint32_t is_valid
GNUNET_NO if revoked, GNUNET_YES if valid.
Definition: revocation.h:69
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
struct GNUNET_CRYPTO_EcdsaPublicKey key
Key to check.
Definition: revocation.h:51
Public ECC key (always for Curve25519) encoded in a format suitable for network transmission and ECDS...
#define GNUNET_log(kind,...)
#define GNUNET_YES
Definition: gnunet_common.h:80
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:353
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2533
Here is the call graph for this function:

◆ do_flood()

static int 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 272 of file gnunet-service-revocation.c.

References e, GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_log, GNUNET_MESSAGE_TYPE_REVOCATION_REVOKE, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_OK, PeerEntry::mq, and value.

Referenced by publicize_rm().

275 {
276  const struct RevokeMessage *rm = cls;
277  struct PeerEntry *pe = value;
278  struct GNUNET_MQ_Envelope *e;
279  struct RevokeMessage *cp;
280 
281  if (NULL == pe->mq)
282  return GNUNET_OK; /* peer connected to us via SET,
283  but we have no direct CORE
284  connection for flooding */
285  e = GNUNET_MQ_msg (cp,
287  *cp = *rm;
289  "Flooding revocation to `%s'\n",
290  GNUNET_i2s (target));
291  GNUNET_MQ_send (pe->mq,
292  e);
293  return GNUNET_OK;
294 }
Per-peer information.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
static struct Experiment * e
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
#define GNUNET_MESSAGE_TYPE_REVOCATION_REVOKE
Client to service OR peer-to-peer: revoke this key!
Revoke key.
Definition: revocation.h:81
static char * value
Value of the record to add/remove.
struct GNUNET_MQ_Handle * mq
Queue for sending messages to this peer.
#define GNUNET_log(kind,...)
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:353
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
Here is the call graph for this function:
Here is the caller graph for this function:

◆ publicize_rm()

static int 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

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

References GNUNET_SET_Element::data, do_flood(), GNUNET_SET_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_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_SET_add_element(), GNUNET_SYSERR, GNUNET_YES, RevokeMessage::header, RevokeMessage::public_key, GNUNET_SET_Element::size, GNUNET_MessageHeader::size, and verify_revoke_message().

Referenced by handle_p2p_revoke(), and handle_revoke_message().

308 {
309  struct RevokeMessage *cp;
310  struct GNUNET_HashCode hc;
311  struct GNUNET_SET_Element e;
312 
314  sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey),
315  &hc);
316  if (GNUNET_YES ==
318  &hc))
319  {
321  "Duplicate revocation received from peer. Ignored.\n");
322  return GNUNET_OK;
323  }
324  if (GNUNET_OK !=
326  {
327  GNUNET_break_op (0);
328  return GNUNET_SYSERR;
329  }
330  /* write to disk */
331  if (sizeof (struct RevokeMessage) !=
333  rm,
334  sizeof (struct RevokeMessage)))
335  {
337  "write");
338  return GNUNET_NO;
339  }
340  if (GNUNET_OK !=
342  {
344  "sync");
345  return GNUNET_NO;
346  }
347  /* keep copy in memory */
348  cp = (struct RevokeMessage *) GNUNET_copy_message (&rm->header);
351  &hc,
352  cp,
354  /* add to set for future connections */
355  e.size = htons (rm->header.size);
356  e.element_type = GNUNET_BLOCK_TYPE_REVOCATION;
357  e.data = rm;
358  if (GNUNET_OK !=
360  &e,
361  NULL,
362  NULL))
363  {
364  GNUNET_break (0);
365  return GNUNET_OK;
366  }
367  else
368  {
370  "Added revocation info to SET\n");
371  }
372  /* flood to neighbours */
374  &do_flood,
375  cp);
376  return GNUNET_OK;
377 }
int GNUNET_DISK_file_sync(const struct GNUNET_DISK_FileHandle *h)
Write file changes to disk.
Definition: disk.c:2133
static int do_flood(void *cls, const struct GNUNET_PeerIdentity *target, void *value)
Flood the given revocation message to all neighbours.
int GNUNET_SET_add_element(struct GNUNET_SET_Handle *set, const struct GNUNET_SET_Element *element, GNUNET_SET_Continuation cont, void *cont_cls)
Add an element to the given set.
Definition: set_api.c:686
static int verify_revoke_message(const struct RevokeMessage *rm)
An revoke message has been received, check that it is well-formed.
Element stored in a set.
Block type for a revocation message by which a key is revoked.
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...
static struct GNUNET_CONTAINER_MultiPeerMap * peers
Map of all connected peers.
static struct Experiment * e
#define GNUNET_NO
Definition: gnunet_common.h:81
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
int 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)...
static struct GNUNET_DISK_FileHandle * revocation_db
File handle for the revocation database.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
#define GNUNET_log_strerror(level, cmd)
Log an error message at log-level &#39;level&#39; that indicates a failure of the command &#39;cmd&#39; with the mess...
Revoke key.
Definition: revocation.h:81
static struct GNUNET_SET_Handle * revocation_set
Set from all revocations known to us.
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition: crypto_hash.c:44
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:1049
A 512-bit hashcode.
There must only be one value per key; storing a value should fail if a value under the same key alrea...
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
int 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.
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_REVOCATION_REVOKE.
Definition: revocation.h:86
int GNUNET_CONTAINER_multipeermap_iterate(struct GNUNET_CONTAINER_MultiPeerMap *map, GNUNET_CONTAINER_PeerMapIterator it, void *it_cls)
Iterate over all entries in the map.
Public ECC key (always for Curve25519) encoded in a format suitable for network transmission and ECDS...
#define GNUNET_log(kind,...)
struct GNUNET_CRYPTO_EcdsaPublicKey public_key
Key to revoke.
Definition: revocation.h:112
#define GNUNET_YES
Definition: gnunet_common.h:80
struct GNUNET_MessageHeader * GNUNET_copy_message(const struct GNUNET_MessageHeader *msg)
Create a copy of the given message.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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 387 of file gnunet-service-revocation.c.

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.

389 {
390  struct GNUNET_SERVICE_Client *client = cls;
391  struct GNUNET_MQ_Envelope *env;
392  struct RevocationResponseMessage *rrm;
393  int ret;
394 
396  "Received REVOKE message from client\n");
397  if (GNUNET_SYSERR == (ret = publicize_rm (rm)))
398  {
399  GNUNET_break_op (0);
401  return;
402  }
403  env = GNUNET_MQ_msg (rrm,
405  rrm->is_valid = htonl ((GNUNET_OK == ret) ? GNUNET_NO : GNUNET_YES);
407  env);
409 }
struct GNUNET_MQ_Handle * GNUNET_SERVICE_client_get_mq(struct GNUNET_SERVICE_Client *c)
Obtain the message queue of c.
Definition: service.c:2734
static int publicize_rm(const struct RevokeMessage *rm)
Publicize revocation message.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
#define GNUNET_NO
Definition: gnunet_common.h:81
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
static int ret
Final status code.
Definition: gnunet-arm.c:89
Handle to a client that is connected to a service.
Definition: service.c:249
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
#define GNUNET_MESSAGE_TYPE_REVOCATION_REVOKE_RESPONSE
Service to client: revocation confirmed.
void GNUNET_SERVICE_client_drop(struct GNUNET_SERVICE_Client *c)
Ask the server to disconnect from the given client.
Definition: service.c:2618
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
Key revocation response.
Definition: revocation.h:120
#define GNUNET_log(kind,...)
#define GNUNET_YES
Definition: gnunet_common.h:80
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:353
uint32_t is_valid
GNUNET_NO if revocation failed for internal reasons (e.g.
Definition: revocation.h:131
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2533
Here is the call graph for this function:

◆ 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 419 of file gnunet-service-revocation.c.

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

Referenced by add_revocation().

421 {
423  "Received REVOKE message\n");
425  publicize_rm (rm));
426 }
static int publicize_rm(const struct RevokeMessage *rm)
Publicize revocation message.
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
#define GNUNET_log(kind,...)
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_SET_Element element,
uint64_t  current_size,
enum GNUNET_SET_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_SET_STATUS_OK
current_sizecurrent set size
statussee enum GNUNET_SET_Status

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

References _, GNUNET_SET_Element::data, GNUNET_SET_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_SET_STATUS_DONE, GNUNET_SET_STATUS_FAILURE, GNUNET_SET_STATUS_HALF_DONE, GNUNET_SET_STATUS_OK, GNUNET_STATISTICS_update(), handle_p2p_revoke(), PeerEntry::id, GNUNET_SET_Element::size, and PeerEntry::so.

Referenced by handle_revocation_union_request().

444 {
445  struct PeerEntry *peer_entry = cls;
446  const struct RevokeMessage *rm;
447 
448  switch (status)
449  {
451  if (element->size != sizeof (struct RevokeMessage))
452  {
453  GNUNET_break_op (0);
454  return;
455  }
457  {
459  gettext_noop ("# unsupported revocations received via set union"),
460  1,
461  GNUNET_NO);
462  return;
463  }
464  rm = element->data;
465  (void) handle_p2p_revoke (NULL,
466  rm);
468  gettext_noop ("# revocation messages received via set union"),
469  1, GNUNET_NO);
470  break;
473  _("Error computing revocation set union with %s\n"),
474  GNUNET_i2s (&peer_entry->id));
475  peer_entry->so = NULL;
477  gettext_noop ("# revocation set unions failed"),
478  1,
479  GNUNET_NO);
480  break;
482  break;
484  peer_entry->so = NULL;
486  gettext_noop ("# revocation set unions completed"),
487  1,
488  GNUNET_NO);
489  break;
490  default:
491  GNUNET_break (0);
492  break;
493  }
494 }
static void handle_p2p_revoke(void *cls, const struct RevokeMessage *rm)
Core handler for flooded revocation messages.
Per-peer information.
struct GNUNET_SET_OperationHandle * so
Handle to active set union operation (over revocation sets).
Block type for a revocation message by which a key is revoked.
#define GNUNET_NO
Definition: gnunet_common.h:81
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
Success, all elements have been sent (and received).
static struct GNUNET_STATISTICS_Handle * stats
Handle to the statistics service.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
const void * data
Actual data of the element.
#define _(String)
GNU gettext support macro.
Definition: platform.h:208
Revoke key.
Definition: revocation.h:81
The other peer refused to to the operation with us, or something went wrong.
Success, all elements have been returned (but the other peer might still be receiving some from us...
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
Everything went ok, we are transmitting an element of the result (in set, or to be removed from set...
uint16_t status
See PRISM_STATUS_*-constants.
uint16_t size
Number of bytes in the buffer pointed to by data.
#define GNUNET_log(kind,...)
struct GNUNET_PeerIdentity id
What is the identity of the peer?
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
uint16_t element_type
Application-specific element type.
#define gettext_noop(String)
Definition: gettext.h:69
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 504 of file gnunet-service-revocation.c.

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

Referenced by handle_core_connect().

505 {
506  struct PeerEntry *peer_entry = cls;
507 
509  "Starting set exchange with peer `%s'\n",
510  GNUNET_i2s (&peer_entry->id));
511  peer_entry->transmit_task = NULL;
512  GNUNET_assert (NULL == peer_entry->so);
513  peer_entry->so = GNUNET_SET_prepare (&peer_entry->id,
515  NULL,
517  (struct GNUNET_SET_Option[]) {{ 0 }},
519  peer_entry);
520  if (GNUNET_OK !=
521  GNUNET_SET_commit (peer_entry->so,
523  {
525  _("SET service crashed, terminating revocation service\n"));
527  return;
528  }
529 }
Client gets only elements that have been added to the set.
Per-peer information.
struct GNUNET_SET_OperationHandle * so
Handle to active set union operation (over revocation sets).
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
struct GNUNET_SET_OperationHandle * GNUNET_SET_prepare(const struct GNUNET_PeerIdentity *other_peer, const struct GNUNET_HashCode *app_id, const struct GNUNET_MessageHeader *context_msg, enum GNUNET_SET_ResultMode result_mode, struct GNUNET_SET_Option options[], GNUNET_SET_ResultIterator result_cb, void *result_cls)
Prepare a set operation to be evaluated with another peer.
Definition: set_api.c:812
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:524
#define _(String)
GNU gettext support macro.
Definition: platform.h:208
static struct GNUNET_SET_Handle * revocation_set
Set from all revocations known to us.
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_SET_Element *element, uint64_t current_size, enum GNUNET_SET_Status status)
Callback for set operation results.
Option for set operations.
struct GNUNET_SCHEDULER_Task * transmit_task
Tasked used to trigger the set union operation.
int GNUNET_SET_commit(struct GNUNET_SET_OperationHandle *oh, struct GNUNET_SET_Handle *set)
Commit a set to be used with a set operation.
Definition: set_api.c:1124
#define GNUNET_log(kind,...)
struct GNUNET_PeerIdentity id
What is the identity of the peer?
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
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 540 of file gnunet-service-revocation.c.

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, PeerEntry::mq, my_identity, new_peer_entry(), PeerEntry::transmit_task, and transmit_task_cb().

Referenced by run().

543 {
544  struct PeerEntry *peer_entry;
545  struct GNUNET_HashCode my_hash;
546  struct GNUNET_HashCode peer_hash;
547 
548  if (0 == GNUNET_memcmp (peer,
549  &my_identity))
550  {
551  return NULL;
552  }
553 
555  "Peer `%s' connected to us\n",
556  GNUNET_i2s (peer));
558  "# peers connected",
559  1,
560  GNUNET_NO);
562  peer);
563  if (NULL != peer_entry)
564  {
565  /* This can happen if "core"'s notification is a tad late
566  and CADET+SET were faster and already produced a
567  #handle_revocation_union_request() for us to deal
568  with. This should be rare, but isn't impossible. */
569  peer_entry->mq = mq;
570  return peer_entry;
571  }
572  peer_entry = new_peer_entry (peer);
573  peer_entry->mq = mq;
575  sizeof (my_identity),
576  &my_hash);
577  GNUNET_CRYPTO_hash (peer,
578  sizeof (*peer),
579  &peer_hash);
580  if (0 < GNUNET_CRYPTO_hash_cmp (&my_hash,
581  &peer_hash))
582  {
584  "Starting SET operation with peer `%s'\n",
585  GNUNET_i2s (peer));
586  peer_entry->transmit_task =
589  peer_entry);
590  }
591  return peer_entry;
592 }
Per-peer information.
#define GNUNET_TIME_UNIT_SECONDS
One second.
static struct GNUNET_CONTAINER_MultiPeerMap * peers
Map of all connected peers.
#define GNUNET_NO
Definition: gnunet_common.h:81
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
static struct GNUNET_STATISTICS_Handle * stats
Handle to the statistics service.
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.
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:1246
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition: crypto_hash.c:44
A 512-bit hashcode.
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.
struct GNUNET_MQ_Handle * mq
Queue for sending messages to this peer.
struct GNUNET_SCHEDULER_Task * transmit_task
Tasked used to trigger the set union operation.
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:278
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.
struct GNUNET_MQ_Handle * mq
Definition: 003.c:5
#define GNUNET_log(kind,...)
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
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 604 of file gnunet-service-revocation.c.

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_SET_operation_cancel(), GNUNET_STATISTICS_update(), GNUNET_YES, my_identity, PeerEntry::so, and PeerEntry::transmit_task.

Referenced by run().

607 {
608  struct PeerEntry *peer_entry = internal_cls;
609 
610  if (0 == GNUNET_memcmp (peer,
611  &my_identity))
612  return;
613  GNUNET_assert (NULL != peer_entry);
615  "Peer `%s' disconnected from us\n",
616  GNUNET_i2s (peer));
619  peer,
620  peer_entry));
621  if (NULL != peer_entry->transmit_task)
622  {
624  peer_entry->transmit_task = NULL;
625  }
626  if (NULL != peer_entry->so)
627  {
628  GNUNET_SET_operation_cancel (peer_entry->so);
629  peer_entry->so = NULL;
630  }
631  GNUNET_free (peer_entry);
633  "# peers connected",
634  -1,
635  GNUNET_NO);
636 }
Per-peer information.
struct GNUNET_SET_OperationHandle * so
Handle to active set union operation (over revocation sets).
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
static struct GNUNET_CONTAINER_MultiPeerMap * peers
Map of all connected peers.
int 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_NO
Definition: gnunet_common.h:81
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
static struct GNUNET_STATISTICS_Handle * stats
Handle to the statistics service.
static struct GNUNET_PeerIdentity my_identity
The peer identity of this peer.
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.
struct GNUNET_SCHEDULER_Task * transmit_task
Tasked used to trigger the set union operation.
#define GNUNET_log(kind,...)
void GNUNET_SET_operation_cancel(struct GNUNET_SET_OperationHandle *oh)
Cancel the given set operation.
Definition: set_api.c:515
#define GNUNET_YES
Definition: gnunet_common.h:80
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#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:965
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 648 of file gnunet-service-revocation.c.

References GNUNET_free, and GNUNET_OK.

Referenced by shutdown_task().

651 {
652  GNUNET_free (value);
653  return GNUNET_OK;
654 }
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
static char * value
Value of the record to add/remove.
#define GNUNET_free(ptr)
Wrapper around free.
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 663 of file gnunet-service-revocation.c.

References free_entry(), GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_CONTAINER_multipeermap_destroy(), GNUNET_CORE_disconnect(), GNUNET_DISK_file_close(), GNUNET_NO, GNUNET_SET_destroy(), GNUNET_SET_listen_cancel(), and GNUNET_STATISTICS_destroy().

Referenced by run().

664 {
665  if (NULL != revocation_set)
666  {
668  revocation_set = NULL;
669  }
670  if (NULL != revocation_union_listen_handle)
671  {
674  }
675  if (NULL != core_api)
676  {
678  core_api = NULL;
679  }
680  if (NULL != stats)
681  {
683  stats = NULL;
684  }
685  if (NULL != peers)
686  {
688  peers = NULL;
689  }
690  if (NULL != revocation_db)
691  {
693  revocation_db = NULL;
694  }
696  &free_entry,
697  NULL);
699 }
int GNUNET_DISK_file_close(struct GNUNET_DISK_FileHandle *h)
Close an open file.
Definition: disk.c:1817
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...
static struct GNUNET_CONTAINER_MultiPeerMap * peers
Map of all connected peers.
#define GNUNET_NO
Definition: gnunet_common.h:81
static struct GNUNET_DISK_FileHandle * revocation_db
File handle for the revocation database.
void GNUNET_STATISTICS_destroy(struct GNUNET_STATISTICS_Handle *h, int sync_first)
Destroy a handle (free all state associated with it).
static int free_entry(void *cls, const struct GNUNET_HashCode *key, void *value)
Free all values in a hash map.
static struct GNUNET_STATISTICS_Handle * stats
Handle to the statistics service.
void GNUNET_CONTAINER_multipeermap_destroy(struct GNUNET_CONTAINER_MultiPeerMap *map)
Destroy a hash map.
void GNUNET_SET_destroy(struct GNUNET_SET_Handle *set)
Destroy the set handle, and free all associated resources.
Definition: set_api.c:771
static struct GNUNET_SET_Handle * revocation_set
Set from all revocations known to us.
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
void GNUNET_CORE_disconnect(struct GNUNET_CORE_Handle *handle)
Disconnect from the core service.
Definition: core_api.c:732
void GNUNET_SET_listen_cancel(struct GNUNET_SET_ListenHandle *lh)
Cancel the given listen operation.
Definition: set_api.c:1047
static struct GNUNET_SET_ListenHandle * revocation_union_listen_handle
Handle for us listening to incoming revocation set union requests.
static struct GNUNET_CORE_Handle * core_api
Handle to the core service (for flooding)
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MulitHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
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 709 of file gnunet-service-revocation.c.

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

Referenced by run().

711 {
712  if (NULL == identity)
713  {
715  "Connection to core FAILED!\n");
717  return;
718  }
720 }
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:524
static struct GNUNET_PeerIdentity my_identity
The peer identity of this peer.
static struct GNUNET_IDENTITY_Handle * identity
Which namespace do we publish to? NULL if we do not publish to a namespace.
#define GNUNET_log(kind,...)
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_SET_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_SET_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, whith sometimes can be derived from the context message. It's necessary to specify the timeout.

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

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_SET_accept(), GNUNET_SET_commit(), GNUNET_SET_RESULT_ADDED, new_peer_entry(), and PeerEntry::so.

Referenced by run().

743 {
744  struct PeerEntry *peer_entry;
745 
746  if (NULL == request)
747  {
748  GNUNET_break (0);
749  return;
750  }
752  "Received set exchange request from peer `%s'\n",
753  GNUNET_i2s (other_peer));
755  other_peer);
756  if (NULL == peer_entry)
757  {
758  peer_entry = new_peer_entry (other_peer);
759  }
760  if (NULL != peer_entry->so)
761  {
762  GNUNET_break_op (0);
763  return;
764  }
765  peer_entry->so = GNUNET_SET_accept (request,
767  (struct GNUNET_SET_Option[]) {{ 0 }},
769  peer_entry);
770  if (GNUNET_OK !=
771  GNUNET_SET_commit (peer_entry->so,
773  {
774  GNUNET_break (0);
776  return;
777  }
778 }
Client gets only elements that have been added to the set.
Per-peer information.
struct GNUNET_SET_OperationHandle * so
Handle to active set union operation (over revocation sets).
static struct GNUNET_CONTAINER_MultiPeerMap * peers
Map of all connected peers.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:524
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
static struct GNUNET_SET_Handle * revocation_set
Set from all revocations known to us.
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
static void add_revocation(void *cls, const struct GNUNET_SET_Element *element, uint64_t current_size, enum GNUNET_SET_Status status)
Callback for set operation results.
Option for set operations.
int GNUNET_SET_commit(struct GNUNET_SET_OperationHandle *oh, struct GNUNET_SET_Handle *set)
Commit a set to be used with a set operation.
Definition: set_api.c:1124
static struct PeerEntry * new_peer_entry(const struct GNUNET_PeerIdentity *peer)
Create a new PeerEntry and add it to the peers multipeermap.
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_log(kind,...)
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
struct GNUNET_SET_OperationHandle * GNUNET_SET_accept(struct GNUNET_SET_Request *request, enum GNUNET_SET_ResultMode result_mode, struct GNUNET_SET_Option options[], GNUNET_SET_ResultIterator result_cb, void *result_cls)
Accept a request we got via GNUNET_SET_listen().
Definition: set_api.c:1081
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 789 of file gnunet-service-revocation.c.

References _, __attribute__, client_connect_cb(), client_disconnect_cb(), core_init(), fn, GNUNET_break, GNUNET_CONFIGURATION_get_value_filename(), GNUNET_CONFIGURATION_get_value_number(), GNUNET_CONTAINER_multihashmap_create(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY, GNUNET_CONTAINER_multipeermap_create(), GNUNET_CORE_connect(), GNUNET_CRYPTO_hash(), 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_QUERY, GNUNET_MESSAGE_TYPE_REVOCATION_REVOKE, GNUNET_MQ_handler_end, GNUNET_MQ_hd_fixed_size, GNUNET_new, GNUNET_NO, GNUNET_OK, GNUNET_SCHEDULER_add_shutdown(), GNUNET_SCHEDULER_shutdown(), GNUNET_SERVICE_MAIN(), GNUNET_SERVICE_OPTION_NONE, GNUNET_SET_create(), GNUNET_SET_listen(), GNUNET_SET_OPERATION_UNION, GNUNET_STATISTICS_create(), GNUNET_YES, handle_core_connect(), handle_core_disconnect(), handle_revocation_union_request(), RevokeMessage::public_key, RevokeMessage::reserved, revocation_set_union_app_id, revocation_work_required, and shutdown_task().

792 {
793  struct GNUNET_MQ_MessageHandler core_handlers[] = {
794  GNUNET_MQ_hd_fixed_size (p2p_revoke,
796  struct RevokeMessage,
797  NULL),
799  };
800  char *fn;
801  uint64_t left;
802  struct RevokeMessage *rm;
803  struct GNUNET_HashCode hc;
804 
805  GNUNET_CRYPTO_hash ("revocation-set-union-application-id",
806  strlen ("revocation-set-union-application-id"),
808  if (GNUNET_OK !=
810  "REVOCATION",
811  "DATABASE",
812  &fn))
813  {
815  "REVOCATION",
816  "DATABASE");
818  return;
819  }
820  cfg = c;
822  GNUNET_NO);
823  if (GNUNET_OK !=
825  "REVOCATION",
826  "WORKBITS",
828  {
830  "REVOCATION",
831  "WORKBITS");
833  GNUNET_free (fn);
834  return;
835  }
836  if (revocation_work_required >= sizeof (struct GNUNET_HashCode) * 8)
837  {
839  "REVOCATION",
840  "WORKBITS",
841  _("Value is too large.\n"));
843  GNUNET_free (fn);
844  return;
845  }
853  NULL);
860  if (NULL == revocation_db)
861  {
863  "REVOCATION",
864  "DATABASE",
865  _("Could not open revocation database file!"));
867  GNUNET_free (fn);
868  return;
869  }
870  if (GNUNET_OK !=
872  left = 0;
873  while (left > sizeof (struct RevokeMessage))
874  {
875  rm = GNUNET_new (struct RevokeMessage);
876  if (sizeof (struct RevokeMessage) !=
878  rm,
879  sizeof (struct RevokeMessage)))
880  {
882  "read",
883  fn);
884  GNUNET_free (rm);
886  GNUNET_free (fn);
887  return;
888  }
889  GNUNET_break (0 == ntohl (rm->reserved));
891  sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey),
892  &hc);
895  &hc,
896  rm,
898  }
899  GNUNET_free (fn);
900 
902  NULL);
904  GNUNET_YES);
905  /* Connect to core service and register core handlers */
906  core_api = GNUNET_CORE_connect (cfg, /* Main configuration */
907  NULL, /* Closure passed to functions */
908  &core_init, /* Call core_init once connected */
909  &handle_core_connect, /* Handle connects */
910  &handle_core_disconnect, /* Handle disconnects */
911  core_handlers); /* Register these handlers */
912  if (NULL == core_api)
913  {
915  return;
916  }
917  stats = GNUNET_STATISTICS_create ("revocation",
918  cfg);
919 }
static void shutdown_task(void *cls)
Task run during shutdown.
struct GNUNET_SET_ListenHandle * GNUNET_SET_listen(const struct GNUNET_CONFIGURATION_Handle *cfg, enum GNUNET_SET_OperationType op_type, const struct GNUNET_HashCode *app_id, GNUNET_SET_ListenCallback listen_cb, void *listen_cls)
Wait for set operation requests for the given application ID.
Definition: set_api.c:1013
Create file if it doesn&#39;t exist.
static void * handle_core_connect(void *cls, const struct GNUNET_PeerIdentity *peer, struct GNUNET_MQ_Handle *mq)
Method called whenever a peer connects.
int 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.
static const struct GNUNET_CONFIGURATION_Handle * cfg
Handle to our current configuration.
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:881
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, or when GNUNET_SCHEDULER_shutdown() is being invoked.
Definition: scheduler.c:1293
struct GNUNET_STATISTICS_Handle * GNUNET_STATISTICS_create(const char *subsystem, const struct GNUNET_CONFIGURATION_Handle *cfg)
Get handle for the statistics service.
struct GNUNET_SET_Handle * GNUNET_SET_create(const struct GNUNET_CONFIGURATION_Handle *cfg, enum GNUNET_SET_OperationType op)
Create an empty set, supporting the specified operation.
Definition: set_api.c:656
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...
static struct GNUNET_CONTAINER_MultiPeerMap * peers
Map of all connected peers.
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
#define GNUNET_NO
Definition: gnunet_common.h:81
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
static void core_init(void *cls, const struct GNUNET_PeerIdentity *identity)
Called on core init/fail.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
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.
static struct GNUNET_DISK_FileHandle * revocation_db
File handle for the revocation database.
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_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:524
#define GNUNET_MESSAGE_TYPE_REVOCATION_REVOKE
Client to service OR peer-to-peer: revoke this key!
static struct GNUNET_STATISTICS_Handle * stats
Handle to the statistics service.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
#define _(String)
GNU gettext support macro.
Definition: platform.h:208
Revoke key.
Definition: revocation.h:81
void GNUNET_log_config_missing(enum GNUNET_ErrorType kind, const char *section, const char *option)
Log error message about missing configuration option.
static struct GNUNET_SET_Handle * revocation_set
Set from all revocations known to us.
#define GNUNET_log_strerror_file(level, cmd, filename)
Log an error message at log-level &#39;level&#39; that indicates a failure of the command &#39;cmd&#39; with the mess...
static char * fn
Filename of the unique file.
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition: crypto_hash.c:44
A 512-bit hashcode.
Message handler for a specific message type.
static struct GNUNET_HashCode revocation_set_union_app_id
Our application ID for set union operations.
There must only be one value per key; storing a value should fail if a value under the same key alrea...
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:694
int 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.
int 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:289
Everybody can read.
static unsigned long long revocation_work_required
Amount of work required (W-bit collisions) for REVOCATION proofs, in collision-bits.
static void handle_revocation_union_request(void *cls, const struct GNUNET_PeerIdentity *other_peer, const struct GNUNET_MessageHeader *context_msg, struct GNUNET_SET_Request *request)
Called when another peer wants to do a set operation with the local peer.
Public ECC key (always for Curve25519) encoded in a format suitable for network transmission and ECDS...
Open the file for both reading and writing.
static void handle_core_disconnect(void *cls, const struct GNUNET_PeerIdentity *peer, void *internal_cls)
Method called whenever a peer disconnects.
int 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.
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
static struct GNUNET_SET_ListenHandle * revocation_union_listen_handle
Handle for us listening to incoming revocation set union requests.
static struct GNUNET_CORE_Handle * core_api
Handle to the core service (for flooding)
struct GNUNET_CRYPTO_EcdsaPublicKey public_key
Key to revoke.
Definition: revocation.h:112
#define GNUNET_YES
Definition: gnunet_common.h:80
Set union, return all elements that are in at least one of the sets.
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:1673
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
#define GNUNET_free(ptr)
Wrapper around free.
uint32_t reserved
For alignment.
Definition: revocation.h:91
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_fixed_size(query_message, GNUNET_MESSAGE_TYPE_REVOCATION_QUERY, struct QueryMessage, NULL)  ,
GNUNET_MQ_hd_fixed_size(revoke_message, GNUNET_MESSAGE_TYPE_REVOCATION_REVOKE, struct RevokeMessage, NULL)  ,
GNUNET_MQ_handler_end()   
)

Define "main" method using service macro.

Referenced by run().

Here is the caller graph for this function:

Variable Documentation

◆ revocation_set

struct GNUNET_SET_Handle* revocation_set
static

Set from all revocations known to us.

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

◆ 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 91 of file gnunet-service-revocation.c.

◆ cfg

const struct GNUNET_CONFIGURATION_Handle* cfg
static

Handle to our current configuration.

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

◆ stats

struct GNUNET_STATISTICS_Handle* stats
static

Handle to the statistics service.

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

◆ core_api

struct GNUNET_CORE_Handle* core_api
static

Handle to the core service (for flooding)

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

◆ peers

struct GNUNET_CONTAINER_MultiPeerMap* peers
static

Map of all connected peers.

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

◆ my_identity

struct GNUNET_PeerIdentity my_identity
static

The peer identity of this peer.

Definition at line 116 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 121 of file gnunet-service-revocation.c.

◆ revocation_union_listen_handle

struct GNUNET_SET_ListenHandle* revocation_union_listen_handle
static

Handle for us listening to incoming revocation set union requests.

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

◆ 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 131 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 137 of file gnunet-service-revocation.c.

Referenced by run(), and transmit_task_cb().