GNUnet  0.11.x
hello-uri.c
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet.
3  Copyright (C) 2022 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  */
20 
37 #include "platform.h"
38 #include "gnunet_signatures.h"
39 #include "gnunet_hello_uri_lib.h"
40 #include "gnunet_protocols.h"
41 #include "gnunet_util_lib.h"
42 
43 
45 
50 {
55 
60 
64  struct GNUNET_HashCode h_addrs;
65 
66 };
67 
72 {
77 
82 
87 
88  /* followed by a 'block' */
89 };
90 
91 
96 {
100  struct GNUNET_PeerIdentity pid;
101 
106 
111 
112 };
113 
114 
120 {
125 
130 
135 
140 
145 
146  /* followed by the serialized addresses of the 'block' */
147 };
148 
149 
151 
152 
156 struct Address
157 {
161  struct Address *next;
162 
166  struct Address *prev;
167 
171  const char *uri;
172 
176  size_t uri_len;
177 };
178 
179 
184 {
188  struct GNUNET_PeerIdentity pid;
189 
193  struct Address *a_head;
194 
198  struct Address *a_tail;
199 
203  unsigned int a_length;
204 
205 };
206 
207 
214 static void
216  struct GNUNET_HashCode *hash)
217 {
218  struct GNUNET_HashContext *hc;
219 
221  for (struct Address *a = builder->a_head;
222  NULL != a;
223  a = a->next)
224  {
226  a->uri,
227  a->uri_len);
228  }
230  hash);
231 
232 }
233 
234 
243 static void
245  struct GNUNET_TIME_Timestamp et,
246  const struct GNUNET_CRYPTO_EddsaPrivateKey *priv,
247  struct GNUNET_CRYPTO_EddsaSignature *sig)
248 {
249  struct HelloSignaturePurpose hsp = {
250  .purpose.size = htonl (sizeof (hsp)),
251  .purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_HELLO),
252  .expiration_time = GNUNET_TIME_absolute_hton (et.abs_time)
253  };
254 
256  &hsp.h_addrs);
258  &hsp,
259  sig);
260 }
261 
262 
272 static enum GNUNET_GenericReturnValue
274  struct GNUNET_TIME_Absolute et,
275  const struct GNUNET_CRYPTO_EddsaSignature *sig)
276 {
277  struct HelloSignaturePurpose hsp = {
278  .purpose.size = htonl (sizeof (hsp)),
279  .purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_HELLO),
280  .expiration_time = GNUNET_TIME_absolute_hton (et)
281  };
282 
284  &hsp.h_addrs);
285  if (GNUNET_OK !=
287  &hsp,
288  sig,
289  &builder->pid.public_key))
290  {
291  GNUNET_break_op (0);
292  return GNUNET_SYSERR;
293  }
295  return GNUNET_NO;
296  return GNUNET_OK;
297 }
298 
299 
300 struct GNUNET_HELLO_Builder *
302 {
304 
306  builder->pid = *pid;
307  return builder;
308 }
309 
310 
311 void
313 {
314  struct Address *a;
315 
316  while (NULL != (a = builder->a_head))
317  {
319  builder->a_tail,
320  a);
321  builder->a_length--;
322  GNUNET_free (a);
323  }
324  GNUNET_assert (0 == builder->a_length);
326 }
327 
328 
329 struct GNUNET_HELLO_Builder *
331 {
332  const struct HelloUriMessage *h;
333  uint16_t size = ntohs (msg->size);
334 
335  if (GNUNET_MESSAGE_TYPE_HELLO_URI != ntohs (msg->type))
336  {
337  GNUNET_break (0);
338  return NULL;
339  }
340  if (sizeof (struct HelloUriMessage) > size)
341  {
342  GNUNET_break_op (0);
343  return NULL;
344  }
345  h = (const struct HelloUriMessage *) msg;
346  size -= sizeof (*h);
348  size);
349 }
350 
351 
352 struct GNUNET_HELLO_Builder *
354  size_t block_size)
355 {
356  const struct BlockHeader *bh = block;
357  struct GNUNET_HELLO_Builder *b;
358 
359  if (block_size < sizeof (*bh))
360  {
361  GNUNET_break_op (0);
362  return NULL;
363  }
364  b = GNUNET_HELLO_builder_new (&bh->pid);
365  block += sizeof (*bh);
366  block_size -= sizeof (*bh);
367  while (block_size > 0)
368  {
369  const void *end = memchr (block,
370  '\0',
371  block_size);
372 
373  if (NULL == end)
374  {
375  GNUNET_break_op (0);
377  return NULL;
378  }
379  if (GNUNET_OK !=
381  block))
382  {
383  GNUNET_break_op (0);
385  return NULL;
386  }
387  end++;
388  block_size -= (end - block);
389  block = end;
390  }
391  {
393 
394  ret = verify_hello (b,
395  GNUNET_TIME_absolute_ntoh (bh->expiration_time),
396  &bh->sig);
398  if (GNUNET_OK != ret)
399  {
401  return NULL;
402  }
403  }
404  return b;
405 }
406 
407 
408 struct GNUNET_HELLO_Builder *
410 {
411  const char *q;
412  const char *s1;
413  const char *s2;
414  struct GNUNET_PeerIdentity pid;
415  struct GNUNET_CRYPTO_EddsaSignature sig;
416  struct GNUNET_TIME_Absolute et;
417  size_t len;
418  struct GNUNET_HELLO_Builder *b;
419 
420  if (0 != strncasecmp (url,
421  "gnunet://hello/",
422  strlen ("gnunet://hello/")))
423  return NULL;
424  url += strlen ("gnunet://hello/");
425  s1 = strchr (url, '/');
426  if (NULL == s1)
427  {
428  GNUNET_break_op (0);
429  return NULL;
430  }
431  s2 = strchr (s1 + 1, '/');
432  if (NULL == s1)
433  {
434  GNUNET_break_op (0);
435  return NULL;
436  }
437  q = strchr (url, '?');
438  if (NULL == q)
439  q = url + strlen (url);
440  if (GNUNET_OK !=
442  s1 - url,
443  &pid,
444  sizeof(pid)))
445  {
446  GNUNET_break_op (0);
447  return NULL;
448  }
449  if (GNUNET_OK !=
451  s2 - (s1 + 1),
452  &sig,
453  sizeof(sig)))
454  {
455  GNUNET_break_op (0);
456  return NULL;
457  }
458  {
459  unsigned long long sec;
460  char dummy = '?';
461 
462  if ( (0 == sscanf (s2 + 1,
463  "%llu%c",
464  &sec,
465  &dummy)) ||
466  ('?' != dummy) )
467  {
468  GNUNET_break_op (0);
469  return NULL;
470  }
471  et = GNUNET_TIME_absolute_from_s (sec);
472  }
473 
475  len = strlen (q);
476  while (len > 0)
477  {
478  const char *eq;
479  const char *amp;
480  char *addr = NULL;
481  char *uri;
482 
483  /* skip ?/& separator */
484  len--;
485  q++;
486  eq = strchr (q, '=');
487  if ( (eq == q) ||
488  (NULL == eq) )
489  {
490  GNUNET_break_op (0);
492  return NULL;
493  }
494  amp = strchr (eq, '&');
495  if (NULL == amp)
496  amp = &q[len];
497  GNUNET_STRINGS_urldecode (eq + 1,
498  amp - (eq + 1),
499  &addr);
500  if ( (NULL == addr) ||
501  (0 == strlen (addr)) )
502  {
503  GNUNET_free (addr);
504  GNUNET_break_op (0);
506  return NULL;
507  }
509  "%.*s://%s",
510  (int) (eq - q),
511  q,
512  addr);
513  GNUNET_free (addr);
514  if (GNUNET_OK !=
516  uri))
517  {
518  GNUNET_break_op (0);
519  GNUNET_free (uri);
521  return NULL;
522  }
523  GNUNET_free (uri);
524  /* move to next URL */
525  len -= (amp - q);
526  q = amp;
527  }
528 
529  {
531 
532  ret = verify_hello (b,
533  et,
534  &sig);
536  if (GNUNET_OK != ret)
537  {
539  return NULL;
540  }
541  }
542  return b;
543 }
544 
545 
546 struct GNUNET_MQ_Envelope *
548  const struct GNUNET_CRYPTO_EddsaPrivateKey *priv)
549 {
550  struct GNUNET_MQ_Envelope *env;
551  struct HelloUriMessage *msg;
552  size_t blen;
553 
554  if (builder->a_length > UINT16_MAX)
555  {
556  GNUNET_break (0);
557  return NULL;
558  }
559  blen = 0;
562  priv,
563  NULL,
564  &blen));
566  blen,
568  msg->url_counter = htonl ((uint16_t) builder->a_length);
571  priv,
572  &msg[1],
573  &blen));
574  return env;
575 }
576 
577 
578 struct GNUNET_MessageHeader *
580  const struct GNUNET_HELLO_Builder *builder,
581  const struct GNUNET_CRYPTO_EddsaPrivateKey *priv)
582 {
583  struct DhtHelloMessage *msg;
584  size_t blen;
585 
586  if (builder->a_length > UINT16_MAX)
587  {
588  GNUNET_break (0);
589  return NULL;
590  }
591  blen = 0;
594  priv,
595  NULL,
596  &blen));
597  GNUNET_assert (blen < UINT16_MAX);
598  GNUNET_assert (blen >= sizeof (struct BlockHeader));
599  {
600  char buf[blen] GNUNET_ALIGN;
601  const struct BlockHeader *block = (const struct BlockHeader *) buf;
602 
605  priv,
606  buf,
607  &blen));
608  msg = GNUNET_malloc (sizeof (*msg)
609  + blen
610  - sizeof (*block));
611  msg->header.type = htons (GNUNET_MESSAGE_TYPE_DHT_P2P_HELLO);
612  msg->header.size = htons (sizeof (*msg)
613  + blen
614  - sizeof (*block));
615  memcpy (&msg[1],
616  &block[1],
617  blen - sizeof (*block));
618  msg->sig = block->sig;
619  msg->expiration_time = block->expiration_time;
620  }
621  msg->url_counter = htonl ((uint16_t) builder->a_length);
622  return &msg->header;
623 }
624 
625 
626 char *
628  const struct GNUNET_CRYPTO_EddsaPrivateKey *priv)
629 {
630  struct GNUNET_CRYPTO_EddsaSignature sig;
631  struct GNUNET_TIME_Timestamp et;
632  char *result;
633  char *pids;
634  char *sigs;
635  const char *sep = "?";
636 
639  et,
640  priv,
641  &sig);
643  sizeof (builder->pid));
645  sizeof (sig));
647  "gnunet://hello/%s/%s/%llu",
648  pids,
649  sigs,
650  (unsigned long long) GNUNET_TIME_timestamp_to_s (et));
651  GNUNET_free (sigs);
652  GNUNET_free (pids);
653  for (struct Address *a = builder->a_head;
654  NULL != a;
655  a = a->next)
656  {
657  char *ue;
658  char *tmp;
659  int pfx_len;
660  const char *eou;
661 
662  eou = strstr (a->uri,
663  "://");
664  if (NULL == eou)
665  {
666  GNUNET_break (0);
668  return NULL;
669  }
670  pfx_len = eou - a->uri;
671  eou += 3;
673  a->uri_len - 4 - pfx_len,
674  &ue);
675  GNUNET_asprintf (&tmp,
676  "%s%s%.*s=%s",
677  result,
678  sep,
679  pfx_len,
680  a->uri,
681  ue);
682  GNUNET_free (ue);
684  result = tmp;
685  sep = "&";
686  }
687  return result;
688 }
689 
690 
693  const struct GNUNET_CRYPTO_EddsaPrivateKey *priv,
694  void *block,
695  size_t *block_size)
696 {
697  struct BlockHeader bh;
698  size_t needed = sizeof (bh);
699  char *pos;
700  struct GNUNET_TIME_Timestamp et;
701 
702  for (struct Address *a = builder->a_head;
703  NULL != a;
704  a = a->next)
705  {
706  GNUNET_assert (needed + a->uri_len > needed);
707  needed += a->uri_len;
708  }
709  if ( (NULL == block) ||
710  (needed < *block_size) )
711  {
712  *block_size = needed;
713  return GNUNET_NO;
714  }
715  bh.pid = builder->pid;
717  bh.expiration_time = GNUNET_TIME_absolute_hton (et.abs_time);
719  et,
720  priv,
721  &bh.sig);
722  memcpy (block,
723  &bh,
724  sizeof (bh));
725  pos = block + sizeof (bh);
726  for (struct Address *a = builder->a_head;
727  NULL != a;
728  a = a->next)
729  {
730  memcpy (pos,
731  a->uri,
732  a->uri_len);
733  pos += a->uri_len;
734  }
735  *block_size = needed;
736  return GNUNET_OK;
737 }
738 
739 
742  const char *address)
743 {
744  size_t alen = strlen (address) + 1;
745  struct Address *a;
746  const char *e;
747 
748  if (NULL == (e = strstr (address,
749  "://")))
750  {
751  GNUNET_break_op (0);
753  "Invalid address `%s'\n",
754  address);
755  return GNUNET_SYSERR;
756  }
757  if (e == address)
758  {
759  GNUNET_break_op (0);
760  return GNUNET_SYSERR;
761  }
762  for (const char *p = address; p != e; p++)
763  if ( (! isalpha ((unsigned char) *p)) &&
764  ('+' != *p) )
765  {
766  GNUNET_break_op (0);
767  return GNUNET_SYSERR;
768  }
769  /* check for duplicates */
770  for (a = builder->a_head;
771  NULL != a;
772  a = a->next)
773  if (0 == strcmp (address,
774  a->uri))
775  return GNUNET_NO;
776  a = GNUNET_malloc (sizeof (struct Address) + alen);
777  a->uri_len = alen;
778  memcpy (&a[1],
779  address,
780  alen);
781  a->uri = (const char *) &a[1];
783  builder->a_tail,
784  a);
785  builder->a_length++;
786  return GNUNET_OK;
787 }
788 
789 
792  const char *address)
793 {
794  struct Address *a;
795 
796  /* check for duplicates */
797  for (a = builder->a_head;
798  NULL != a;
799  a = a->next)
800  if (0 == strcmp (address,
801  a->uri))
802  break;
803  if (NULL == a)
804  return GNUNET_NO;
806  builder->a_tail,
807  a);
808  builder->a_length--;
809  GNUNET_free (a);
810  return GNUNET_OK;
811 }
812 
813 
814 void
816  struct GNUNET_PeerIdentity *pid,
818  void *uc_cls)
819 {
820  struct Address *nxt;
821 
822  *pid = builder->pid;
823  if (NULL == uc)
824  return;
825  for (struct Address *a = builder->a_head;
826  NULL != a;
827  a = nxt)
828  {
829  nxt = a->next;
830  uc (uc_cls,
831  a->uri);
832  }
833 }
834 
835 
838  const struct GNUNET_PeerIdentity *pid,
839  void **block,
840  size_t *block_size,
841  struct GNUNET_TIME_Absolute *block_expiration)
842 {
843  const struct DhtHelloMessage *msg
844  = (const struct DhtHelloMessage *) hello;
845  uint16_t len = ntohs (hello->size);
846  struct BlockHeader *bh;
847  struct GNUNET_HELLO_Builder *b;
849 
850  if (GNUNET_MESSAGE_TYPE_DHT_P2P_HELLO != ntohs (hello->type))
851  {
852  GNUNET_break (0);
853  return GNUNET_SYSERR;
854  }
855  if (len < sizeof (*msg))
856  {
857  GNUNET_break_op (0);
858  return GNUNET_SYSERR;
859  }
860  len -= sizeof (*msg);
861  *block_size = len + sizeof (*bh);
862  *block = GNUNET_malloc (*block_size);
863  bh = *block;
864  bh->pid = *pid;
865  bh->sig = msg->sig;
866  bh->expiration_time = msg->expiration_time;
867  *block_expiration = GNUNET_TIME_absolute_ntoh (msg->expiration_time);
868  memcpy (&bh[1],
869  &msg[1],
870  len);
872  *block_size);
873  if (NULL == b)
874  {
875  GNUNET_break_op (0);
876  GNUNET_free (*block);
877  *block_size = 0;
878  return GNUNET_SYSERR;
879  }
880  ret = verify_hello (b,
881  *block_expiration,
882  &msg->sig);
884  if (GNUNET_SYSERR == ret)
885  {
886  GNUNET_free (*block);
887  *block_size = 0;
888  return GNUNET_SYSERR;
889  }
890  return ret;
891 }
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
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 int end
Set if we are to shutdown all services (including ARM).
Definition: gnunet-arm.c:34
static struct Experiment * e
static char * address
GNS address for this phone.
static struct HostSet * builder
NULL if we are not currently iterating over peer information.
static struct GNUNET_TRANSPORT_Blacklist * bh
The blacklist handle we obtain from transport when we register ourselves for access control.
static struct in_addr dummy
Target "dummy" address of the packet we pretend to respond to.
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...
static struct GNUNET_FS_Uri * uri
Value of URI provided on command-line (when not publishing a file but just creating UBlocks to refer ...
static int result
Global testing status.
static struct GNUNET_REVOCATION_Query * q
Handle for revocation query.
static char buf[2048]
static struct GNUNET_PeerIdentity pid
Identity of the peer we transmit to / connect to.
static struct GNUNET_FS_UnindexContext * uc
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-uri.c:37
#define GNUNET_NETWORK_STRUCT_BEGIN
Define as empty, GNUNET_PACKED should suffice, but this won't work on W32.
#define GNUNET_log(kind,...)
#define GNUNET_NETWORK_STRUCT_END
Define as empty, GNUNET_PACKED should suffice, but this won't work on W32;.
#define GNUNET_ALIGN
gcc-ism to force alignment; we use this to align char-arrays that may then be cast to 'struct's.
GNUNET_GenericReturnValue
Named constants for return values.
Definition: gnunet_common.h:92
@ GNUNET_OK
Definition: gnunet_common.h:95
@ GNUNET_NO
Definition: gnunet_common.h:94
@ GNUNET_SYSERR
Definition: gnunet_common.h:93
#define GNUNET_PACKED
gcc-ism to get packed structs.
struct GNUNET_HashContext * GNUNET_CRYPTO_hash_context_start(void)
Start incremental hashing operation.
Definition: crypto_hash.c:348
void GNUNET_CRYPTO_hash_context_read(struct GNUNET_HashContext *hc, const void *buf, size_t size)
Add data to be hashed.
Definition: crypto_hash.c:364
void GNUNET_CRYPTO_hash_context_finish(struct GNUNET_HashContext *hc, struct GNUNET_HashCode *r_hash)
Finish the hash computation.
Definition: crypto_hash.c:388
#define GNUNET_SIGNATURE_PURPOSE_HELLO
Signature by which a peer affirms its address.
#define GNUNET_CRYPTO_eddsa_sign(priv, ps, sig)
EdDSA sign a given block.
#define GNUNET_CRYPTO_eddsa_verify(purp, ps, sig, pub)
Verify EdDSA signature.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
struct GNUNET_HELLO_Builder * GNUNET_HELLO_builder_from_block(const void *block, size_t block_size)
Parse block into builder.
Definition: hello-uri.c:353
void GNUNET_HELLO_builder_free(struct GNUNET_HELLO_Builder *builder)
Release resources of a builder.
Definition: hello-uri.c:312
enum GNUNET_GenericReturnValue GNUNET_HELLO_dht_msg_to_block(const struct GNUNET_MessageHeader *hello, const struct GNUNET_PeerIdentity *pid, void **block, size_t *block_size, struct GNUNET_TIME_Absolute *block_expiration)
Convert a DHT hello message to a HELLO block.
Definition: hello-uri.c:837
struct GNUNET_MessageHeader * GNUNET_HELLO_builder_to_dht_hello_msg(const struct GNUNET_HELLO_Builder *builder, const struct GNUNET_CRYPTO_EddsaPrivateKey *priv)
Generate DHT HELLO message (without peer ID) from a builder.
Definition: hello-uri.c:579
void GNUNET_HELLO_builder_iterate(const struct GNUNET_HELLO_Builder *builder, struct GNUNET_PeerIdentity *pid, GNUNET_HELLO_UriCallback uc, void *uc_cls)
Iterate over URIs in a builder.
Definition: hello-uri.c:815
enum GNUNET_GenericReturnValue GNUNET_HELLO_builder_del_address(struct GNUNET_HELLO_Builder *builder, const char *address)
Remove individual address from the builder.
Definition: hello-uri.c:791
#define GNUNET_HELLO_ADDRESS_EXPIRATION
For how long are HELLO signatures valid?
struct GNUNET_HELLO_Builder * GNUNET_HELLO_builder_from_msg(const struct GNUNET_MessageHeader *msg)
Parse msg into builder.
Definition: hello-uri.c:330
enum GNUNET_GenericReturnValue GNUNET_HELLO_builder_add_address(struct GNUNET_HELLO_Builder *builder, const char *address)
Add individual address to the builder.
Definition: hello-uri.c:741
enum GNUNET_GenericReturnValue GNUNET_HELLO_builder_to_block(const struct GNUNET_HELLO_Builder *builder, const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, void *block, size_t *block_size)
Generate DHT block from a builder.
Definition: hello-uri.c:692
struct GNUNET_HELLO_Builder * GNUNET_HELLO_builder_new(const struct GNUNET_PeerIdentity *pid)
Allocate builder.
Definition: hello-uri.c:301
struct GNUNET_HELLO_Builder * GNUNET_HELLO_builder_from_url(const char *url)
Parse GNUnet HELLO url into builder.
Definition: hello-uri.c:409
void(* GNUNET_HELLO_UriCallback)(void *cls, const char *uri)
Callback function used to extract URIs from a builder.
char * GNUNET_HELLO_builder_to_url(const struct GNUNET_HELLO_Builder *builder, const struct GNUNET_CRYPTO_EddsaPrivateKey *priv)
Generate GNUnet HELLO URI from a builder.
Definition: hello-uri.c:627
struct GNUNET_MQ_Envelope * GNUNET_HELLO_builder_to_env(const struct GNUNET_HELLO_Builder *builder, const struct GNUNET_CRYPTO_EddsaPrivateKey *priv)
Generate envelope with GNUnet HELLO message (including peer ID) from a builder.
Definition: hello-uri.c:547
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
#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_ERROR
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
#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.
#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
#define GNUNET_MESSAGE_TYPE_DHT_P2P_HELLO
HELLO advertising a neighbours addresses.
#define GNUNET_MESSAGE_TYPE_HELLO_URI
Latest HELLO messages used for communicating peer addresses.
size_t GNUNET_STRINGS_urldecode(const char *data, size_t len, char **out)
url/percent encode (RFC3986).
Definition: strings.c:1807
char * GNUNET_STRINGS_data_to_string_alloc(const void *buf, size_t size)
Return the base32crockford encoding of the given buffer.
Definition: strings.c:764
size_t GNUNET_STRINGS_urlencode(const char *data, size_t len, char **out)
url/percent encode (RFC3986).
Definition: strings.c:1851
enum GNUNET_GenericReturnValue GNUNET_STRINGS_string_to_data(const char *enc, size_t enclen, void *out, size_t out_size)
Convert CrockfordBase32 encoding back to data.
Definition: strings.c:789
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_from_s(uint64_t s_after_epoch)
Convert seconds after the UNIX epoch to absolute time.
Definition: time.c:702
struct GNUNET_TIME_Timestamp GNUNET_TIME_relative_to_timestamp(struct GNUNET_TIME_Relative rel)
Convert relative time to a timestamp in the future.
Definition: time.c:334
uint64_t GNUNET_TIME_timestamp_to_s(struct GNUNET_TIME_Timestamp ts)
Convert timestamp to number of seconds after the UNIX epoch.
Definition: time.c:729
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_ntoh(struct GNUNET_TIME_AbsoluteNBO a)
Convert absolute time from network byte order.
Definition: time.c:736
struct GNUNET_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton(struct GNUNET_TIME_Absolute a)
Convert absolute time to network byte order.
Definition: time.c:637
bool GNUNET_TIME_absolute_is_past(struct GNUNET_TIME_Absolute abs)
Test if abs is truly in the past (excluding now).
Definition: time.c:668
static void sign_hello(const struct GNUNET_HELLO_Builder *builder, struct GNUNET_TIME_Timestamp et, const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, struct GNUNET_CRYPTO_EddsaSignature *sig)
Create HELLO signature.
Definition: hello-uri.c:244
static enum GNUNET_GenericReturnValue verify_hello(const struct GNUNET_HELLO_Builder *builder, struct GNUNET_TIME_Absolute et, const struct GNUNET_CRYPTO_EddsaSignature *sig)
Verify HELLO signature.
Definition: hello-uri.c:273
static void hash_addresses(const struct GNUNET_HELLO_Builder *builder, struct GNUNET_HashCode *hash)
Compute hash over addresses in builder.
Definition: hello-uri.c:215
static unsigned int size
Size of the "table".
Definition: peer.c:67
Address of a peer.
Definition: hello-uri.c:157
struct Address * next
Kept in a DLL.
Definition: hello-uri.c:161
size_t uri_len
Length of uri including 0-terminator.
Definition: hello-uri.c:176
struct Address * prev
Kept in a DLL.
Definition: hello-uri.c:166
const char * uri
Actual URI, allocated at the end of this struct.
Definition: hello-uri.c:171
Start of a 'block'.
Definition: hello-uri.c:96
struct GNUNET_TIME_AbsoluteNBO expiration_time
When does the HELLO expire?
Definition: hello-uri.c:110
struct GNUNET_CRYPTO_EddsaSignature sig
Signature over the block, of purpose GNUNET_SIGNATURE_PURPOSE_HELLO.
Definition: hello-uri.c:105
struct GNUNET_PeerIdentity pid
Public key of the peer.
Definition: hello-uri.c:100
Message used when a DHT provides its HELLO to direct neighbours.
Definition: hello-uri.c:120
uint16_t reserved
Reserved.
Definition: hello-uri.c:129
struct GNUNET_TIME_AbsoluteNBO expiration_time
When does the HELLO expire?
Definition: hello-uri.c:144
struct GNUNET_MessageHeader header
Type must be GNUNET_MESSAGE_TYPE_DHT_P2P_HELLO.
Definition: hello-uri.c:124
struct GNUNET_CRYPTO_EddsaSignature sig
Signature over the block, of purpose GNUNET_SIGNATURE_PURPOSE_HELLO.
Definition: hello-uri.c:139
uint16_t url_counter
Number of URLs encoded after the end of the struct, in NBO.
Definition: hello-uri.c:134
header of what an ECC signature signs this must be followed by "size - 8" bytes of the actual signed ...
uint32_t size
How many bytes does this signature sign? (including this purpose header); in network byte order (!...
Private ECC key encoded for transmission.
an ECC signature using EdDSA.
Context for building (or parsing) HELLO URIs.
Definition: hello-uri.c:184
struct GNUNET_PeerIdentity pid
Public key of the peer.
Definition: hello-uri.c:188
struct Address * a_tail
Tail of the addresses DLL.
Definition: hello-uri.c:198
struct Address * a_head
Head of the addresses DLL.
Definition: hello-uri.c:193
unsigned int a_length
Length of the a_head DLL.
Definition: hello-uri.c:203
A 512-bit hashcode.
Header for all communications.
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
The identity of the host (wraps the signing key of the peer).
Time for absolute time used by GNUnet, in microseconds and in network byte order.
Time for absolute times used by GNUnet, in microseconds.
Rounded time for timestamps used by GNUnet, in seconds.
struct GNUNET_TIME_Absolute abs_time
The actual value.
Message signed as part of a HELLO block/URL.
Definition: hello-uri.c:50
struct GNUNET_CRYPTO_EccSignaturePurpose purpose
Purpose must be GNUNET_SIGNATURE_PURPOSE_HELLO.
Definition: hello-uri.c:54
struct GNUNET_TIME_AbsoluteNBO expiration_time
When does the signature expire?
Definition: hello-uri.c:59
struct GNUNET_HashCode h_addrs
Hash over all addresses.
Definition: hello-uri.c:64
Message used when gossiping HELLOs between peers.
Definition: hello-uri.c:72
uint16_t reserved
Reserved.
Definition: hello-uri.c:81
uint16_t url_counter
Number of URLs encoded after the end of the struct, in NBO.
Definition: hello-uri.c:86
struct GNUNET_MessageHeader header
Type must be GNUNET_MESSAGE_TYPE_HELLO_URI.
Definition: hello-uri.c:76