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

tool for revoking public keys More...

#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_revocation_service.h"
#include "gnunet_identity_service.h"
Include dependency graph for gnunet-revocation.c:

Go to the source code of this file.

Data Structures

struct  RevocationData
 Data needed to perform a revocation. More...
 

Functions

static void do_shutdown (void *cls)
 Function run if the user aborts with CTRL-C. More...
 
static void print_query_result (void *cls, int is_valid)
 Print the result from a revocation query. More...
 
static void print_revocation_result (void *cls, int is_valid)
 Print the result from a revocation request. More...
 
static void perform_revocation (const struct RevocationData *rd)
 Perform the revocation. More...
 
static void sync_rd (const struct RevocationData *rd)
 Write the current state of the revocation data to disk. More...
 
static void calculate_pow_shutdown (void *cls)
 Perform the proof-of-work calculation. More...
 
static void calculate_pow (void *cls)
 Perform the proof-of-work calculation. More...
 
static void ego_callback (void *cls, const struct GNUNET_IDENTITY_Ego *ego)
 Function called with the result from the ego lookup. More...
 
static void run (void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c)
 Main function that will be run by the scheduler. More...
 
int main (int argc, char *const *argv)
 The main function of gnunet-revocation. More...
 

Variables

static int ret
 Final status code. More...
 
static int perform
 Was "-p" specified? More...
 
static char * filename
 -f option. More...
 
static char * revoke_ego
 -R option More...
 
static char * test_ego
 -t option. More...
 
static struct GNUNET_REVOCATION_Queryq
 Handle for revocation query. More...
 
static struct GNUNET_REVOCATION_Handleh
 Handle for revocation. More...
 
static struct GNUNET_IDENTITY_EgoLookupel
 Handle for our ego lookup. More...
 
static const struct GNUNET_CONFIGURATION_Handlecfg
 Our configuration. More...
 
static unsigned long long matching_bits
 Number of matching bits required for revocation. More...
 
static struct GNUNET_SCHEDULER_Taskpow_task
 Task used for proof-of-work calculation. More...
 

Detailed Description

tool for revoking public keys

Author
Christian Grothoff

Definition in file gnunet-revocation.c.

Function Documentation

◆ do_shutdown()

static void do_shutdown ( void *  cls)
static

Function run if the user aborts with CTRL-C.

Parameters
clsclosure

Definition at line 94 of file gnunet-revocation.c.

References GNUNET_IDENTITY_ego_lookup_cancel(), GNUNET_REVOCATION_query_cancel(), and GNUNET_REVOCATION_revoke_cancel().

Referenced by run().

95 {
96  if (NULL != el)
97  {
99  el = NULL;
100  }
101  if (NULL != q)
102  {
104  q = NULL;
105  }
106  if (NULL != h)
107  {
109  h = NULL;
110  }
111 }
static struct GNUNET_IDENTITY_EgoLookup * el
Handle for our ego lookup.
void GNUNET_REVOCATION_query_cancel(struct GNUNET_REVOCATION_Query *q)
Cancel key revocation check.
void GNUNET_IDENTITY_ego_lookup_cancel(struct GNUNET_IDENTITY_EgoLookup *el)
Abort ego lookup attempt.
static struct GNUNET_REVOCATION_Handle * h
Handle for revocation.
static struct GNUNET_REVOCATION_Query * q
Handle for revocation query.
void GNUNET_REVOCATION_revoke_cancel(struct GNUNET_REVOCATION_Handle *h)
Cancel key revocation.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ print_query_result()

static void print_query_result ( void *  cls,
int  is_valid 
)
static

Print the result from a revocation query.

Parameters
clsNULL
is_validGNUNET_YES if the key is still valid, GNUNET_NO if not, GNUNET_SYSERR on error

Definition at line 121 of file gnunet-revocation.c.

References _, FPRINTF, GNUNET_break, GNUNET_NO, GNUNET_SCHEDULER_shutdown(), GNUNET_SYSERR, GNUNET_YES, and test_ego.

Referenced by run().

