GNUnet  0.11.x
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.

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 ()
 Perform the revocation. More...
 
static void sync_pow ()
 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, 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 unsigned int pow_passes = 1
 Pow passes. More...
 
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 unsigned int epochs = 1
 -e 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_TIME_Relative epoch_duration
 Epoch length. More...
 
static struct GNUNET_SCHEDULER_Taskpow_task
 Task used for proof-of-work calculation. More...
 
static struct GNUNET_REVOCATION_PowPproof_of_work
 Proof-of-work object. 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 112 of file gnunet-revocation.c.

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

Referenced by run().

113 {
114  fprintf (stderr, "%s", _ ("Shutting down...\n"));
115  if (NULL != el)
116  {
118  el = NULL;
119  }
120  if (NULL != q)
121  {
123  q = NULL;
124  }
125  if (NULL != h)
126  {
128  h = NULL;
129  }
130 }
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.
#define _(String)
GNU gettext support macro.
Definition: platform.h:178
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 140 of file gnunet-revocation.c.

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

Referenced by run().

141 {
142  q = NULL;
143  switch (is_valid)
144  {
145  case GNUNET_YES:
146  fprintf (stdout, _ ("Key `%s' is valid\n"), test_ego);
147  break;
148 
149  case GNUNET_NO:
150  fprintf (stdout, _ ("Key `%s' has been revoked\n"), test_ego);
151  break;
152 
153  case GNUNET_SYSERR:
154  fprintf (stdout, "%s", _ ("Internal error\n"));
155  break;
156 
157  default:
158  GNUNET_break (0);
159  break;
160  }
162 }
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:531
#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:178
static struct GNUNET_REVOCATION_Query * q
Handle for revocation query.
static char * test_ego
-t option.
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 172 of file gnunet-revocation.c.

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

Referenced by perform_revocation().

173 {
174  h = NULL;
175  switch (is_valid)
176  {
177  case GNUNET_YES:
178  if (NULL != revoke_ego)
179  fprintf (stdout,
180  _ ("Key for ego `%s' is still valid, revocation failed (!)\n"),
181  revoke_ego);
182  else
183  fprintf (stdout, "%s", _ ("Revocation failed (!)\n"));
184  break;
185 
186  case GNUNET_NO:
187  if (NULL != revoke_ego)
188  fprintf (stdout,
189  _ ("Key for ego `%s' has been successfully revoked\n"),
190  revoke_ego);
191  else
192  fprintf (stdout, "%s", _ ("Revocation successful.\n"));
193  break;
194 
195  case GNUNET_SYSERR:
196  fprintf (stdout,
197  "%s",
198  _ ("Internal error, key revocation might have failed\n"));
199  break;
200 
201  default:
202  GNUNET_break (0);
203  break;
204  }
206 }
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:531
#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:178
static struct GNUNET_REVOCATION_Handle * h
Handle for revocation.
static char * revoke_ego
-R option
Here is the call graph for this function:
Here is the caller graph for this function:

◆ perform_revocation()

static void perform_revocation ( )
static

Perform the revocation.

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

References GNUNET_REVOCATION_revoke(), and print_revocation_result().

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

214 {
218  NULL);
219 }
static const struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
static struct GNUNET_REVOCATION_Handle * h
Handle for revocation.
static struct GNUNET_REVOCATION_PowP * proof_of_work
Proof-of-work object.
struct GNUNET_REVOCATION_Handle * GNUNET_REVOCATION_revoke(const struct GNUNET_CONFIGURATION_Handle *cfg, const struct GNUNET_REVOCATION_PowP *pow, GNUNET_REVOCATION_Callback func, void *func_cls)
Perform key revocation.
static void print_revocation_result(void *cls, int is_valid)
Print the result from a revocation request.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ sync_pow()

static void sync_pow ( )
static

Write the current state of the revocation data to disk.

Parameters
rddata to sync

Definition at line 229 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, GNUNET_log_strerror_file, GNUNET_OK, and GNUNET_REVOCATION_proof_get_size().

Referenced by calculate_pow(), and calculate_pow_shutdown().

