GNUnet  0.19.5
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
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  size_t key_len;
179 
181  "revocation",
182  handlers,
184  q);
185  if (NULL == q->mq)
186  {
187  GNUNET_free (q);
188  return NULL;
189  }
190  q->func = func;
191  q->func_cls = func_cls;
193  env = GNUNET_MQ_msg_extra (qm, key_len,
196  qm->key_len = htonl (key_len);
197  GNUNET_MQ_send (q->mq,
198  env);
199  return q;
200 }
201 
202 
208 void
210 {
211  if (NULL != q->mq)
212  {
214  q->mq = NULL;
215  }
216  GNUNET_free (q);
217 }
218 
219 
224 {
229 
234 
238  void *func_cls;
239 };
240 
241 
251 static void
253  enum GNUNET_MQ_Error error)
254 {
255  struct GNUNET_REVOCATION_Handle *h = cls;
256 
258  "Revocation MQ error\n");
259  h->func (h->func_cls,
260  GNUNET_SYSERR);
262 }
263 
264 
271 static void
273  const struct RevocationResponseMessage *rrm)
274 {
275  struct GNUNET_REVOCATION_Handle *h = cls;
276 
278  "Revocation transmission result: %d\n",
279  (uint32_t) ntohl (rrm->is_valid));
280  h->func (h->func_cls,
281  ntohl (rrm->is_valid));
283 }
284 
285 
304  const struct GNUNET_REVOCATION_PowP *pow,
306  void *func_cls)
307 {
311  GNUNET_MQ_hd_fixed_size (revocation_response,
314  h),
316  };
317  unsigned long long matching_bits;
319  struct RevokeMessage *rm;
320  struct GNUNET_MQ_Envelope *env;
321 
322  if ((GNUNET_OK !=
324  "REVOCATION",
325  "WORKBITS",
326  &matching_bits)))
327  {
328  GNUNET_break (0);
329  GNUNET_free (h);
330  return NULL;
331  }
332  if ((GNUNET_OK !=
334  "REVOCATION",
335  "EPOCH_DURATION",
336  &epoch_duration)))
337  {
338  GNUNET_break (0);
339  GNUNET_free (h);
340  return NULL;
341  }
343  (unsigned int) matching_bits,
345  {
346  GNUNET_break (0);
347  GNUNET_free (h);
348  return NULL;
349  }
350 
351 
353  "revocation",
354  handlers,
356  h);
357  if (NULL == h->mq)
358  {
359  GNUNET_free (h);
360  return NULL;
361  }
362  h->func = func;
363  h->func_cls = func_cls;
364  size_t extra_len = GNUNET_REVOCATION_proof_get_size (pow);
365  env = GNUNET_MQ_msg_extra (rm,
366  extra_len,
368  rm->pow_size = htonl (extra_len);
369  memcpy (&rm[1], pow, extra_len);
370  GNUNET_MQ_send (h->mq,
371  env);
372  return h;
373 }
374 
375 
376 void
378 {
379  if (NULL != h->mq)
380  {
382  h->mq = NULL;
383  }
384  GNUNET_free (h);
385 }
386 
387 
394 static unsigned int
396 {
397  double sum = 0.0;
398  for (unsigned int j = 0; j<POW_COUNT; j++)
399  sum += ph->best[j].bits;
400  double avg = sum / POW_COUNT;
401  return avg;
402 }
403 
406 {
408  const struct GNUNET_IDENTITY_PublicKey *pk;
409  size_t ksize;
410 
411  pk = (const struct GNUNET_IDENTITY_PublicKey *) &pow[1];
413  spurp = GNUNET_malloc (sizeof (*spurp) + ksize);
414  spurp->timestamp = pow->timestamp;
416  spurp->purpose.size = htonl (sizeof(*spurp) + ksize);
418  (char*) &spurp[1],
419  ksize);
420  return spurp;
421 }
422 
425  const struct GNUNET_IDENTITY_PublicKey *key)
426 {
428  unsigned char *sig;
429  size_t ksize;
430  int ret;
431 
433  spurp = REV_create_signature_message (pow);
434  sig = ((unsigned char*) &pow[1] + ksize);
435  ret =
437  &spurp->purpose,
438  sig,
439  key);
440  GNUNET_free (spurp);
441  return ret == GNUNET_OK ? GNUNET_OK : GNUNET_SYSERR;
442 }
443 
444 
446 check_signature (const struct GNUNET_REVOCATION_PowP *pow)
447 {
448  const struct GNUNET_IDENTITY_PublicKey *pk;
449 
450  pk = (const struct GNUNET_IDENTITY_PublicKey *) &pow[1];
451  return check_signature_identity (pow, pk);
452 }
453 
454 
465  unsigned int difficulty,
467 {
468  char buf[sizeof(struct GNUNET_IDENTITY_PublicKey)
469  + sizeof (struct GNUNET_TIME_AbsoluteNBO)
470  + sizeof (uint64_t)] GNUNET_ALIGN;
471  struct GNUNET_HashCode result;
472  struct GNUNET_TIME_Absolute ts;
473  struct GNUNET_TIME_Absolute exp;
474  struct GNUNET_TIME_Relative ttl;
475  struct GNUNET_TIME_Relative buffer;
476  /* LSD0001: D' */
477  unsigned int score = 0;
478  unsigned int tmp_score = 0;
479  unsigned int epochs;
480  uint64_t pow_val;
481  ssize_t pklen;
482  const struct GNUNET_IDENTITY_PublicKey *pk;
483 
484  pk = (const struct GNUNET_IDENTITY_PublicKey *) &pow[1];
485 
489  if (GNUNET_OK != check_signature (pow))
490  {
492  "Proof of work signature invalid!\n");
493  return GNUNET_SYSERR;
494  }
495 
499  for (unsigned int i = 0; i < POW_COUNT - 1; i++)
500  {
501  if (GNUNET_ntohll (pow->pow[i]) >= GNUNET_ntohll (pow->pow[i + 1]))
502  return GNUNET_NO;
503  }
504  GNUNET_memcpy (&buf[sizeof(uint64_t)],
505  &pow->timestamp,
506  sizeof (uint64_t));
508  if (0 > pklen)
509  {
510  GNUNET_break (0);
511  return GNUNET_NO;
512  }
513  GNUNET_memcpy (&buf[sizeof(uint64_t) * 2],
514  pk,
515  pklen);
516  for (unsigned int i = 0; i < POW_COUNT; i++)
517  {
518  pow_val = GNUNET_ntohll (pow->pow[i]);
519  GNUNET_memcpy (buf, &pow->pow[i], sizeof(uint64_t));
521  buf,
522  sizeof(buf),
523  &result);
526  "Score %u with %" PRIu64 " (#%u)\n",
527  tmp_score, pow_val, i);
528 
529  score += tmp_score;
530 
531  }
532  score = score / POW_COUNT;
533  if (score < difficulty)
534  return GNUNET_NO;
535  /* LSD0001: (D'-D+1) */
536  epochs = score - difficulty + 1;
537 
543  epochs);
548  10);
549  exp = GNUNET_TIME_absolute_add (ts, ttl);
550  exp = GNUNET_TIME_absolute_add (exp,
551  buffer);
552 
553  if (0 != GNUNET_TIME_absolute_get_remaining (ts).rel_value_us)
554  return GNUNET_NO; /* Not yet valid. */
555  /* Revert to actual start time */
556  ts = GNUNET_TIME_absolute_add (ts,
557  buffer);
558 
559  if (0 == GNUNET_TIME_absolute_get_remaining (exp).rel_value_us)
560  return GNUNET_NO; /* expired */
561  return GNUNET_YES;
562 }
563 
564 
567  struct GNUNET_REVOCATION_PowP *pow)
568 {
571  const struct GNUNET_IDENTITY_PublicKey *pk;
572  size_t ksize;
573  char *sig;
574 
581  pk = (const struct GNUNET_IDENTITY_PublicKey *) &pow[1];
585  sig = ((char*) &pow[1]) + ksize;
587  &rp->purpose,
588  (void*) sig);
589  GNUNET_free (rp);
590  if (result == GNUNET_SYSERR)
591  return GNUNET_NO;
592  else
593  return result;
594 }
595 
596 
599  struct GNUNET_REVOCATION_PowP *pow)
600 {
602 
603  pk = (struct GNUNET_IDENTITY_PublicKey *) &pow[1];
605  return sign_pow_identity (key, pow);
606 }
607 
608 
615 void
617  struct GNUNET_REVOCATION_PowP *pow)
618 {
619  GNUNET_assert (GNUNET_OK == sign_pow (key, pow));
620 }
621 
622 
625  int epochs,
626  unsigned int difficulty)
627 {
629  struct GNUNET_TIME_Relative ttl;
630 
631 
633  pc->pow = pow;
635  epochs);
636  pc->pow->ttl = GNUNET_TIME_relative_hton (ttl);
638  UINT64_MAX);
639  pc->difficulty = difficulty;
640  pc->epochs = epochs;
641  return pc;
642 }
643 
644 
652 static int
653 cmp_pow_value (const void *a, const void *b)
654 {
655  return (GNUNET_ntohll (*(uint64_t*) a) - GNUNET_ntohll (*(uint64_t*) b));
656 }
657 
658 
671 {
672  char buf[sizeof(struct GNUNET_IDENTITY_PublicKey)
673  + sizeof (uint64_t)
674  + sizeof (uint64_t)] GNUNET_ALIGN;
675  struct GNUNET_HashCode result;
676  const struct GNUNET_IDENTITY_PublicKey *pk;
677  unsigned int zeros;
678  int ret;
679  uint64_t pow_nbo;
680  ssize_t ksize;
681 
682  pc->current_pow++;
683  pk = (const struct GNUNET_IDENTITY_PublicKey *) &(pc->pow[1]);
684 
688  for (unsigned int i = 0; i < POW_COUNT; i++)
689  if (pc->current_pow == pc->best[i].pow)
690  return GNUNET_NO;
691  pow_nbo = GNUNET_htonll (pc->current_pow);
692  GNUNET_memcpy (buf, &pow_nbo, sizeof(uint64_t));
693  GNUNET_memcpy (&buf[sizeof(uint64_t)],
694  &pc->pow->timestamp,
695  sizeof (uint64_t));
697  GNUNET_assert (0 < ksize);
698  GNUNET_memcpy (&buf[sizeof(uint64_t) * 2],
699  pk,
700  ksize);
702  buf,
703  sizeof(buf),
704  &result);
706  for (unsigned int i = 0; i < POW_COUNT; i++)
707  {
708  if (pc->best[i].bits < zeros)
709  {
710  pc->best[i].bits = zeros;
711  pc->best[i].pow = pc->current_pow;
712  pc->pow->pow[i] = pow_nbo;
714  "New best score %u with %" PRIu64 " (#%u)\n",
715  zeros, pc->current_pow, i);
716 
717  break;
718  }
719  }
720  ret = calculate_score (pc) >= pc->difficulty + pc->epochs ? GNUNET_YES :
721  GNUNET_NO;
722  if (GNUNET_YES == ret)
723  {
724  /* Sort POWs) */
725  qsort (pc->pow->pow, POW_COUNT, sizeof (uint64_t), &cmp_pow_value);
726  }
727  return ret;
728 }
729 
730 
738 void
740 {
741  GNUNET_free (pc);
742 }
743 
744 
745 size_t
747 {
748  size_t size;
749  size_t ksize;
750  const struct GNUNET_IDENTITY_PublicKey *pk;
751 
752  size = sizeof (struct GNUNET_REVOCATION_PowP);
753  pk = (const struct GNUNET_IDENTITY_PublicKey *) &pow[1];
755  size += ksize;
757  return size;
758 }
759 
760 
761 /* end of revocation_api.c */
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
#define GNUNET_SIGNATURE_PURPOSE_REVOCATION
Signature for confirming a key revocation.
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
static struct GNUNET_ATS_PerformanceHandle * ph
ATS performance handle used.
Definition: gnunet-ats.c:116
static struct GNUNET_CADET_MessageHandler handlers[]
Handlers, for diverse services.
struct GNUNET_HashCode key
The key used in the DHT.
struct GNUNET_IDENTITY_PrivateKey pk
Private key from command line option, or NULL.
static struct GNUNET_TIME_Relative ttl
Current record $TTL to use.
static struct GNUNET_FS_PublishContext * pc
Handle to FS-publishing operation.
static char * rp
Relying party.
static int result
Global testing status.
static struct GNUNET_REVOCATION_Query * q
Handle for revocation query.
static struct GNUNET_TIME_Relative epoch_duration
Epoch length.
static unsigned long long matching_bits
Number of matching bits required for revocation.
static unsigned int epochs
-e option.
static char buf[2048]
Constants for network protocols.
API to perform and access key revocations.
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:1057
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_number(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, unsigned long long *number)
Get a configuration value that should be a number.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_time(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, struct GNUNET_TIME_Relative *time)
Get a configuration value that should be a relative time.
uint64_t GNUNET_CRYPTO_random_u64(enum GNUNET_CRYPTO_Quality mode, uint64_t max)
Generate a random unsigned 64-bit value.
@ GNUNET_CRYPTO_QUALITY_WEAK
No good quality of the operation is needed (i.e., random numbers can be pseudo-random).
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:179
ssize_t GNUNET_IDENTITY_write_public_key_to_buffer(const struct GNUNET_IDENTITY_PublicKey *key, void *buffer, size_t len)
Writes a GNUNET_IDENTITY_PublicKey to a compact buffer.
Definition: identity_api.c:890
ssize_t GNUNET_IDENTITY_public_key_get_length(const struct GNUNET_IDENTITY_PublicKey *key)
Get the compacted length of a GNUNET_IDENTITY_PublicKey.
Definition: identity_api.c:830
enum GNUNET_GenericReturnValue GNUNET_IDENTITY_sign_raw_(const struct GNUNET_IDENTITY_PrivateKey *priv, const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, unsigned char *sig)
Sign a given block.
enum GNUNET_GenericReturnValue GNUNET_IDENTITY_signature_verify_raw_(uint32_t purpose, const struct GNUNET_CRYPTO_EccSignaturePurpose *validate, const unsigned char *sig, const struct GNUNET_IDENTITY_PublicKey *pub)
Verify a given signature.
ssize_t GNUNET_IDENTITY_signature_get_raw_length_by_type(uint32_t type)
Get the compacted length of a signature by type.
Definition: identity_api.c:970
unsigned int GNUNET_CRYPTO_hash_count_leading_zeros(const struct GNUNET_HashCode *h)
Count the number of leading 0 bits in h.
Definition: crypto_hash.c:176
#define GNUNET_log(kind,...)
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
Definition: common_endian.c:54
void GNUNET_CRYPTO_pow_hash(const struct GNUNET_CRYPTO_PowSalt *salt, const void *buf, size_t buf_len, struct GNUNET_HashCode *result)
Calculate the 'proof-of-work' hash (an expensive hash).
Definition: crypto_pow.c:42
uint64_t GNUNET_htonll(uint64_t n)
Convert unsigned 64-bit integer to network byte order.
Definition: common_endian.c:37
#define GNUNET_ALIGN
gcc-ism to force alignment; we use this to align char-arrays that may then be cast to 'struct's.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
GNUNET_GenericReturnValue
Named constants for return values.
@ GNUNET_OK
@ GNUNET_YES
@ GNUNET_NO
@ GNUNET_SYSERR
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
@ GNUNET_ERROR_TYPE_WARNING
@ GNUNET_ERROR_TYPE_ERROR
@ GNUNET_ERROR_TYPE_DEBUG
@ GNUNET_ERROR_TYPE_INFO
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
GNUNET_MQ_Error
Error codes for the queue.
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:304
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
#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:62
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:683
#define GNUNET_MESSAGE_TYPE_REVOCATION_QUERY
Client to service: was this key revoked?
#define GNUNET_MESSAGE_TYPE_REVOCATION_REVOKE
Client to service OR peer-to-peer: revoke this key!
#define GNUNET_MESSAGE_TYPE_REVOCATION_REVOKE_RESPONSE
Service to client: revocation confirmed.
#define GNUNET_MESSAGE_TYPE_REVOCATION_QUERY_RESPONSE
Service to client: answer if key was revoked!
void GNUNET_REVOCATION_pow_stop(struct GNUNET_REVOCATION_PowCalculationHandle *pc)
Stop a PoW calculation.
size_t GNUNET_REVOCATION_proof_get_size(const struct GNUNET_REVOCATION_PowP *pow)
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_REVOCATION_pow_init(const struct GNUNET_IDENTITY_PrivateKey *key, struct GNUNET_REVOCATION_PowP *pow)
Initializes a fresh PoW computation.
void GNUNET_REVOCATION_query_cancel(struct GNUNET_REVOCATION_Query *q)
Cancel key revocation check.
enum GNUNET_GenericReturnValue GNUNET_REVOCATION_pow_round(struct GNUNET_REVOCATION_PowCalculationHandle *pc)
Calculate a key revocation valid for broadcasting for a number of epochs.
void GNUNET_REVOCATION_revoke_cancel(struct GNUNET_REVOCATION_Handle *h)
Cancel key revocation.
#define POW_COUNT
The proof-of-work narrowing factor.
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.
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.
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.
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:405
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:111
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_ntoh(struct GNUNET_TIME_AbsoluteNBO a)
Convert absolute time from network byte order.
Definition: time.c:737
#define GNUNET_TIME_UNIT_WEEKS
One week.
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:469
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:484
struct GNUNET_TIME_RelativeNBO GNUNET_TIME_relative_hton(struct GNUNET_TIME_Relative a)
Convert relative time to network byte order.
Definition: time.c:618
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:450
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:550
struct GNUNET_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton(struct GNUNET_TIME_Absolute a)
Convert absolute time to network byte order.
Definition: time.c:638
#define GNUNET_TIME_UNIT_YEARS
One year (365 days).
static unsigned int size
Size of the "table".
Definition: peer.c:68
messages for key revocation
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...
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...
static void handle_revocation_query_response(void *cls, const struct QueryResponseMessage *qrm)
Handle response to our revocation query.
static unsigned int calculate_score(const struct GNUNET_REVOCATION_PowCalculationHandle *ph)
Calculate the average zeros in the pows.
enum GNUNET_GenericReturnValue check_signature_identity(const struct GNUNET_REVOCATION_PowP *pow, const struct GNUNET_IDENTITY_PublicKey *key)
enum GNUNET_GenericReturnValue sign_pow_identity(const struct GNUNET_IDENTITY_PrivateKey *key, struct GNUNET_REVOCATION_PowP *pow)
static int cmp_pow_value(const void *a, const void *b)
Comparison function for quicksort.
static struct GNUNET_CRYPTO_PowSalt salt
enum GNUNET_GenericReturnValue check_signature(const struct GNUNET_REVOCATION_PowP *pow)
static void handle_revocation_response(void *cls, const struct RevocationResponseMessage *rrm)
Handle response to our revocation query.
enum GNUNET_GenericReturnValue sign_pow(const struct GNUNET_IDENTITY_PrivateKey *key, struct GNUNET_REVOCATION_PowP *pow)
struct GNUNET_REVOCATION_SignaturePurposePS * REV_create_signature_message(const struct GNUNET_REVOCATION_PowP *pow)
Create the revocation metadata to sign for a revocation message.
Helper struct that holds a found pow nonce and the corresponding number of leading zeros.
unsigned int bits
Corresponding zero bits in hash.
uint64_t pow
PoW nonce.
struct GNUNET_MQ_Handle * mq
Our connection to the ARM service.
Definition: arm_api.c:107
uint32_t size
How many bytes does this signature sign? (including this purpose header); in network byte order (!...
uint32_t purpose
What does this signature vouch for? This must contain a GNUNET_SIGNATURE_PURPOSE_XXX constant (from g...
Value for a salt for GNUNET_CRYPTO_pow_hash().
A 512-bit hashcode.
A private key for an identity as per LSD0001.
uint32_t type
Type of public key.
An identity key as per LSD0001.
Handle to a message queue.
Definition: mq.c:87
Message handler for a specific message type.
Handle for the key revocation operation.
struct GNUNET_MQ_Handle * mq
Message queue to the service.
GNUNET_REVOCATION_Callback func
Function to call once we are done.
void * func_cls
Closure for func.
The handle to a PoW calculation.
unsigned int epochs
Epochs how long the PoW should be valid.
struct BestPow best[POW_COUNT]
Current set of found PoWs.
uint64_t current_pow
The current nonce to try.
unsigned int difficulty
The difficulty (leading zeros) to achieve.
struct GNUNET_REVOCATION_PowP * pow
The final PoW result data structure.
Struct for a proof of work as part of the revocation.
struct GNUNET_TIME_AbsoluteNBO timestamp
The timestamp of the revocation.
Handle for the key revocation query.
void * func_cls
Closure for func.
struct GNUNET_MQ_Handle * mq
Message queue to the service.
GNUNET_REVOCATION_Callback func
Function to call with the result.
The signature object we use for the PoW.
struct GNUNET_CRYPTO_EccSignaturePurpose purpose
The signature purpose.
struct GNUNET_TIME_AbsoluteNBO timestamp
The timestamp of the revocation.
Time for absolute time used by GNUnet, in microseconds and in network byte order.
Time for absolute times used by GNUnet, in microseconds.
Time for relative time used by GNUnet, in microseconds.
Query key revocation status.
Definition: revocation.h:38
uint32_t key_len
Key length.
Definition: revocation.h:47
Key revocation response.
Definition: revocation.h:59
uint32_t is_valid
GNUNET_NO if revoked, GNUNET_YES if valid.
Definition: revocation.h:68
Key revocation response.
Definition: revocation.h:99
uint32_t is_valid
GNUNET_NO if revocation failed for internal reasons (e.g.
Definition: revocation.h:109
Revoke key.
Definition: revocation.h:80
uint32_t pow_size
Length of PoW with signature.
Definition: revocation.h:89