123 {
124  q = NULL;
125  switch (is_valid)
126  {
127  case GNUNET_YES:
128  FPRINTF (stdout,
129  _("Key `%s' is valid\n"),
130  test_ego);
131  break;
132  case GNUNET_NO:
133  FPRINTF (stdout,
134  _("Key `%s' has been revoked\n"),
135  test_ego);
136  break;
137  case GNUNET_SYSERR:
138  FPRINTF (stdout,
139  "%s",
140  _("Internal error\n"));
141  break;
142  default:
143  GNUNET_break (0);
144  break;
145  }
147 }
#define FPRINTF
Definition: plibc.h:683
#define GNUNET_NO
Definition: gnunet_common.h:81
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...
#define _(String)
GNU gettext support macro.
Definition: platform.h:208
static struct GNUNET_REVOCATION_Query * q
Handle for revocation query.
static char * test_ego
-t option.
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
#define GNUNET_YES
Definition: gnunet_common.h:80
Here is the call graph for this function:
Here is the caller graph for this function:

◆ print_revocation_result()

static void print_revocation_result ( void *  cls,
int  is_valid 
)
static

Print the result from a revocation request.

Parameters
clsNULL
is_validGNUNET_YES if the key is still valid, GNUNET_NO if not, GNUNET_SYSERR on error

Definition at line 157 of file gnunet-revocation.c.

References _, FPRINTF, GNUNET_break, GNUNET_NO, GNUNET_SCHEDULER_shutdown(), GNUNET_SYSERR, GNUNET_YES, and revoke_ego.

Referenced by perform_revocation().

159 {
160  h = NULL;
161  switch (is_valid)
162  {
163  case GNUNET_YES:
164  if (NULL != revoke_ego)
165  FPRINTF (stdout,
166  _("Key for ego `%s' is still valid, revocation failed (!)\n"),
167  revoke_ego);
168  else
169  FPRINTF (stdout,
170  "%s",
171  _("Revocation failed (!)\n"));
172  break;
173  case GNUNET_NO:
174  if (NULL != revoke_ego)
175  FPRINTF (stdout,
176  _("Key for ego `%s' has been successfully revoked\n"),
177  revoke_ego);
178  else
179  FPRINTF (stdout,
180  "%s",
181  _("Revocation successful.\n"));
182  break;
183  case GNUNET_SYSERR:
184  FPRINTF (stdout,
185  "%s",
186  _("Internal error, key revocation might have failed\n"));
187  break;
188  default:
189  GNUNET_break (0);
190  break;
191  }
193 }
#define FPRINTF
Definition: plibc.h:683
#define GNUNET_NO
Definition: gnunet_common.h:81
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...
#define _(String)
GNU gettext support macro.
Definition: platform.h:208
static struct GNUNET_REVOCATION_Handle * h
Handle for revocation.
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
static char * revoke_ego
-R option
#define GNUNET_YES
Definition: gnunet_common.h:80
Here is the call graph for this function:
Here is the caller graph for this function:

◆ perform_revocation()

static void perform_revocation ( const struct RevocationData rd)
static

Perform the revocation.

Definition at line 222 of file gnunet-revocation.c.

References GNUNET_REVOCATION_revoke(), RevocationData::key, RevocationData::pow, print_revocation_result(), and RevocationData::sig.

Referenced by calculate_pow(), ego_callback(), and run().

223 {
225  &rd->key,
226  &rd->sig,
227  rd->pow,
229  NULL);
230 }
static const struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
struct GNUNET_REVOCATION_Handle * GNUNET_REVOCATION_revoke(const struct GNUNET_CONFIGURATION_Handle *cfg, const struct GNUNET_CRYPTO_EcdsaPublicKey *key, const struct GNUNET_CRYPTO_EcdsaSignature *sig, uint64_t pow, GNUNET_REVOCATION_Callback func, void *func_cls)
Perform key revocation.
struct GNUNET_CRYPTO_EcdsaPublicKey key
Public key.
static struct GNUNET_REVOCATION_Handle * h
Handle for revocation.
uint64_t pow
Proof of work (in NBO).
static void print_revocation_result(void *cls, int is_valid)
Print the result from a revocation request.
struct GNUNET_CRYPTO_EcdsaSignature sig
Revocation signature data.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ sync_rd()