230 {
232  if ((NULL != filename) &&
233  (GNUNET_OK !=
236  psize,
240 }
static char * filename
-f 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...
static struct GNUNET_REVOCATION_PowP * proof_of_work
Proof-of-work object.
size_t GNUNET_REVOCATION_proof_get_size(const struct GNUNET_REVOCATION_PowP *pow)
enum GNUNET_GenericReturnValue GNUNET_DISK_fn_write(const char *fn, const void *buf, size_t buf_size, enum GNUNET_DISK_AccessPermissions mode)
Write a buffer to a file atomically.
Definition: disk.c:705
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 249 of file gnunet-revocation.c.

References _, GNUNET_REVOCATION_pow_stop(), GNUNET_SCHEDULER_cancel(), ph, and sync_pow().

Referenced by ego_callback(), and run().

250 {
252  fprintf (stderr, "%s", _ ("Cancelling calculation.\n"));
253  sync_pow ();
254  if (NULL != pow_task)
255  {
257  pow_task = NULL;
258  }
259  if (NULL != ph)
261 }
static struct GNUNET_ATS_PerformanceHandle * ph
ATS performance handle used.
Definition: gnunet-ats.c:116
static struct GNUNET_SCHEDULER_Task * pow_task
Task used for proof-of-work calculation.
void GNUNET_REVOCATION_pow_stop(struct GNUNET_REVOCATION_PowCalculationHandle *pc)
Stop a PoW calculation.
#define _(String)
GNU gettext support macro.
Definition: platform.h:178
static void sync_pow()
Write the current state of the revocation data to disk.
The handle to a PoW calculation.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:972
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 270 of file gnunet-revocation.c.

References _, filename, GNUNET_DISK_directory_remove(), 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_pow_round(), GNUNET_REVOCATION_proof_get_size(), GNUNET_SCHEDULER_add_delayed(), GNUNET_SCHEDULER_shutdown(), GNUNET_TIME_UNIT_MILLISECONDS, perform, perform_revocation(), ph, pow_passes, revoke_ego, and sync_pow().

Referenced by ego_callback(), and run().

271 {
273  size_t psize;
274 
275  /* store temporary results */
276  pow_task = NULL;
277  if (0 == (pow_passes % 128))
278  sync_pow ();
279  /* actually do POW calculation */
281  {
283  if (NULL != filename)
284  {
286  if (GNUNET_OK !=
289  psize,
293  }
294  if (perform)
295  {
297  }
298  else
299  {
300  fprintf (stderr, "%s", "\n");
301  fprintf (stderr,
302  _ ("Revocation certificate for `%s' stored in `%s'\n"),
303  revoke_ego,
304  filename);
306  }
307  return;
308  }
309  pow_passes++;
311  &calculate_pow,
312  ph);
313 
314 }
enum GNUNET_GenericReturnValue GNUNET_REVOCATION_pow_round(struct GNUNET_REVOCATION_PowCalculationHandle *pc)
Calculate a single round in the key revocation PoW.
static char * filename
-f option.
static struct GNUNET_ATS_PerformanceHandle * ph
ATS performance handle used.
Definition: gnunet-ats.c:116
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:531
static struct GNUNET_SCHEDULER_Task * pow_task
Task used for proof-of-work calculation.
static void perform_revocation()
Perform the revocation.
#define _(String)
GNU gettext support macro.
Definition: platform.h:178
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:1269
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 'level' that indicates a failure of the command 'cmd' with the mess...
static void sync_pow()
Write the current state of the revocation data to disk.
static struct GNUNET_REVOCATION_PowP * proof_of_work
Proof-of-work object.
static int perform
Was "-p" specified?
#define GNUNET_TIME_UNIT_MILLISECONDS
One millisecond.
static unsigned int pow_passes
Pow passes.
size_t GNUNET_REVOCATION_proof_get_size(const struct GNUNET_REVOCATION_PowP *pow)
enum GNUNET_GenericReturnValue GNUNET_DISK_fn_write(const char *fn, const void *buf, size_t buf_size, enum GNUNET_DISK_AccessPermissions mode)
Write a buffer to a file atomically.
Definition: disk.c:705
static char * revoke_ego
-R option
The handle to a PoW calculation.
enum GNUNET_GenericReturnValue GNUNET_DISK_directory_remove(const char *filename)
Remove all files in a directory (rm -rf).
Definition: disk.c:905
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ego_callback()

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

Function called with the result from the ego lookup.

Parameters
clsclosure
egothe ego, NULL if not found

Certificate not yet ready

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

References _, calculate_pow(), calculate_pow_shutdown(), epoch_duration, epochs, filename, GNUNET_DISK_file_test(), GNUNET_DISK_fn_read(), GNUNET_IDENTITY_ego_get_private_key(), GNUNET_IDENTITY_ego_get_public_key(), GNUNET_IDENTITY_key_get_length(), GNUNET_malloc, GNUNET_REVOCATION_check_pow(), GNUNET_REVOCATION_MAX_PROOF_SIZE, GNUNET_REVOCATION_pow_init(), GNUNET_REVOCATION_pow_start(), GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_add_shutdown(), GNUNET_SCHEDULER_shutdown(), GNUNET_YES, matching_bits, perform, perform_revocation(), ph, and revoke_ego.

Referenced by run().

325 {
327  const struct GNUNET_IDENTITY_PrivateKey *privkey;
329  size_t psize;
330 
331  el = NULL;
332  if (NULL == ego)
333  {
334  fprintf (stdout, _ ("Ego `%s' not found.\n"), revoke_ego);
336  return;
337  }
339  privkey = GNUNET_IDENTITY_ego_get_private_key (ego);
341  if ((NULL != filename) && (GNUNET_YES == GNUNET_DISK_file_test (filename)) &&
342  (0 < (psize =
345  {
346  ssize_t ksize = GNUNET_IDENTITY_key_get_length (&key);
347  if (0 > ksize)
348  {
349  fprintf (stderr,
350  _ ("Error: Key is invalid\n"));
351  return;
352  }
353  if (((psize - sizeof (*proof_of_work)) < ksize) || // Key too small
354  (0 != memcmp (&proof_of_work[1], &key, ksize))) // Keys do not match
355  {
356  fprintf (stderr,
357  _ ("Error: revocation certificate in `%s' is not for `%s'\n"),
358  filename,
359  revoke_ego);
360  return;
361  }
362  if (GNUNET_YES ==
364  (unsigned int) matching_bits,
366  {
367  fprintf (stderr, "%s", _ ("Revocation certificate ready\n"));
368  if (perform)
370  else
372  return;
373  }
377  fprintf (stderr,
378  "%s",
379  _ ("Continuing calculation where left off...\n"));
381  epochs,
382  matching_bits);
383  }
384  fprintf (stderr,
385  "%s",
386  _ ("Revocation certificate not ready, calculating proof of work\n"));
387  if (NULL == ph)
388  {
390  proof_of_work);
392  epochs, /* Epochs */
393  matching_bits);
394  }
397 }
static unsigned int epochs
-e option.
static struct GNUNET_IDENTITY_EgoLookup * el
Handle for our ego lookup.
static char * filename
-f option.
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:1331
static struct GNUNET_ATS_PerformanceHandle * ph
ATS performance handle used.
Definition: gnunet-ats.c:116
ssize_t GNUNET_IDENTITY_key_get_length(const struct GNUNET_IDENTITY_PublicKey *key)
Get the compacted length of a GNUNET_IDENTITY_PublicKey.
Definition: identity_api.c:976
#define GNUNET_REVOCATION_MAX_PROOF_SIZE
Maximum length of a revocation.
A private key for an identity as per LSD0001.
void GNUNET_IDENTITY_ego_get_public_key(struct GNUNET_IDENTITY_Ego *ego, struct GNUNET_IDENTITY_PublicKey *pk)
Get the identifier (public key) of an ego.
Definition: identity_api.c:652
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:531
static struct GNUNET_SCHEDULER_Task * pow_task
Task used for proof-of-work calculation.
static void perform_revocation()
Perform the revocation.
#define _(String)
GNU gettext support macro.
Definition: platform.h:178
static struct GNUNET_TIME_Relative epoch_duration
Epoch length.
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:1296
static struct GNUNET_REVOCATION_PowP * proof_of_work
Proof-of-work object.
static int perform
Was "-p" specified?
struct GNUNET_HashCode key
The key used in the DHT.
struct GNUNET_REVOCATION_PowCalculationHandle * GNUNET_REVOCATION_pow_start(struct GNUNET_REVOCATION_PowP *pow, int epochs, unsigned int difficulty)
Starts a proof-of-work calculation given the pow object as well as target epochs and difficulty...
An identity key as per LSD0001.
static char * revoke_ego
-R option
const struct GNUNET_IDENTITY_PrivateKey * GNUNET_IDENTITY_ego_get_private_key(const struct GNUNET_IDENTITY_Ego *ego)
Obtain the ECC key associated with a ego.
Definition: identity_api.c:639
The handle to a PoW calculation.
void GNUNET_REVOCATION_pow_init(const struct GNUNET_IDENTITY_PrivateKey *key, struct GNUNET_REVOCATION_PowP *pow)
Initializes a fresh PoW computation.
static unsigned long long matching_bits
Number of matching bits required for revocation.
enum GNUNET_GenericReturnValue 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:437
#define GNUNET_malloc(size)
Wrapper around malloc.
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:644
enum GNUNET_GenericReturnValue GNUNET_REVOCATION_check_pow(const struct GNUNET_REVOCATION_PowP *pow, unsigned int matching_bits, struct GNUNET_TIME_Relative epoch_duration)
Check if the given proof-of-work is valid.
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 409 of file gnunet-revocation.c.

References _, calculate_pow(), calculate_pow_shutdown(), do_shutdown(), ego_callback(), epoch_duration, epochs, filename, GNUNET_CONFIGURATION_get_value_number(), GNUNET_CONFIGURATION_get_value_time(), GNUNET_DISK_fn_read(), GNUNET_ERROR_TYPE_ERROR, GNUNET_IDENTITY_ego_lookup(), GNUNET_IDENTITY_public_key_from_string(), GNUNET_log_config_missing(), GNUNET_malloc, GNUNET_OK, GNUNET_REVOCATION_check_pow(), GNUNET_REVOCATION_MAX_PROOF_SIZE, GNUNET_REVOCATION_pow_start(), GNUNET_REVOCATION_proof_get_size(), GNUNET_REVOCATION_query(), GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_add_shutdown(), GNUNET_YES, matching_bits, perform, perform_revocation(), ph, print_query_result(), revoke_ego, and test_ego.

Referenced by main().

413 {
415  size_t psize;
416 
417  cfg = c;
418  if (NULL != test_ego)
419  {
420  if (GNUNET_OK !=
422  &pk))
423  {
424  fprintf (stderr, _ ("Public key `%s' malformed\n"), test_ego);
425  return;
426  }
429  if (NULL != revoke_ego)
430  fprintf (
431  stderr,
432  "%s",
433  _ (
434  "Testing and revoking at the same time is not allowed, only executing test.\n"));
435  return;
436  }
438  "REVOCATION",
439  "WORKBITS",
440  &matching_bits))
441  {
443  "REVOCATION",
444  "WORKBITS");
445  return;
446  }
448  "REVOCATION",
449  "EPOCH_DURATION",
450  &epoch_duration))
451  {
453  "REVOCATION",
454  "EPOCH_DURATION");
455  return;
456  }
457 
458  if (NULL != revoke_ego)
459  {
460  if (! perform && (NULL == filename))
461  {
462  fprintf (stderr,
463  "%s",
464  _ ("No filename to store revocation certificate given.\n"));
465  return;
466  }
467  /* main code here */
470  return;
471  }
472  if ((NULL != filename) && (perform))
473  {
474  size_t bread;
476  if (0 < (bread = GNUNET_DISK_fn_read (filename,
479  {
480  fprintf (stderr,
481  _ ("Failed to read revocation certificate from `%s'\n"),
482  filename);
483  return;
484  }
486  if (bread != psize)
487  {
488  fprintf (stderr,
489  _ ("Revocation certificate corrupted in `%s'\n"),
490  filename);
491  return;
492  }
494  if (GNUNET_YES !=
496  (unsigned int) matching_bits,
498  {
501  epochs, /* Epochs */
502  matching_bits);
503 
506  return;
507  }
509  return;
510  }
511  fprintf (stderr, "%s", _ ("No action specified. Nothing to do.\n"));
512 }
static unsigned int epochs
-e option.
static struct GNUNET_IDENTITY_EgoLookup * el
Handle for our ego lookup.
static const struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
static char * filename
-f option.
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:1331
static struct GNUNET_ATS_PerformanceHandle * ph
ATS performance handle used.
Definition: gnunet-ats.c:116
#define GNUNET_REVOCATION_MAX_PROOF_SIZE
Maximum length of a revocation.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_number(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, unsigned long long *number)
Get a configuration value that should be a number.
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.
static void perform_revocation()
Perform the revocation.
#define _(String)
GNU gettext support macro.
Definition: platform.h:178
static struct GNUNET_TIME_Relative epoch_duration
Epoch length.
struct GNUNET_REVOCATION_Query * GNUNET_REVOCATION_query(const struct GNUNET_CONFIGURATION_Handle *cfg, const struct GNUNET_IDENTITY_PublicKey *key, GNUNET_REVOCATION_Callback func, void *func_cls)
Check if a key was revoked.
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:1296
static void ego_callback(void *cls, struct GNUNET_IDENTITY_Ego *ego)
Function called with the result from the ego lookup.
static struct GNUNET_REVOCATION_PowP * proof_of_work
Proof-of-work object.
static int perform
Was "-p" specified?
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.
enum GNUNET_GenericReturnValue GNUNET_IDENTITY_public_key_from_string(const char *str, struct GNUNET_IDENTITY_PublicKey *key)
Parses a (Base32) string representation of the public key.
static char * test_ego
-t option.
struct GNUNET_REVOCATION_PowCalculationHandle * GNUNET_REVOCATION_pow_start(struct GNUNET_REVOCATION_PowP *pow, int epochs, unsigned int difficulty)
Starts a proof-of-work calculation given the pow object as well as target epochs and difficulty...
size_t GNUNET_REVOCATION_proof_get_size(const struct GNUNET_REVOCATION_PowP *pow)
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.
An identity key as per LSD0001.
static char * revoke_ego
-R option
struct GNUNET_IDENTITY_PrivateKey pk
Private key from command line option, or NULL.
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.
The handle to a PoW calculation.
static unsigned long long matching_bits
Number of matching bits required for revocation.
#define GNUNET_malloc(size)
Wrapper around malloc.
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:644
enum GNUNET_GenericReturnValue GNUNET_REVOCATION_check_pow(const struct GNUNET_REVOCATION_PowP *pow, unsigned int matching_bits, struct GNUNET_TIME_Relative epoch_duration)
Check if the given proof-of-work is valid.
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 523 of file gnunet-revocation.c.

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

524 {
527  "filename",
528  "NAME",
529  gettext_noop (
530  "use NAME for the name of the revocation file"),
531  &filename),
532 
534  'R',
535  "revoke",
536  "NAME",
537  gettext_noop (
538  "revoke the private key associated for the the private key associated with the ego NAME "),
539  &revoke_ego),
540 
542  'p',
543  "perform",
544  gettext_noop (
545  "actually perform revocation, otherwise we just do the precomputation"),
546  &perform),
547 
549  "test",
550  "KEY",
551  gettext_noop (
552  "test if the public key KEY has been revoked"),
553  &test_ego),
555  "epochs",
556  "EPOCHS",
557  gettext_noop (
558  "number of epochs to calculate for"),
559  &epochs),
560 
562  };
563 
564  if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
565  return 2;
566 
567  ret = (GNUNET_OK == GNUNET_PROGRAM_run (argc,
568  argv,
569  "gnunet-revocation",
570  gettext_noop ("help text"),
571  options,
572  &run,
573  NULL))
574  ? ret
575  : 1;
576  GNUNET_free_nz ((void *) argv);
577  return ret;
578 }
static unsigned int epochs
-e option.
enum GNUNET_GenericReturnValue 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:363
static char * filename
-f option.
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
static int ret
Final status code.
enum GNUNET_GenericReturnValue GNUNET_STRINGS_get_utf8_args(int argc, char *const *argv, int *u8argc, char *const **u8argv)
Returns utf-8 encoded arguments.
Definition: strings.c:1209
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?
#define GNUNET_free_nz(ptr)
Wrapper around free.
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.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_uint(char shortName, const char *name, const char *argumentHelp, const char *description, unsigned int *val)
Allow user to specify an unsigned int.
#define gettext_noop(String)
Definition: gettext.h:69
Here is the call graph for this function:

Variable Documentation

◆ pow_passes

unsigned int pow_passes = 1
static

Pow passes.

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

Referenced by calculate_pow(), and run().

◆ ret

int ret
static

Final status code.

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

Referenced by main().

◆ perform

int perform
static

Was "-p" specified?

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

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

◆ filename

char* filename
static

-f option.

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

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

◆ revoke_ego

char* revoke_ego
static

-R option

Definition at line 54 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 59 of file gnunet-revocation.c.

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

◆ epochs

unsigned int epochs = 1
static

-e option.

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

Referenced by ego_callback(), GNUNET_REVOCATION_check_pow(), GNUNET_REVOCATION_pow_start(), main(), and run().

◆ q

struct GNUNET_REVOCATION_Query* q
static

◆ h

struct GNUNET_REVOCATION_Handle* h
static

Handle for revocation.

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

◆ el

struct GNUNET_IDENTITY_EgoLookup* el
static

Handle for our ego lookup.

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

◆ cfg

const struct GNUNET_CONFIGURATION_Handle* cfg
static

Our configuration.

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

◆ matching_bits

unsigned long long matching_bits
static

◆ epoch_duration

struct GNUNET_TIME_Relative epoch_duration
static

Epoch length.

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

Referenced by ego_callback(), and run().

◆ pow_task

struct GNUNET_SCHEDULER_Task* pow_task
static

Task used for proof-of-work calculation.

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

◆ proof_of_work

struct GNUNET_REVOCATION_PowP* proof_of_work
static

Proof-of-work object.

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