GNUnet  0.11.x
revocation_api.c
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet
3  Copyright (C) 2013, 2016 GNUnet e.V.
4 
5  GNUnet is free software: you can redistribute it and/or modify it
6  under the terms of the GNU Affero General Public License as published
7  by the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  GNUnet is distributed in the hope that it will be useful, but
11  WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Affero General Public License for more details.
14 
15  You should have received a copy of the GNU Affero General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
18  SPDX-License-Identifier: AGPL3.0-or-later
19  */
25 #include "platform.h"
27 #include "gnunet_signatures.h"
28 #include "gnunet_protocols.h"
29 #include "revocation.h"
30 #include <inttypes.h>
31 
36 {
41 
46 
50  void *func_cls;
51 };
52 
53 
58 struct BestPow
59 {
63  uint64_t pow;
64 
68  unsigned int bits;
69 };
70 
71 
77 {
81  struct BestPow best[POW_COUNT];
82 
87 
91  uint64_t current_pow;
92 
97  unsigned int epochs;
98 
102  unsigned int difficulty;
103 
104 };
105 
106 static struct GNUNET_CRYPTO_PowSalt salt = { "GnsRevocationPow" };
107 
117 static void
119  enum GNUNET_MQ_Error error)
120 {
121  struct GNUNET_REVOCATION_Query *q = cls;
122 
124  "Revocation query MQ error\n");
125  q->func (q->func_cls,
126  GNUNET_SYSERR);
128 }
129 
130 
137 static void
139  const struct QueryResponseMessage *qrm)
140 {
141  struct GNUNET_REVOCATION_Query *q = cls;
142 
144  "Revocation query result: %d\n",
145  (uint32_t) ntohl (qrm->is_valid));
146  q->func (q->func_cls,
147  ntohl (qrm->is_valid));
149 }
150 
151 
163  const struct GNUNET_IDENTITY_PublicKey *key,
165  void *func_cls)
166 {
167  struct GNUNET_REVOCATION_Query *q
169  struct GNUNET_MQ_MessageHandler handlers[] = {
170  GNUNET_MQ_hd_fixed_size (revocation_query_response,
172  struct QueryResponseMessage,
173  q),
175  };
176  struct QueryMessage *qm;
177  struct GNUNET_MQ_Envelope *env;
178 
179  q->mq = GNUNET_CLIENT_connect (cfg,
180  "revocation",
181  handlers,
183  q);
184  if (NULL == q->mq)
185  {
186  GNUNET_free (q);
187  return NULL;
188  }
189  q->func = func;
190  q->func_cls = func_cls;
191  env = GNUNET_MQ_msg (qm,
193  qm->reserved = htonl (0);
194  qm->key = *key;
195  GNUNET_MQ_send (q->mq,
196  env);
197  return q;
198 }
199 
200 
206 void
208 {
209  if (NULL != q->mq)
210  {
211  GNUNET_MQ_destroy (q->mq);
212  q->mq = NULL;
213  }
214  GNUNET_free (q);
215 }
216 
217 
222 {
227 
232 
236  void *func_cls;
237 };
238 
239 
249 static void
251  enum GNUNET_MQ_Error error)
252 {
253  struct GNUNET_REVOCATION_Handle *h = cls;
254 
256  "Revocation MQ error\n");
257  h->func (h->func_cls,
258  GNUNET_SYSERR);
260 }
261 
262 
269 static void
271  const struct RevocationResponseMessage *rrm)
272 {
273  struct GNUNET_REVOCATION_Handle *h = cls;
274 
276  "Revocation transmission result: %d\n",
277  (uint32_t) ntohl (rrm->is_valid));
278  h->func (h->func_cls,
279  ntohl (rrm->is_valid));
281 }
282 
283 
302  const struct GNUNET_REVOCATION_PowP *pow,
304  void *func_cls)
305 {
308  struct GNUNET_MQ_MessageHandler handlers[] = {
309  GNUNET_MQ_hd_fixed_size (revocation_response,
312  h),
314  };
315  unsigned long long matching_bits;
316  struct GNUNET_TIME_Relative epoch_duration;
317  struct RevokeMessage *rm;
318  struct GNUNET_MQ_Envelope *env;
319 
320  if ((GNUNET_OK !=
322  "REVOCATION",
323  "WORKBITS",
324  &matching_bits)))
325  {
326  GNUNET_break (0);
327  GNUNET_free (h);
328  return NULL;
329  }
330  if ((GNUNET_OK !=
332  "REVOCATION",
333  "EPOCH_DURATION",
334  &epoch_duration)))
335  {
336  GNUNET_break (0);
337  GNUNET_free (h);
338  return NULL;
339  }
341  (unsigned int) matching_bits,
342  epoch_duration))
343  {
344  GNUNET_break (0);
345  GNUNET_free (h);
346  return NULL;
347  }
348 
349 
350  h->mq = GNUNET_CLIENT_connect (cfg,
351  "revocation",
352  handlers,
354  h);
355  if (NULL == h->mq)
356  {
357  GNUNET_free (h);
358  return NULL;
359  }
360  h->func = func;
361  h->func_cls = func_cls;
362  size_t extra_len = GNUNET_REVOCATION_proof_get_size (pow);
363  env = GNUNET_MQ_msg_extra (rm,
364  extra_len,
366  rm->pow_size = htonl (extra_len);
367  memcpy (&rm[1], pow, extra_len);
368  GNUNET_MQ_send (h->mq,
369  env);
370  return h;
371 }
372 
373 
379 void
381 {
382  if (NULL != h->mq)
383  {
384  GNUNET_MQ_destroy (h->mq);
385  h->mq = NULL;
386  }
387  GNUNET_free (h);
388 }
389 
390 
397 static unsigned int
399 {
400  unsigned int hash_count;
401  hash_count = 0;
402  while ((0 == GNUNET_CRYPTO_hash_get_bit_ltr (hash, hash_count)))
403  hash_count++;
404  return hash_count;
405 }
406 
407 
414 static unsigned int
416 {
417  double sum = 0.0;
418  for (unsigned int j = 0; j<POW_COUNT; j++)
419  sum += ph->best[j].bits;
420  double avg = sum / POW_COUNT;
421  return avg;
422 }
423 
424 
427  const struct GNUNET_IDENTITY_PublicKey *key)
428 {
430  struct GNUNET_IDENTITY_Signature *sig;
431  const struct GNUNET_IDENTITY_PublicKey *pk;
432  size_t ksize;
433 
434  pk = (const struct GNUNET_IDENTITY_PublicKey *) &pow[1];
435  ksize = GNUNET_IDENTITY_key_get_length (pk);
436 
437  spurp = GNUNET_malloc (sizeof (*spurp) + ksize);
438  spurp->timestamp = pow->timestamp;
440  spurp->purpose.size = htonl (sizeof(*spurp) + ksize);
442  (char*) &spurp[1],
443  ksize);
445  "Expected signature payload len: %u\n",
446  ntohl (spurp->purpose.size));
447  sig = (struct GNUNET_IDENTITY_Signature *) ((char*) &pow[1] + ksize);
448  if (GNUNET_OK !=
450  &spurp->purpose,
451  sig,
452  key))
453  {
454  return GNUNET_SYSERR;
455  }
456  return GNUNET_OK;
457 }
458 
459 
462 {
463  const struct GNUNET_IDENTITY_PublicKey *pk;
464 
465  pk = (const struct GNUNET_IDENTITY_PublicKey *) &pow[1];
466  return check_signature_identity (pow, pk);
467 }
468 
469 
480  unsigned int difficulty,
482 {
483  char buf[sizeof(struct GNUNET_IDENTITY_PublicKey)
484  + sizeof (struct GNUNET_TIME_AbsoluteNBO)
485  + sizeof (uint64_t)] GNUNET_ALIGN;
486  struct GNUNET_HashCode result;
487  struct GNUNET_TIME_Absolute ts;
488  struct GNUNET_TIME_Absolute exp;
489  struct GNUNET_TIME_Relative ttl;
490  struct GNUNET_TIME_Relative buffer;
491  unsigned int score = 0;
492  unsigned int tmp_score = 0;
493  unsigned int epochs;
494  uint64_t pow_val;
495  ssize_t pklen;
496  const struct GNUNET_IDENTITY_PublicKey *pk;
497 
498  pk = (const struct GNUNET_IDENTITY_PublicKey *) &pow[1];
499 
503  if (GNUNET_OK != check_signature (pow))
504  {
506  "Proof of work signature invalid!\n");
507  return GNUNET_SYSERR;
508  }
509 
513  for (unsigned int i = 0; i < POW_COUNT - 1; i++)
514  {
515  if (GNUNET_ntohll (pow->pow[i]) >= GNUNET_ntohll (pow->pow[i + 1]))
516  return GNUNET_NO;
517  }
518  GNUNET_memcpy (&buf[sizeof(uint64_t)],
519  &pow->timestamp,
520  sizeof (uint64_t));
521  pklen = GNUNET_IDENTITY_key_get_length (pk);
522  if (0 > pklen)
523  {
524  GNUNET_break (0);
525  return GNUNET_NO;
526  }
527  GNUNET_memcpy (&buf[sizeof(uint64_t) * 2],
528  pk,
529  pklen);
530  for (unsigned int i = 0; i < POW_COUNT; i++)
531  {
532  pow_val = GNUNET_ntohll (pow->pow[i]);
533  GNUNET_memcpy (buf, &pow->pow[i], sizeof(uint64_t));
534  GNUNET_CRYPTO_pow_hash (&salt,
535  buf,
536  sizeof(buf),
537  &result);
538  tmp_score = count_leading_zeroes (&result);
540  "Score %u with %" PRIu64 " (#%u)\n",
541  tmp_score, pow_val, i);
542 
543  score += tmp_score;
544 
545  }
546  score = score / POW_COUNT;
547  if (score < difficulty)
548  return GNUNET_NO;
549  epochs = score - difficulty;
550 
555  ttl = GNUNET_TIME_relative_multiply (epoch_duration,
556  epochs);
560  buffer = GNUNET_TIME_relative_divide (epoch_duration,
561  10);
562  exp = GNUNET_TIME_absolute_add (ts, ttl);
563  exp = GNUNET_TIME_absolute_add (exp,
564  buffer);
565 
566  if (0 != GNUNET_TIME_absolute_get_remaining (ts).rel_value_us)
567  return GNUNET_NO; /* Not yet valid. */
568  /* Revert to actual start time */
569  ts = GNUNET_TIME_absolute_add (ts,
570  buffer);
571 
572  if (0 == GNUNET_TIME_absolute_get_remaining (exp).rel_value_us)
573  return GNUNET_NO; /* expired */
574  return GNUNET_YES;
575 }
576 
577 
580  struct GNUNET_REVOCATION_PowP *pow)
581 {
584  const struct GNUNET_IDENTITY_PublicKey *pk;
585  size_t ksize;
586  char *sig;
587 
594  pk = (const struct GNUNET_IDENTITY_PublicKey *) &pow[1];
595  ksize = GNUNET_IDENTITY_key_get_length (pk);
597  rp = GNUNET_malloc (sizeof (*rp) + ksize);
598  rp->timestamp = pow->timestamp;
600  rp->purpose.size = htonl (sizeof(*rp) + ksize);
602  "Signature payload len: %u\n",
603  ntohl (rp->purpose.size));
605  ((char*) &rp[1]),
606  ksize);
607  sig = ((char*) &pow[1]) + ksize;
608  int result = GNUNET_IDENTITY_sign_ (key,
609  &rp->purpose,
610  (void*) sig);
611  if (result == GNUNET_SYSERR)
612  return GNUNET_NO;
613  else
614  return result;
615 }
616 
617 
620  struct GNUNET_REVOCATION_PowP *pow)
621 {
623 
624  pk = (struct GNUNET_IDENTITY_PublicKey *) &pow[1];
626  return sign_pow_identity (key, pow);
627 }
628 
629 
636 void
638  struct GNUNET_REVOCATION_PowP *pow)
639 {
640  GNUNET_assert (GNUNET_OK == sign_pow (key, pow));
641 }
642 
643 
655  int epochs,
656  unsigned int difficulty)
657 {
659  struct GNUNET_TIME_Relative ttl;
660 
661 
663  pc->pow = pow;
665  epochs);
666  pc->pow->ttl = GNUNET_TIME_relative_hton (ttl);
668  UINT64_MAX);
669  pc->difficulty = difficulty;
670  pc->epochs = epochs;
671  return pc;
672 }
673 
674 
682 static int
683 cmp_pow_value (const void *a, const void *b)
684 {
685  return (GNUNET_ntohll (*(uint64_t*) a) - GNUNET_ntohll (*(uint64_t*) b));
686 }
687 
688 
701 {
702  char buf[sizeof(struct GNUNET_IDENTITY_PublicKey)
703  + sizeof (uint64_t)
704  + sizeof (uint64_t)] GNUNET_ALIGN;
705  struct GNUNET_HashCode result;
706  const struct GNUNET_IDENTITY_PublicKey *pk;
707  unsigned int zeros;
708  int ret;
709  uint64_t pow_nbo;
710  ssize_t ksize;
711 
712  pc->current_pow++;
713  pk = (const struct GNUNET_IDENTITY_PublicKey *) &(pc->pow[1]);
714 
718  for (unsigned int i = 0; i < POW_COUNT; i++)
719  if (pc->current_pow == pc->best[i].pow)
720  return GNUNET_NO;
721  pow_nbo = GNUNET_htonll (pc->current_pow);
722  GNUNET_memcpy (buf, &pow_nbo, sizeof(uint64_t));
723  GNUNET_memcpy (&buf[sizeof(uint64_t)],
724  &pc->pow->timestamp,
725  sizeof (uint64_t));
726  ksize = GNUNET_IDENTITY_key_get_length (pk);
727  GNUNET_assert (0 < ksize);
728  GNUNET_memcpy (&buf[sizeof(uint64_t) * 2],
729  pk,
730  ksize);
731  GNUNET_CRYPTO_pow_hash (&salt,
732  buf,
733  sizeof(buf),
734  &result);
735  zeros = count_leading_zeroes (&result);
736  for (unsigned int i = 0; i < POW_COUNT; i++)
737  {
738  if (pc->best[i].bits < zeros)
739  {
740  pc->best[i].bits = zeros;
741  pc->best[i].pow = pc->current_pow;
742  pc->pow->pow[i] = pow_nbo;
744  "New best score %u with %" PRIu64 " (#%u)\n",
745  zeros, pc->current_pow, i);
746 
747  break;
748  }
749  }
750  ret = calculate_score (pc) >= pc->difficulty + pc->epochs ? GNUNET_YES :
751  GNUNET_NO;
752  if (GNUNET_YES == ret)
753  {
754  /* Sort POWs) */
755  qsort (pc->pow->pow, POW_COUNT, sizeof (uint64_t), &cmp_pow_value);
756  }
757  return ret;
758 }
759 
760 
768 void
770 {
771  GNUNET_free (pc);
772 }
773 
774 
775 size_t
777 {
778  size_t size;
779  size_t ksize;
780  const struct GNUNET_IDENTITY_PublicKey *pk;
781  const struct GNUNET_IDENTITY_Signature *sig;
782 
783  size = sizeof (struct GNUNET_REVOCATION_PowP);
784  pk = (const struct GNUNET_IDENTITY_PublicKey *) &pow[1];
785  ksize = GNUNET_IDENTITY_key_get_length (pk);
786  size += ksize;
787  sig = (struct GNUNET_IDENTITY_Signature *) ((char*) &pow[1] + ksize);
789  return size;
790 }
791 
792 
793 /* end of revocation_api.c */
#define GNUNET_MESSAGE_TYPE_REVOCATION_QUERY
Client to service: was this key revoked?
static unsigned int epochs
-e option.
int GNUNET_IDENTITY_signature_verify_(uint32_t purpose, const struct GNUNET_CRYPTO_EccSignaturePurpose *validate, const struct GNUNET_IDENTITY_Signature *sig, const struct GNUNET_IDENTITY_PublicKey *pub)
Verify a given signature.
void GNUNET_REVOCATION_query_cancel(struct GNUNET_REVOCATION_Query *q)
Cancel key revocation check.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_subtract(struct GNUNET_TIME_Absolute start, struct GNUNET_TIME_Relative duration)
Subtract a given relative duration from the given start time.
Definition: time.c:296
static unsigned int calculate_score(const struct GNUNET_REVOCATION_PowCalculationHandle *ph)
Calculate the average zeros in the pows.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_ntoh(struct GNUNET_TIME_AbsoluteNBO a)
Convert absolute time from network byte order.
Definition: time.c:542
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
struct GNUNET_MQ_Handle * mq
Message queue to the service.
struct GNUNET_TIME_AbsoluteNBO timestamp
The timestamp of the revocation.
enum GNUNET_GenericReturnValue GNUNET_REVOCATION_pow_round(struct GNUNET_REVOCATION_PowCalculationHandle *pc)
Calculate a key revocation valid for broadcasting for a number of epochs.
struct GNUNET_MQ_Handle * GNUNET_CLIENT_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *service_name, const struct GNUNET_MQ_MessageHandler *handlers, GNUNET_MQ_ErrorHandler error_handler, void *error_handler_cls)
Create a message queue to connect to a GNUnet service.
Definition: client.c:1063
uint32_t purpose
What does this signature vouch for? This must contain a GNUNET_SIGNATURE_PURPOSE_XXX constant (from g...
static void revocation_mq_error_handler(void *cls, enum GNUNET_MQ_Error error)
Generic error handler, called with the appropriate error code and the same closure specified at the c...
uint64_t current_pow
The current nonce to try.
GNUNET_MQ_Error
Error codes for the queue.
uint64_t GNUNET_CRYPTO_random_u64(enum GNUNET_CRYPTO_Quality mode, uint64_t max)
Random on unsigned 64-bit values.
struct GNUNET_MQ_Handle * mq
Message queue to the service.
#define POW_COUNT
The proof-of-work narrowing factor.
Struct for a proof of work as part of the revocation.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
static struct GNUNET_ATS_PerformanceHandle * ph
ATS performance handle used.
Definition: gnunet-ats.c:116
enum GNUNET_GenericReturnValue sign_pow(const struct GNUNET_IDENTITY_PrivateKey *key, struct GNUNET_REVOCATION_PowP *pow)
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
A private key for an identity as per LSD0001.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
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.
GNUNET_GenericReturnValue
Named constants for return values.
Definition: gnunet_common.h:83
ssize_t GNUNET_IDENTITY_write_key_to_buffer(const struct GNUNET_IDENTITY_PublicKey *key, void *buffer, size_t len)
Writes a GNUNET_IDENTITY_PublicKey to a compact buffer.
struct BestPow best[POW_COUNT]
Current set of found PoWs.
The signature object we use for the PoW.
uint64_t pow
PoW nonce.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_add(struct GNUNET_TIME_Absolute start, struct GNUNET_TIME_Relative duration)
Add a given relative duration to the given start time.
Definition: time.c:277
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_IDENTITY_PublicKey key
Key to check.
Definition: revocation.h:52
Query key revocation status.
Definition: revocation.h:37
uint32_t pow_size
Length of PoW with signature.
Definition: revocation.h:90
void GNUNET_REVOCATION_pow_stop(struct GNUNET_REVOCATION_PowCalculationHandle *pc)
Stop a PoW calculation.
#define GNUNET_MESSAGE_TYPE_REVOCATION_REVOKE
Client to service OR peer-to-peer: revoke this key!
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
static unsigned int count_leading_zeroes(const struct GNUNET_HashCode *hash)
Count the leading zeroes in hash.
static struct GNUNET_TIME_Relative epoch_duration
Epoch length.
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct...
Definition: gnunet_mq_lib.h:52
void * func_cls
Closure for func.
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.
#define GNUNET_MESSAGE_TYPE_REVOCATION_QUERY_RESPONSE
Service to client: answer if key was revoked!
static int cmp_pow_value(const void *a, const void *b)
Comparison function for quicksort.
Revoke key.
Definition: revocation.h:80
Key revocation response.
Definition: revocation.h:59
static void handle_revocation_response(void *cls, const struct RevocationResponseMessage *rrm)
Handle response to our revocation query.
#define GNUNET_MESSAGE_TYPE_REVOCATION_REVOKE_RESPONSE
Service to client: revocation confirmed.
messages for key revocation
An identity signature as per LSD0001.
unsigned int difficulty
The difficulty (leading zeros) to achieve.
static char buf[2048]
struct GNUNET_REVOCATION_PowP * pow
The final PoW result data structure.
static int result
Global testing status.
struct GNUNET_TIME_Relative GNUNET_TIME_relative_multiply(struct GNUNET_TIME_Relative rel, unsigned long long factor)
Multiply relative time by a given factor.
Definition: time.c:311
enum GNUNET_GenericReturnValue GNUNET_IDENTITY_key_get_public(const struct GNUNET_IDENTITY_PrivateKey *privkey, struct GNUNET_IDENTITY_PublicKey *key)
Retrieves the public key representation of a private key.
Definition: identity_api.c:175
void * func_cls
Closure for func.
uint32_t size
How many bytes does this signature sign? (including this purpose header); in network byte order (!)...
A 512-bit hashcode.
static void handle_revocation_query_response(void *cls, const struct QueryResponseMessage *qrm)
Handle response to our revocation query.
Message handler for a specific message type.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:86
uint64_t pow[32]
The PoWs.
static struct GNUNET_REVOCATION_Query * q
Handle for revocation query.
void GNUNET_CRYPTO_pow_hash(const struct GNUNET_CRYPTO_PowSalt *salt, const void *buf, size_t buf_len, struct GNUNET_HashCode *result)
Calculate the &#39;proof-of-work&#39; hash (an expensive hash).
Definition: crypto_pow.c:41
uint64_t GNUNET_htonll(uint64_t n)
Convert unsigned 64-bit integer to network byte order.
Definition: common_endian.c:36
uint32_t is_valid
GNUNET_NO if revoked, GNUNET_YES if valid.
Definition: revocation.h:69
#define GNUNET_SIGNATURE_PURPOSE_REVOCATION
Signature for confirming a key revocation.
struct GNUNET_HashCode key
The key used in the DHT.
static unsigned int size
Size of the "table".
Definition: peer.c:67
struct GNUNET_TIME_RelativeNBO GNUNET_TIME_relative_hton(struct GNUNET_TIME_Relative a)
Convert relative time to network byte order.
Definition: time.c:444
uint32_t reserved
For alignment.
Definition: revocation.h:47
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
Value for a salt for GNUNET_CRYPTO_pow_hash().
unsigned int bits
Corresponding zero bits in hash.
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...
Handle for the key revocation query.
struct GNUNET_TIME_AbsoluteNBO timestamp
The timestamp of the revocation.
ssize_t GNUNET_IDENTITY_signature_get_length(const struct GNUNET_IDENTITY_Signature *sig)
Get the compacted length of a GNUNET_IDENTITY_Signature.
size_t GNUNET_REVOCATION_proof_get_size(const struct GNUNET_REVOCATION_PowP *pow)
Key revocation response.
Definition: revocation.h:99
enum GNUNET_GenericReturnValue check_signature_identity(const struct GNUNET_REVOCATION_PowP *pow, const struct GNUNET_IDENTITY_PublicKey *key)
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.
void(* GNUNET_REVOCATION_Callback)(void *cls, enum GNUNET_GenericReturnValue is_valid)
Callback to call with the result of a key revocation query.
Handle to a message queue.
Definition: mq.c:85
static struct GNUNET_FS_PublishContext * pc
Handle to FS-publishing operation.
An identity key as per LSD0001.
configuration data
Definition: configuration.c:84
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.
#define GNUNET_TIME_UNIT_WEEKS
One week.
int GNUNET_IDENTITY_sign_(const struct GNUNET_IDENTITY_PrivateKey *priv, const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, struct GNUNET_IDENTITY_Signature *sig)
Sign a given block.
static void query_mq_error_handler(void *cls, enum GNUNET_MQ_Error error)
Generic error handler, called with the appropriate error code and the same closure specified at the c...
enum GNUNET_GenericReturnValue sign_pow_identity(const struct GNUNET_IDENTITY_PrivateKey *key, struct GNUNET_REVOCATION_PowP *pow)
#define GNUNET_TIME_UNIT_YEARS
One year (365 days).
#define GNUNET_log(kind,...)
static struct GNUNET_CRYPTO_PowSalt salt
static char * rp
Relying party.
Handle for the key revocation operation.
int GNUNET_CRYPTO_hash_get_bit_ltr(const struct GNUNET_HashCode *code, unsigned int bit)
Obtain a bit from a hashcode.
Definition: crypto_hash.c:171
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_remaining(struct GNUNET_TIME_Absolute future)
Given a timestamp in the future, how much time remains until then?
Definition: time.c:232
GNUNET_REVOCATION_Callback func
Function to call with the result.
struct GNUNET_TIME_Relative GNUNET_TIME_relative_divide(struct GNUNET_TIME_Relative rel, unsigned long long factor)
Divide relative time by a given factor.
Definition: time.c:376
Time for absolute times used by GNUnet, in microseconds.
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:837
GNUNET_REVOCATION_Callback func
Function to call once we are done.
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:355
The handle to a PoW calculation.
uint32_t is_valid
GNUNET_NO if revocation failed for internal reasons (e.g.
Definition: revocation.h:110
void GNUNET_REVOCATION_revoke_cancel(struct GNUNET_REVOCATION_Handle *h)
Cancel key revocation.
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.
unsigned int epochs
Epochs how long the PoW should be valid.
struct GNUNET_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton(struct GNUNET_TIME_Absolute a)
Convert absolute time to network byte order.
Definition: time.c:464
struct GNUNET_CRYPTO_EccSignaturePurpose purpose
The signature purpose.
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
Helper struct that holds a found pow nonce and the corresponding number of leading zeroes...
No good quality of the operation is needed (i.e., random numbers can be pseudo-random).
#define GNUNET_malloc(size)
Wrapper around malloc.
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
Definition: common_endian.c:53
enum GNUNET_GenericReturnValue check_signature(const struct GNUNET_REVOCATION_PowP *pow)
#define GNUNET_free(ptr)
Wrapper around free.
Time for relative time used by GNUnet, in microseconds.
enum GNUNET_GenericReturnValue GNUNET_REVOCATION_check_pow(const struct GNUNET_REVOCATION_PowP *pow, unsigned int difficulty, struct GNUNET_TIME_Relative epoch_duration)
Check if the given proof-of-work is valid.