static void sync_rd ( const struct RevocationData rd)
static

Write the current state of the revocation data to disk.

Parameters
rddata to sync

Definition at line 240 of file gnunet-revocation.c.

References filename, GNUNET_DISK_fn_write(), GNUNET_DISK_PERM_USER_READ, GNUNET_DISK_PERM_USER_WRITE, GNUNET_ERROR_TYPE_ERROR, and GNUNET_log_strerror_file.

Referenced by calculate_pow(), and calculate_pow_shutdown().

241 {
242  if ( (NULL != filename) &&
243  (sizeof (struct RevocationData) ==
245  &rd,
246  sizeof (rd),
250  "write",
251  filename);
252 }
static char * filename
-f option.
ssize_t GNUNET_DISK_fn_write(const char *fn, const void *buffer, size_t n, enum GNUNET_DISK_AccessPermissions mode)
Write a buffer to a file.
Definition: disk.c:1203
#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...
Data needed to perform a revocation.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ calculate_pow_shutdown()

static void calculate_pow_shutdown ( void *  cls)
static

Perform the proof-of-work calculation.

Parameters
clsthe struct RevocationData

Definition at line 261 of file gnunet-revocation.c.

References GNUNET_free, GNUNET_SCHEDULER_cancel(), and sync_rd().

Referenced by ego_callback(), and run().

262 {
263  struct RevocationData *rd = cls;
264 
265  if (NULL != pow_task)
266  {
268  pow_task = NULL;
269  }
270  sync_rd (rd);
271  GNUNET_free (rd);
272 }
static void sync_rd(const struct RevocationData *rd)
Write the current state of the revocation data to disk.
static struct GNUNET_SCHEDULER_Task * pow_task
Task used for proof-of-work calculation.
Data needed to perform a revocation.
#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:

◆ calculate_pow()

static void calculate_pow ( void *  cls)
static

Perform the proof-of-work calculation.

Parameters
clsthe struct RevocationData

Definition at line 281 of file gnunet-revocation.c.

References _, filename, FPRINTF, GNUNET_DISK_fn_write(), GNUNET_DISK_PERM_USER_READ, GNUNET_DISK_PERM_USER_WRITE, GNUNET_ERROR_TYPE_ERROR, GNUNET_log_strerror_file, GNUNET_OK, GNUNET_REVOCATION_check_pow(), GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_shutdown(), RevocationData::key, matching_bits, perform, perform_revocation(), RevocationData::pow, revoke_ego, and sync_rd().

Referenced by ego_callback(), and run().

282 {
283  struct RevocationData *rd = cls;
284 
285  /* store temporary results */
286  pow_task = NULL;
287  if (0 == (rd->pow % 128))
288  sync_rd (rd);
289  /* display progress estimate */
290  if ( (0 == ((1 << matching_bits) / 100 / 50)) ||
291  (0 == (rd->pow % ((1 << matching_bits) / 100 / 50))) )
292  FPRINTF (stderr, "%s", ".");
293  if ( (0 != rd->pow) &&
294  ( (0 == ((1 << matching_bits) / 100)) ||
295  (0 == (rd->pow % ((1 << matching_bits) / 100))) ) )
296  FPRINTF (stderr, " - @ %3u%% (estimate)\n",
297  (unsigned int) (rd->pow * 100) / (1 << matching_bits));
298  /* actually do POW calculation */
299  rd->pow++;
300  if (GNUNET_OK ==
302  rd->pow,
303  (unsigned int) matching_bits))
304  {
305  if ( (NULL != filename) &&
306  (sizeof (struct RevocationData) !=
308  rd,
309  sizeof (struct RevocationData),
313  "write",
314  filename);
315  if (perform)
316  {
317  perform_revocation (rd);
318  }
319  else
320  {
321  FPRINTF (stderr, "%s", "\n");
322  FPRINTF (stderr,
323  _("Revocation certificate for `%s' stored in `%s'\n"),
324  revoke_ego,
325  filename);
327  }
328  return;
329  }
331  rd);
332 }
static void sync_rd(const struct RevocationData *rd)
Write the current state of the revocation data to disk.
static char * filename
-f option.
#define FPRINTF
Definition: plibc.h:683
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
struct GNUNET_CRYPTO_EcdsaPublicKey key
Public key.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:524
static struct GNUNET_SCHEDULER_Task * pow_task
Task used for proof-of-work calculation.
ssize_t GNUNET_DISK_fn_write(const char *fn, const void *buffer, size_t n, enum GNUNET_DISK_AccessPermissions mode)
Write a buffer to a file.
Definition: disk.c:1203
#define _(String)
GNU gettext support macro.
Definition: platform.h:208
static void calculate_pow(void *cls)
Perform the proof-of-work calculation.
#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...
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1273
static int perform
Was "-p" specified?
Data needed to perform a revocation.
uint64_t pow
Proof of work (in NBO).
static char * revoke_ego
-R option
static void perform_revocation(const struct RevocationData *rd)
Perform the revocation.
static unsigned long long matching_bits
Number of matching bits required for revocation.
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:

◆ ego_callback()

static void ego_callback ( void *  cls,
const struct GNUNET_IDENTITY_Ego ego 
)
static

Function called with the result from the ego lookup.

Parameters
clsclosure
egothe ego, NULL if not found

Definition at line 342 of file gnunet-revocation.c.

References _, calculate_pow(), calculate_pow_shutdown(), filename, FPRINTF, GNUNET_DISK_file_test(), GNUNET_DISK_fn_read(), GNUNET_free, GNUNET_IDENTITY_ego_get_private_key(), GNUNET_IDENTITY_ego_get_public_key(), GNUNET_memcmp, GNUNET_new, GNUNET_REVOCATION_check_pow(), GNUNET_REVOCATION_sign_revocation(), GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_add_shutdown(), GNUNET_SCHEDULER_shutdown(), GNUNET_YES, RevocationData::key, matching_bits, perform, perform_revocation(), RevocationData::pow, revoke_ego, and RevocationData::sig.

Referenced by run().

344 {
345  struct RevocationData *rd;
347 
348  el = NULL;
349  if (NULL == ego)
350  {
351  FPRINTF (stdout,
352  _("Ego `%s' not found.\n"),
353  revoke_ego);
355  return;
356  }
358  &key);
359  rd = GNUNET_new (struct RevocationData);
360  if ( (NULL != filename) &&
361  (GNUNET_YES ==
363  (sizeof (struct RevocationData) ==
365  rd,
366  sizeof (struct RevocationData))) )
367  {
368  if (0 != GNUNET_memcmp (&rd->key,
369  &key))
370  {
371  fprintf (stderr,
372  _("Error: revocation certificate in `%s' is not for `%s'\n"),
373  filename,
374  revoke_ego);
375  GNUNET_free (rd);
376  return;
377  }
378  }
379  else
380  {
382  &rd->sig);
383  rd->key = key;
384  }
385  if (GNUNET_YES ==
387  rd->pow,
388  (unsigned int) matching_bits))
389  {
390  FPRINTF (stderr,
391  "%s",
392  _("Revocation certificate ready\n"));
393  if (perform)
394  perform_revocation (rd);
395  else
397  GNUNET_free (rd);
398  return;
399  }
400  FPRINTF (stderr,
401  "%s",
402  _("Revocation certificate not ready, calculating proof of work\n"));
404  rd);
406  rd);
407 }
int GNUNET_DISK_file_test(const char *fil)
Check that fil corresponds to a filename (of a file that exists and that is not a directory)...
Definition: disk.c:669
static struct GNUNET_IDENTITY_EgoLookup * el
Handle for our ego lookup.
static char * filename
-f option.
#define FPRINTF
Definition: plibc.h:683
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
void GNUNET_REVOCATION_sign_revocation(const struct GNUNET_CRYPTO_EcdsaPrivateKey *key, struct GNUNET_CRYPTO_EcdsaSignature *sig)
Create a revocation signature.
const struct GNUNET_CRYPTO_EcdsaPrivateKey * GNUNET_IDENTITY_ego_get_private_key(const struct GNUNET_IDENTITY_Ego *ego)
Obtain the ECC key associated with a ego.
Definition: identity_api.c:556
struct GNUNET_CRYPTO_EcdsaPublicKey key
Public key.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:524
static struct GNUNET_SCHEDULER_Task * pow_task
Task used for proof-of-work calculation.
#define _(String)
GNU gettext support macro.
Definition: platform.h:208
static void calculate_pow_shutdown(void *cls)
Perform the proof-of-work calculation.
static void calculate_pow(void *cls)
Perform the proof-of-work calculation.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1273
static int perform
Was "-p" specified?
Data needed to perform a revocation.
struct GNUNET_HashCode key
The key used in the DHT.
void GNUNET_IDENTITY_ego_get_public_key(const struct GNUNET_IDENTITY_Ego *ego, struct GNUNET_CRYPTO_EcdsaPublicKey *pk)
Get the identifier (public key) of an ego.
Definition: identity_api.c:569
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.
uint64_t pow
Proof of work (in NBO).
static char * revoke_ego
-R option
Public ECC key (always for Curve25519) encoded in a format suitable for network transmission and ECDS...
struct GNUNET_CRYPTO_EcdsaSignature sig
Revocation signature data.
static void perform_revocation(const struct RevocationData *rd)
Perform the revocation.
#define GNUNET_YES
Definition: gnunet_common.h:80
static unsigned long long matching_bits
Number of matching bits required for revocation.
ssize_t GNUNET_DISK_fn_read(const char *fn, void *result, size_t len)
Read the contents of a binary file into a buffer.
Definition: disk.c:1019
#define GNUNET_free(ptr)
Wrapper around free.
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:

◆ run()

static void run ( void *  cls,
char *const *  args,
const char *  cfgfile,
const struct GNUNET_CONFIGURATION_Handle c 
)
static

Main function that will be run by the scheduler.

Parameters
clsclosure
argsremaining command-line arguments
cfgfilename of the configuration file used (for saving, can be NULL!)
cconfiguration

Definition at line 419 of file gnunet-revocation.c.

References _, calculate_pow(), calculate_pow_shutdown(), do_shutdown(), ego_callback(), filename, FPRINTF, GNUNET_CONFIGURATION_get_value_number(), GNUNET_CRYPTO_ecdsa_public_key_from_string(), GNUNET_DISK_fn_read(), GNUNET_ERROR_TYPE_ERROR, GNUNET_IDENTITY_ego_lookup(), GNUNET_log_config_missing(), GNUNET_new, GNUNET_OK, GNUNET_REVOCATION_check_pow(), GNUNET_REVOCATION_query(), GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_add_shutdown(), GNUNET_YES, RevocationData::key, matching_bits, perform, perform_revocation(), RevocationData::pow, print_query_result(), revoke_ego, and test_ego.

Referenced by main().

423 {
425  struct RevocationData rd;
426 
427  cfg = c;
428  if (NULL != test_ego)
429  {
430  if (GNUNET_OK !=
432  strlen (test_ego),
433  &pk))
434  {
435  FPRINTF (stderr,
436  _("Public key `%s' malformed\n"),
437  test_ego);
438  return;
439  }
441  NULL);
442  q = GNUNET_REVOCATION_query (cfg,
443  &pk,
445  NULL);
446  if (NULL != revoke_ego)
447  FPRINTF (stderr,
448  "%s",
449  _("Testing and revoking at the same time is not allowed, only executing test.\n"));
450  return;
451  }
452  if (GNUNET_OK !=
454  "REVOCATION",
455  "WORKBITS",
456  &matching_bits))
457  {
459  "REVOCATION",
460  "WORKBITS");
461  return;
462  }
463  if (NULL != revoke_ego)
464  {
465  if ( !perform && (NULL == filename) )
466  {
467  FPRINTF (stderr,
468  "%s",
469  _("No filename to store revocation certificate given.\n"));
470  return;
471  }
472  /* main code here */
474  revoke_ego,
475  &ego_callback,
476  NULL);
478  NULL);
479  return;
480  }
481  if ( (NULL != filename) &&
482  (perform) )
483  {
484  if (sizeof (rd) !=
486  &rd,
487  sizeof (rd)))
488  {
489  fprintf (stderr,
490  _("Failed to read revocation certificate from `%s'\n"),
491  filename);
492  return;
493  }
495  NULL);
496  if (GNUNET_YES !=
498  rd.pow,
499  (unsigned int) matching_bits))
500  {
501  struct RevocationData *cp = GNUNET_new (struct RevocationData);
502 
503  *cp = rd;
505  cp);
507  cp);
508  return;
509  }
510  perform_revocation (&rd);
511  return;
512  }
513  FPRINTF (stderr,
514  "%s",
515  _("No action specified. Nothing to do.\n"));
516 }
static struct GNUNET_IDENTITY_EgoLookup * el
Handle for our ego lookup.
static struct GNUNET_CRYPTO_EddsaPrivateKey * pk
Private key of this peer.
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
Our configuration.
static char * filename
-f option.
#define FPRINTF
Definition: plibc.h:683
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
static void ego_callback(void *cls, const struct GNUNET_IDENTITY_Ego *ego)
Function called with the result from the ego lookup.
#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.
static void print_query_result(void *cls, int is_valid)
Print the result from a revocation query.
static struct GNUNET_SCHEDULER_Task * pow_task
Task used for proof-of-work calculation.
#define _(String)
GNU gettext support macro.
Definition: platform.h:208
void GNUNET_log_config_missing(enum GNUNET_ErrorType kind, const char *section, const char *option)
Log error message about missing configuration option.
static void calculate_pow_shutdown(void *cls)
Perform the proof-of-work calculation.
static void calculate_pow(void *cls)
Perform the proof-of-work calculation.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1273
static int perform
Was "-p" specified?
Data needed to perform a revocation.
static void do_shutdown(void *cls)
Function run if the user aborts with CTRL-C.
static struct GNUNET_REVOCATION_Query * q
Handle for revocation query.
static char * test_ego
-t option.
struct GNUNET_IDENTITY_EgoLookup * GNUNET_IDENTITY_ego_lookup(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *name, GNUNET_IDENTITY_EgoCallback cb, void *cb_cls)
Lookup an ego by name.
int GNUNET_CRYPTO_ecdsa_public_key_from_string(const char *enc, size_t enclen, struct GNUNET_CRYPTO_EcdsaPublicKey *pub)
Convert a string representing a public key to a public key.
Definition: crypto_ecc.c:468
static char * revoke_ego
-R option
Public ECC key (always for Curve25519) encoded in a format suitable for network transmission and ECDS...
struct GNUNET_REVOCATION_Query * GNUNET_REVOCATION_query(const struct GNUNET_CONFIGURATION_Handle *cfg, const struct GNUNET_CRYPTO_EcdsaPublicKey *key, GNUNET_REVOCATION_Callback func, void *func_cls)
Check if a key was revoked.
static void perform_revocation(const struct RevocationData *rd)
Perform the revocation.
#define GNUNET_YES
Definition: gnunet_common.h:80
static unsigned long long matching_bits
Number of matching bits required for revocation.
ssize_t GNUNET_DISK_fn_read(const char *fn, void *result, size_t len)
Read the contents of a binary file into a buffer.
Definition: disk.c:1019
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:

◆ main()

int main ( int  argc,
char *const *  argv 
)

The main function of gnunet-revocation.

Parameters
argcnumber of arguments from the command line
argvcommand line arguments
Returns
0 ok, 1 on error

Definition at line 527 of file gnunet-revocation.c.

References filename, gettext_noop, GNUNET_free, GNUNET_GETOPT_OPTION_END, GNUNET_GETOPT_option_flag(), GNUNET_GETOPT_option_string(), GNUNET_OK, GNUNET_PROGRAM_run(), GNUNET_STRINGS_get_utf8_args(), perform, ret, revoke_ego, run(), and test_ego.

528 {
530 
532  "filename",
533  "NAME",
534  gettext_noop ("use NAME for the name of the revocation file"),
535  &filename),
536 
538  "revoke",
539  "NAME",
540  gettext_noop ("revoke the private key associated for the the private key associated with the ego NAME "),
541  &revoke_ego),
542 
544  "perform",
545  gettext_noop ("actually perform revocation, otherwise we just do the precomputation"),
546  &perform),
547 
549  "test",
550  "KEY",
551  gettext_noop ("test if the public key KEY has been revoked"),
552  &test_ego),
553 
555  };
556  if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
557  return 2;
558 
559  ret = (GNUNET_OK ==
560  GNUNET_PROGRAM_run (argc, argv, "gnunet-revocation",
561  gettext_noop ("help text"), options, &run,
562  NULL)) ? ret : 1;
563  GNUNET_free ((void*) argv);
564  return ret;
565 }
static char * filename
-f option.
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
static int ret
Final status code.
int GNUNET_STRINGS_get_utf8_args(int argc, char *const *argv, int *u8argc, char *const **u8argv)
Returns utf-8 encoded arguments.
Definition: strings.c:1521
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
Definition of a command line option.
static void run(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c)
Main function that will be run by the scheduler.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_OPTION_END
Definition: 002.c:13
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_string(char shortName, const char *name, const char *argumentHelp, const char *description, char **str)
Allow user to specify a string.
static int perform
Was "-p" specified?
static char * test_ego
-t option.
static char * revoke_ego
-R option
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_flag(char shortName, const char *name, const char *description, int *val)
Allow user to specify a flag (which internally means setting an integer to 1/GNUNET_YES/GNUNET_OK.
int GNUNET_PROGRAM_run(int argc, char *const *argv, const char *binaryName, const char *binaryHelp, const struct GNUNET_GETOPT_CommandLineOption *options, GNUNET_PROGRAM_Main task, void *task_cls)
Run a standard GNUnet command startup sequence (initialize loggers and configuration, parse options).
Definition: program.c:361
#define GNUNET_free(ptr)
Wrapper around free.
#define gettext_noop(String)
Definition: gettext.h:69
Here is the call graph for this function:

Variable Documentation

◆ ret

int ret
static

Final status code.

Definition at line 35 of file gnunet-revocation.c.

Referenced by main().

◆ perform

int perform
static

Was "-p" specified?

Definition at line 40 of file gnunet-revocation.c.

Referenced by calculate_pow(), ego_callback(), main(), and run().

◆ filename

char* filename
static

-f option.

Definition at line 45 of file gnunet-revocation.c.

Referenced by calculate_pow(), ego_callback(), main(), run(), and sync_rd().

◆ revoke_ego

char* revoke_ego
static

-R option

Definition at line 50 of file gnunet-revocation.c.

Referenced by calculate_pow(), ego_callback(), main(), print_revocation_result(), and run().

◆ test_ego

char* test_ego
static

-t option.

Definition at line 55 of file gnunet-revocation.c.

Referenced by main(), print_query_result(), and run().

◆ q

struct GNUNET_REVOCATION_Query* q
static

◆ h

struct GNUNET_REVOCATION_Handle* h
static

Handle for revocation.

Definition at line 65 of file gnunet-revocation.c.

◆ el

struct GNUNET_IDENTITY_EgoLookup* el
static

Handle for our ego lookup.

Definition at line 70 of file gnunet-revocation.c.

◆ cfg

const struct GNUNET_CONFIGURATION_Handle* cfg
static

Our configuration.

Definition at line 75 of file gnunet-revocation.c.

◆ matching_bits

unsigned long long matching_bits
static

◆ pow_task

struct GNUNET_SCHEDULER_Task* pow_task
static

Task used for proof-of-work calculation.

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