GNUnet  0.11.x
gnunet-abd.c
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet.
3  Copyright (C) 2012-2013 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"
26 #include <gnunet_util_lib.h>
27 #include <gnunet_abd_service.h>
28 #include <gnunet_gnsrecord_lib.h>
30 #include "delegate_misc.h"
31 #include "abd_serialization.h"
32 
36 static const struct GNUNET_CONFIGURATION_Handle *cfg;
37 
41 static struct GNUNET_NAMESTORE_Handle *ns;
42 
47 
52 
56 static struct GNUNET_ABD_Handle *abd;
57 
62 
67 
72 
76 static struct GNUNET_SCHEDULER_Task *tt;
77 
81 static int ret = 0;
82 
86 static char *subject;
87 
91 static char *subject_delegate;
92 
96 static char *expiration;
97 
102 
107 
108 
112 static char *issuer_key;
113 
117 static char *ego_name;
118 
122 static char *issuer_attr;
123 
127 static int verify;
128 
132 static int collect;
133 
137 static int create_is;
138 
142 static int create_ss;
143 
147 static int sign_ss;
148 
152 static char *import;
153 
157 static int is_private;
158 
162 static int forward;
163 
167 static int backward;
168 
173 
178 
182 static void *data;
183 
187 static size_t data_size;
188 
192 static uint32_t type;
193 
197 static char *typestring;
201 static uint64_t etime;
202 
207 
211 static const int key_length = 52;
212 
216 static char *record_label;
217 
223 static void
224 do_shutdown (void *cls)
225 {
226  if (NULL != verify_request)
227  {
228  GNUNET_ABD_request_cancel (verify_request);
229  verify_request = NULL;
230  }
231  if (NULL != abd)
232  {
233  GNUNET_ABD_disconnect (abd);
234  abd = NULL;
235  }
236  if (NULL != tt)
237  {
239  tt = NULL;
240  }
241  if (NULL != el)
242  {
244  el = NULL;
245  }
246  if (NULL != add_qe)
247  {
248  GNUNET_NAMESTORE_cancel (add_qe);
249  add_qe = NULL;
250  }
251  if (NULL != ns)
252  {
254  ns = NULL;
255  }
256 }
257 
258 
264 static void
265 do_timeout (void *cls)
266 {
267  tt = NULL;
269 }
270 
271 
272 static void
274  struct GNUNET_ABD_Delegation *dd,
275  bool is_bw)
276 {
277  char *prefix = "";
278  if (is_bw)
279  prefix = "Backward -";
280  else
281  prefix = "Forward -";
282 
283  printf ("%s Intermediate result: %s.%s <- %s.%s\n",
284  prefix,
286  dd->issuer_attribute,
288  dd->subject_attribute);
289 }
290 
291 
292 static void
294  unsigned int d_count,
295  struct GNUNET_ABD_Delegation *dc,
296  unsigned int c_count,
297  struct GNUNET_ABD_Delegate *dele)
298 {
299  int i;
300  char *line;
301 
302  verify_request = NULL;
303  if (NULL != dele)
304  {
305  for (i = 0; i < c_count; i++)
306  {
307  line = GNUNET_ABD_delegate_to_string (&dele[i]);
308  printf ("%s\n", line);
309  GNUNET_free (line);
310  }
311  }
312  else
313  {
314  printf ("Received NULL\n");
315  }
316 
318 }
319 
320 
321 static void
323  unsigned int d_count,
324  struct GNUNET_ABD_Delegation *dc,
325  unsigned int c_count,
326  struct GNUNET_ABD_Delegate *dele)
327 {
328  int i;
329  char *iss_key;
330  char *sub_key;
331 
332  verify_request = NULL;
333  if (NULL == dele)
334  ret = 1;
335  else
336  {
337  printf ("Delegation Chain:\n");
338  for (i = 0; i < d_count; i++)
339  {
341  sub_key = GNUNET_CRYPTO_ecdsa_public_key_to_string (&dc[i].subject_key);
342 
343  if (0 != dc[i].subject_attribute_len)
344  {
345  printf ("(%d) %s.%s <- %s.%s\n",
346  i,
347  iss_key,
348  dc[i].issuer_attribute,
349  sub_key,
350  dc[i].subject_attribute);
351  }
352  else
353  {
354  printf ("(%d) %s.%s <- %s\n",
355  i,
356  iss_key,
357  dc[i].issuer_attribute,
358  sub_key);
359  }
360  GNUNET_free (iss_key);
361  GNUNET_free (sub_key);
362  }
363  printf ("\nDelegate(s):\n");
364  for (i = 0; i < c_count; i++)
365  {
367  sub_key = GNUNET_CRYPTO_ecdsa_public_key_to_string (&dele[i].subject_key);
368  printf ("%s.%s <- %s\n", iss_key, dele[i].issuer_attribute, sub_key);
369  GNUNET_free (iss_key);
370  GNUNET_free (sub_key);
371  }
372  printf ("Successful.\n");
373  }
374 
376 }
377 
378 
386 static void
387 identity_cb (void *cls, const struct GNUNET_IDENTITY_Ego *ego)
388 {
389  const struct GNUNET_CRYPTO_EcdsaPrivateKey *privkey;
390 
391  el = NULL;
392  if (NULL == ego)
393  {
394  if (NULL != ego_name)
395  {
396  fprintf (stderr,
397  _ ("Ego `%s' not known to identity service\n"),
398  ego_name);
399  }
401  return;
402  }
403 
404  if (GNUNET_YES == collect)
405  {
406 
407  if (GNUNET_OK !=
409  strlen (issuer_key),
410  &issuer_pkey))
411  {
412  fprintf (stderr,
413  _ ("Issuer public key `%s' is not well-formed\n"),
414  issuer_key);
416  }
417  privkey = GNUNET_IDENTITY_ego_get_private_key (ego);
418 
419  collect_request = GNUNET_ABD_collect (abd,
420  &issuer_pkey,
421  issuer_attr,
422  privkey,
423  direction,
425  NULL,
427  NULL);
428  return;
429  }
431 }
432 
433 
442 static int
444  int *etime_is_rel,
445  uint64_t *etime)
446 {
447  // copied from namestore/gnunet-namestore.c
448  struct GNUNET_TIME_Relative etime_rel;
449  struct GNUNET_TIME_Absolute etime_abs;
450 
451  if (0 == strcmp (expirationstring, "never"))
452  {
453  *etime = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us;
454  *etime_is_rel = GNUNET_NO;
455  return GNUNET_OK;
456  }
457  if (GNUNET_OK ==
458  GNUNET_STRINGS_fancy_time_to_relative (expirationstring, &etime_rel))
459  {
460  *etime_is_rel = GNUNET_YES;
461  *etime = etime_rel.rel_value_us;
463  "Storing record with relative expiration time of %s\n",
465  return GNUNET_OK;
466  }
467  if (GNUNET_OK ==
468  GNUNET_STRINGS_fancy_time_to_absolute (expirationstring, &etime_abs))
469  {
470  *etime_is_rel = GNUNET_NO;
471  *etime = etime_abs.abs_value_us;
473  "Storing record with absolute expiration time of %s\n",
475  return GNUNET_OK;
476  }
477  return GNUNET_SYSERR;
478 }
479 
480 
484 static void
485 error_cb (void *cls)
486 {
487  fprintf (stderr, "Error occured during lookup, shutting down.\n");
489  return;
490 }
491 
492 
493 static void
494 add_continuation (void *cls, int32_t success, const char *emsg)
495 {
496  struct GNUNET_NAMESTORE_QueueEntry **qe = cls;
497  *qe = NULL;
498 
499  if (GNUNET_OK == success)
500  printf ("Adding successful.\n");
501  else
502  fprintf (stderr, "Error occured during adding, shutting down.\n");
503 
505 }
506 
507 
508 static void
510  const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key,
511  const char *rec_name,
512  unsigned int rd_count,
513  const struct GNUNET_GNSRECORD_Data *rd)
514 {
515  struct GNUNET_GNSRECORD_Data rdn[rd_count + 1];
516  struct GNUNET_GNSRECORD_Data *rde;
517 
518  memset (rdn, 0, sizeof (struct GNUNET_GNSRECORD_Data));
519  GNUNET_memcpy (&rdn[1], rd, rd_count * sizeof (struct GNUNET_GNSRECORD_Data));
520  rde = &rdn[0];
521  rde->data = data;
522  rde->data_size = data_size;
523  rde->record_type = type;
524 
525  // Set flags
526  if (GNUNET_YES == is_private)
528  rde->expiration_time = etime;
529  if (GNUNET_YES == etime_is_rel)
531  else if (GNUNET_NO != etime_is_rel)
532  rde->expiration_time = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us;
533 
534  GNUNET_assert (NULL != rec_name);
535  add_qe = GNUNET_NAMESTORE_records_store (ns,
536  &zone_pkey,
537  rec_name,
538  rd_count + 1,
539  rde,
541  &add_qe);
542 
543  return;
544 }
545 
546 
547 static void
548 store_cb (void *cls, const struct GNUNET_IDENTITY_Ego *ego)
549 {
550  const struct GNUNET_CONFIGURATION_Handle *cfg = cls;
551 
552  el = NULL;
553 
554  ns = GNUNET_NAMESTORE_connect (cfg);
555  if (NULL == ns)
556  {
558  _ ("Failed to connect to namestore\n"));
560  return;
561  }
562 
563  // Key handling
565 
567  {
568  // Parse import
569  struct GNUNET_ABD_Delegate *cred;
570  cred = GNUNET_ABD_delegate_from_string (import);
571 
572  // Get import subject public key string
573  char *subject_pubkey_str =
575 
576  // Get zone public key string
577  struct GNUNET_CRYPTO_EcdsaPublicKey zone_pubkey;
578  GNUNET_IDENTITY_ego_get_public_key (ego, &zone_pubkey);
579  char *zone_pubkey_str =
581 
582  // Check if the subject key in the signed import matches the zone's key it is issued to
583  if (strcmp (zone_pubkey_str, subject_pubkey_str) != 0)
584  {
585  fprintf (stderr,
586  "Import signed delegate does not match this ego's public key.\n");
588  return;
589  }
590 
591  // Expiration
592  etime = cred->expiration.abs_value_us;
594 
595  // Prepare the data to be store in the record
596  data_size = GNUNET_ABD_delegate_serialize (cred, (char **) &data);
597  GNUNET_free (cred);
598  }
599  else
600  {
601  // For all other types e.g. GNUNET_GNSRECORD_TYPE_ATTRIBUTE
602  if (GNUNET_OK !=
604  {
605  fprintf (stderr,
606  "Value `%s' invalid for record type `%s'\n",
607  subject,
608  typestring);
610  return;
611  }
612 
613  // Take care of expiration
614  if (NULL == expiration)
615  {
616  fprintf (stderr, "Missing option -e for operation 'create'\n");
618  return;
619  }
621  {
622  fprintf (stderr, "Invalid time format `%s'\n", expiration);
624  return;
625  }
626  }
627 
628  // Start lookup
629  add_qe = GNUNET_NAMESTORE_records_lookup (ns,
630  &zone_pkey,
631  record_label,
632  &error_cb,
633  NULL,
635  NULL);
636  return;
637 }
638 
639 
640 static void
641 sign_cb (void *cls, const struct GNUNET_IDENTITY_Ego *ego)
642 {
643  const struct GNUNET_CRYPTO_EcdsaPrivateKey *privkey;
644  struct GNUNET_ABD_Delegate *dele;
645  struct GNUNET_TIME_Absolute etime_abs;
646  char *res;
647 
648  el = NULL;
649 
650  // work on expiration time
651  if (NULL == expiration)
652  {
653  fprintf (stderr, "Please specify a TTL\n");
655  return;
656  }
657  else if (GNUNET_OK !=
659  {
660  fprintf (stderr,
661  "%s is not a valid ttl! Only absolute times are accepted!\n",
662  expiration);
664  return;
665  }
666 
667  // If contains a space - split it by the first space only - assume first entry is subject followed by attribute(s)
668  char *subject_pubkey_str;
669  char *subject_attr = NULL;
670  char *token;
671 
672  // Subject Public Key
673  token = strtok (subject, " ");
674  if (key_length == strlen (token))
675  {
676  subject_pubkey_str = token;
677  }
678  else
679  {
680  fprintf (stderr, "Key error, wrong length: %ld!\n", strlen (token));
682  return;
683  }
684  // Subject Attribute(s)
685  token = strtok (NULL, " ");
686  if (NULL != token)
687  {
688  subject_attr = token;
689  }
690 
691  // work on keys
692  privkey = GNUNET_IDENTITY_ego_get_private_key (ego);
693 
694  if (GNUNET_OK !=
695  GNUNET_CRYPTO_ecdsa_public_key_from_string (subject_pubkey_str,
696  strlen (subject_pubkey_str),
697  &subject_pkey))
698  {
699  fprintf (stderr,
700  "Subject public key `%s' is not well-formed\n",
701  subject_pubkey_str);
703  return;
704  }
705 
706  // Sign delegate
707  dele = GNUNET_ABD_delegate_issue (privkey,
708  &subject_pkey,
709  issuer_attr,
710  subject_attr,
711  &etime_abs);
712  res = GNUNET_ABD_delegate_to_string (dele);
713  GNUNET_free (dele);
714  printf ("%s\n", res);
715 
717  ego_name = NULL;
718 
720 }
721 
722 
731 static void
732 run (void *cls,
733  char *const *args,
734  const char *cfgfile,
735  const struct GNUNET_CONFIGURATION_Handle *c)
736 {
737  cfg = c;
738 
741 
742  // Check relevant cmdline parameters
743  if (GNUNET_YES == create_is)
744  {
745  if (NULL == ego_name)
746  {
747  fprintf (stderr, "Missing option '-ego'\n");
749  return;
750  }
751  if (NULL == issuer_attr)
752  {
753  fprintf (stderr, "Missing option '-attribute' for issuer attribute\n");
755  return;
756  }
757  if (NULL == subject)
758  {
759  fprintf (stderr, "Missing option -subject for operation 'create'.'\n");
761  return;
762  }
763 
764  // Lookup ego, on success call store_cb and store as ATTRIBUTE type
767  el = GNUNET_IDENTITY_ego_lookup (cfg, ego_name, &store_cb, (void *) cfg);
768  return;
769  }
770 
771  if (GNUNET_YES == create_ss)
772  {
773 
774  // check if signed parameter has been passed in cmd line call
775  if (NULL == import)
776  {
777  fprintf (stderr, "'import' required\n");
779  return;
780  }
781 
784  // Store subject side
785  el = GNUNET_IDENTITY_ego_lookup (cfg, ego_name, &store_cb, (void *) cfg);
786 
787  return;
788  }
789 
790  if (GNUNET_YES == sign_ss)
791  {
792  if (NULL == ego_name)
793  {
794  fprintf (stderr, "ego required\n");
796  return;
797  }
798  if (NULL == subject)
799  {
800  fprintf (stderr, "Subject public key needed\n");
802  return;
803  }
804 
805  // lookup ego and call function sign_cb on success
806  el = GNUNET_IDENTITY_ego_lookup (cfg, ego_name, &sign_cb, (void *) cfg);
807  return;
808  }
809 
810  if ((GNUNET_NO == forward) && (GNUNET_NO == backward))
811  {
812  // set default: bidirectional
815  }
816  if (GNUNET_YES == forward)
818  if (GNUNET_YES == backward)
820 
821  if (GNUNET_YES == collect)
822  {
823  if (NULL == issuer_key)
824  {
825  fprintf (stderr, _ ("Issuer public key not well-formed\n"));
827  return;
828  }
829 
830  abd = GNUNET_ABD_connect (cfg);
831 
832  if (NULL == abd)
833  {
834  fprintf (stderr, _ ("Failed to connect to ABD\n"));
836  return;
837  }
838  if (NULL == issuer_attr)
839  {
840  fprintf (stderr, _ ("You must provide issuer the attribute\n"));
842  return;
843  }
844 
845  if (NULL == ego_name)
846  {
847  fprintf (stderr, _ ("ego required\n"));
849  return;
850  }
851  el = GNUNET_IDENTITY_ego_lookup (cfg, ego_name, &identity_cb, (void *) cfg);
852  return;
853  }
854 
855  if (NULL == subject)
856  {
857  fprintf (stderr, _ ("Subject public key needed\n"));
859  return;
860  }
862  strlen (subject),
863  &subject_pkey))
864  {
865  fprintf (stderr,
866  _ ("Subject public key `%s' is not well-formed\n"),
867  subject);
869  return;
870  }
871 
872  if (GNUNET_YES == verify)
873  {
874  if (NULL == issuer_key)
875  {
876  fprintf (stderr, _ ("Issuer public key not well-formed\n"));
878  return;
879  }
880  if (GNUNET_OK !=
882  strlen (issuer_key),
883  &issuer_pkey))
884  {
885  fprintf (stderr,
886  _ ("Issuer public key `%s' is not well-formed\n"),
887  issuer_key);
889  return;
890  }
891  abd = GNUNET_ABD_connect (cfg);
892 
893  if (NULL == abd)
894  {
895  fprintf (stderr, _ ("Failed to connect to ABD\n"));
897  return;
898  }
899  if ((NULL == issuer_attr) || (NULL == subject_delegate))
900  {
901  fprintf (stderr, _ ("You must provide issuer and subject attributes\n"));
903  return;
904  }
905 
906  // Subject credentials are comma separated
907  char *tmp = GNUNET_strdup (subject_delegate);
908  char *tok = strtok (tmp, ",");
909  if (NULL == tok)
910  {
911  fprintf (stderr, "Invalid subject credentials\n");
912  GNUNET_free (tmp);
914  return;
915  }
916  int count = 1;
917  int i;
918  while (NULL != (tok = strtok (NULL, ",")))
919  count++;
920  struct GNUNET_ABD_Delegate delegates[count];
921  struct GNUNET_ABD_Delegate *dele;
922  GNUNET_free (tmp);
924  tok = strtok (tmp, ",");
925  for (i = 0; i < count; i++)
926  {
927  dele = GNUNET_ABD_delegate_from_string (tok);
928  GNUNET_memcpy (&delegates[i],
929  dele,
930  sizeof (struct GNUNET_ABD_Delegate));
931  delegates[i].issuer_attribute = GNUNET_strdup (dele->issuer_attribute);
932  tok = strtok (NULL, ",");
933  GNUNET_free (dele);
934  }
935 
936  verify_request = GNUNET_ABD_verify (abd,
937  &issuer_pkey,
938  issuer_attr,
939  &subject_pkey,
940  count,
941  delegates,
942  direction,
944  NULL,
946  NULL);
947  for (i = 0; i < count; i++)
948  {
949  GNUNET_free ((char *) delegates[i].issuer_attribute);
950  }
951  GNUNET_free (tmp);
952  }
953  else
954  {
955  fprintf (stderr,
956  _ (
957  "Please specify name to lookup, subject key and issuer key!\n"));
959  }
960  return;
961 }
962 
963 
971 int
972 main (int argc, char *const *argv)
973 {
974  struct GNUNET_GETOPT_CommandLineOption options[] =
976  "verify",
977  gettext_noop (
978  "verify credential against attribute"),
979  &verify),
981  's',
982  "subject",
983  "PKEY",
984  gettext_noop (
985  "The public key of the subject to lookup the"
986  "credential for, or for issuer side storage: subject and its attributes"),
987  &subject),
989  'd',
990  "delegate",
991  "DELE",
992  gettext_noop ("The private, signed delegate presented by the subject"),
995  'i',
996  "issuer",
997  "PKEY",
998  gettext_noop (
999  "The public key of the authority to verify the credential against"),
1000  &issuer_key),
1002  "ego",
1003  "EGO",
1004  gettext_noop ("The ego/zone name to use"),
1005  &ego_name),
1007  'a',
1008  "attribute",
1009  "ATTR",
1010  gettext_noop ("The issuer attribute to verify against or to issue"),
1011  &issuer_attr),
1013  "ttl",
1014  "EXP",
1015  gettext_noop (
1016  "The time to live for the credential."
1017  "e.g. 5m, 6h, \"1990-12-30 12:00:00\""),
1018  &expiration),
1020  "collect",
1021  gettext_noop ("collect credentials"),
1022  &collect),
1024  "createIssuerSide",
1025  gettext_noop (
1026  "Create and issue a credential issuer side."),
1027  &create_is),
1029  "createSubjectSide",
1030  gettext_noop (
1031  "Issue a credential subject side."),
1032  &create_ss),
1034  'S',
1035  "signSubjectSide",
1036  gettext_noop ("Create, sign and return a credential subject side."),
1037  &sign_ss),
1039  'x',
1040  "import",
1041  "IMP",
1042  gettext_noop (
1043  "Import signed credentials that should be issued to a zone/ego"),
1044  &import),
1046  "private",
1047  gettext_noop ("Create private record entry."),
1048  &is_private),
1050  'F',
1051  "forward",
1052  gettext_noop (
1053  "Indicates that the collect/verify process is done via forward search."),
1054  &forward),
1056  'B',
1057  "backward",
1058  gettext_noop (
1059  "Indicates that the collect/verify process is done via forward search."),
1060  &backward),
1062 
1063 
1065  if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
1066  return 2;
1067 
1068  GNUNET_log_setup ("gnunet-abd", "WARNING", NULL);
1069  if (GNUNET_OK != GNUNET_PROGRAM_run (argc,
1070  argv,
1071  "gnunet-abd",
1072  _ ("GNUnet abd resolver tool"),
1073  options,
1074  &run,
1075  NULL))
1076  ret = 1;
1077  GNUNET_free ((void *) argv);
1078  return ret;
1079 }
1080 
1081 
1082 /* end of gnunet-abd.c */
static void handle_verify_result(void *cls, unsigned int d_count, struct GNUNET_ABD_Delegation *dc, unsigned int c_count, struct GNUNET_ABD_Delegate *dele)
Definition: gnunet-abd.c:322
static struct GNUNET_DATASTORE_QueueEntry * qe
Current operation.
static char * typestring
Type of the record to add/remove, NULL to remove all.
Definition: gnunet-abd.c:197
struct GNUNET_CRYPTO_EcdsaPublicKey subject_key
Public key of the subject this credential was issued to.
static int create_is
Create mode.
Definition: gnunet-abd.c:137
struct GNUNET_ABD_Handle * GNUNET_ABD_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Initialize the connection with the ABD service.
Definition: abd_api.c:355
void GNUNET_IDENTITY_ego_lookup_cancel(struct GNUNET_IDENTITY_EgoLookup *el)
Abort ego lookup attempt.
Handle for ego lookup.
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
uint64_t rel_value_us
The actual value.
char * GNUNET_ABD_delegate_to_string(const struct GNUNET_ABD_Delegate *cred)
Definition: delegate_misc.c:37
static void handle_collect_result(void *cls, unsigned int d_count, struct GNUNET_ABD_Delegation *dc, unsigned int c_count, struct GNUNET_ABD_Delegate *dele)
Definition: gnunet-abd.c:293
#define GNUNET_GNS_EMPTY_LABEL_AT
String we use to indicate an empty label (top-level entry in the zone).
static struct GNUNET_SCHEDULER_Task * tt
Task scheduled to handle timeout.
Definition: gnunet-abd.c:76
struct GNUNET_NAMESTORE_QueueEntry * GNUNET_NAMESTORE_records_lookup(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, const char *label, GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, GNUNET_NAMESTORE_RecordMonitor rm, void *rm_cls)
Lookup an item in the namestore.
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:1300
static void error_cb(void *cls)
Function called if lookup fails.
Definition: gnunet-abd.c:485
int GNUNET_STRINGS_get_utf8_args(int argc, char *const *argv, int *u8argc, char *const **u8argv)
Returns utf-8 encoded arguments.
Definition: strings.c:1438
static size_t data_size
Number of bytes in data.
Definition: gnunet-abd.c:187
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
int GNUNET_STRINGS_fancy_time_to_relative(const char *fancy_time, struct GNUNET_TIME_Relative *rtime)
Convert a given fancy human-readable time to our internal representation.
Definition: strings.c:351
static void handle_intermediate_result(void *cls, struct GNUNET_ABD_Delegation *dd, bool is_bw)
Definition: gnunet-abd.c:273
const struct GNUNET_CRYPTO_EcdsaPrivateKey * GNUNET_IDENTITY_ego_get_private_key(const struct GNUNET_IDENTITY_Ego *ego)
Obtain the ECC key associated with a ego.
Definition: identity_api.c:555
GNUNET_ABD_AlgoDirectionFlags
struct GNUNET_ABD_Delegate * GNUNET_ABD_delegate_issue(const struct GNUNET_CRYPTO_EcdsaPrivateKey *issuer, struct GNUNET_CRYPTO_EcdsaPublicKey *subject, const char *iss_attr, const char *sub_attr, struct GNUNET_TIME_Absolute *expiration)
Issue an attribute to a subject.
struct GNUNET_ABD_Request * GNUNET_ABD_collect(struct GNUNET_ABD_Handle *handle, const struct GNUNET_CRYPTO_EcdsaPublicKey *issuer_key, const char *issuer_attribute, const struct GNUNET_CRYPTO_EcdsaPrivateKey *subject_key, enum GNUNET_ABD_AlgoDirectionFlags direction, GNUNET_ABD_CredentialResultProcessor proc, void *proc_cls, GNUNET_ABD_IntermediateResultProcessor proc2, void *proc2_cls)
Performs attribute collection.
Definition: abd_api.c:424
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
int GNUNET_STRINGS_fancy_time_to_absolute(const char *fancy_time, struct GNUNET_TIME_Absolute *atime)
Convert a given fancy human-readable time to our internal representation.
Definition: strings.c:402
#define GNUNET_NO
Definition: gnunet_common.h:78
struct GNUNET_CRYPTO_EcdsaPublicKey issuer_pkey
Issuer key.
Definition: gnunet-abd.c:106
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
size_t data_size
Number of bytes in data.
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
Definition of a command line option.
Private ECC key encoded for transmission.
Delegate helper functions.
Handle to a verify request.
Definition: abd_api.c:43
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:526
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
uint64_t abs_value_us
The actual value.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_OPTION_END
Definition: 002.c:13
enum GNUNET_ABD_AlgoDirectionFlags direction
API enum, filled and passed for collect/verify.
Definition: gnunet-abd.c:172
void GNUNET_NAMESTORE_cancel(struct GNUNET_NAMESTORE_QueueEntry *qe)
Cancel a namestore operation.
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.
#define GNUNET_TIME_UNIT_FOREVER_ABS
Constant used to specify "forever".
#define _(String)
GNU gettext support macro.
Definition: platform.h:180
struct GNUNET_NAMESTORE_QueueEntry * GNUNET_NAMESTORE_records_store(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd, GNUNET_NAMESTORE_ContinuationWithStatus cont, void *cont_cls)
Store an item in the namestore.
static int parse_expiration(const char *expirationstring, int *etime_is_rel, uint64_t *etime)
Parse expiration time.
Definition: gnunet-abd.c:443
static void do_timeout(void *cls)
Task run on timeout.
Definition: gnunet-abd.c:265
int GNUNET_ABD_delegate_serialize(struct GNUNET_ABD_Delegate *dele, char **data)
void GNUNET_NAMESTORE_disconnect(struct GNUNET_NAMESTORE_Handle *h)
Disconnect from the namestore service (and free associated resources).
#define GNUNET_GNSRECORD_TYPE_DELEGATE
65546 reserved
static char * record_label
Record label for storing delegations.
Definition: gnunet-abd.c:216
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:1253
Handle for an ego.
Definition: identity.h:245
static struct GNUNET_TIME_Relative timeout
Desired timeout for the lookup (default is no timeout).
Definition: gnunet-abd.c:61
const void * data
Binary value stored in the DNS record.
static char * line
Desired phone line (string to be converted to a hash).
struct GNUNET_ABD_Delegate * GNUNET_ABD_delegate_from_string(const char *s)
Definition: delegate_misc.c:80
Connection to the NAMESTORE service.
uint64_t expiration_time
Expiration time for the DNS record.
static char * subject_delegate
Subject delegate string.
Definition: gnunet-abd.c:91
static struct GNUNET_NAMESTORE_Handle * ns
Handle to the namestore.
Definition: gnunet-abd.c:41
static void sign_cb(void *cls, const struct GNUNET_IDENTITY_Ego *ego)
Definition: gnunet-abd.c:641
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
Definition: strings.c:687
static const int key_length
Fixed size of the public/private keys.
Definition: gnunet-abd.c:211
static int is_private
Is record private.
Definition: gnunet-abd.c:157
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
struct GNUNET_CRYPTO_EcdsaPublicKey subject_pkey
Subject key.
Definition: gnunet-abd.c:101
This is a private record of this peer and it should thus not be handed out to other peers...
static int forward
Search direction: forward.
Definition: gnunet-abd.c:162
struct GNUNET_CRYPTO_EcdsaPublicKey issuer_key
The issuer of the delegation.
static void do_shutdown(void *cls)
Task run on shutdown.
Definition: gnunet-abd.c:224
int GNUNET_GNSRECORD_string_to_value(uint32_t type, const char *s, void **data, size_t *data_size)
Convert human-readable version of a &#39;value&#39; of a record to the binary representation.
Definition: gnsrecord.c:175
static char * expiration
Credential TTL.
Definition: gnunet-abd.c:96
static int res
char * GNUNET_CRYPTO_ecdsa_public_key_to_string(const struct GNUNET_CRYPTO_EcdsaPublicKey *pub)
Convert a public key to a string.
Definition: crypto_ecc.c:237
static char * issuer_key
Issuer pubkey string.
Definition: gnunet-abd.c:112
static int collect
Collect mode.
Definition: gnunet-abd.c:132
Connection to the ABD service.
Definition: abd_api.c:96
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
static struct GNUNET_ABD_Request * collect_request
Handle to collect request.
Definition: gnunet-abd.c:71
static int create_ss
Create mode.
Definition: gnunet-abd.c:142
An QueueEntry used to store information for a pending NAMESTORE record operation. ...
Definition: namestore_api.c:53
static char * expirationstring
Desired expiration time.
struct GNUNET_NAMESTORE_Handle * GNUNET_NAMESTORE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the namestore service.
static struct GNUNET_ABD_Handle * abd
Handle to Credential service.
Definition: gnunet-abd.c:56
static void store_cb(void *cls, const struct GNUNET_IDENTITY_Ego *ego)
Definition: gnunet-abd.c:548
static void * data
Value in binary format.
Definition: gnunet-abd.c:182
void GNUNET_IDENTITY_ego_get_public_key(const struct GNUNET_IDENTITY_Ego *ego, struct GNUNET_CRYPTO_EcdsaPublicKey *pk)
Get the identifier (public key) of an ego.
Definition: identity_api.c:568
const char * subject_attribute
The attribute.
static int backward
Search direction: backward.
Definition: gnunet-abd.c:167
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.
static struct GNUNET_CRYPTO_EcdsaPrivateKey zone_pkey
Private key for the our zone.
Definition: gnunet-abd.c:46
static char * subject
Subject pubkey string.
Definition: gnunet-abd.c:86
struct GNUNET_CRYPTO_EcdsaPublicKey subject_key
Public key of the subject this attribute was delegated to.
void GNUNET_ABD_request_cancel(struct GNUNET_ABD_Request *lr)
Cancel pending verify request.
Definition: abd_api.c:400
int GNUNET_CRYPTO_ecdsa_public_key_from_string(const char *enc, size_t enclen, struct GNUNET_CRYPTO_EcdsaPublicKey *pub)
Convert a string representing a public key to a public key.
Definition: crypto_ecc.c:371
uint32_t record_type
Type of the GNS/DNS record.
configuration data
Definition: configuration.c:85
static struct GNUNET_NAMESTORE_QueueEntry * add_qe
Queue entry for the &#39;add&#39; operation.
Definition: gnunet-abd.c:177
Public ECC key (always for Curve25519) encoded in a format suitable for network transmission and ECDS...
static struct GNUNET_ABD_Request * verify_request
Handle to verify request.
Definition: gnunet-abd.c:66
static uint32_t type
Type string converted to DNS type value.
Definition: gnunet-abd.c:192
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.
#define GNUNET_GNSRECORD_TYPE_ATTRIBUTE
Record type for reverse lookups.
#define GNUNET_log(kind,...)
Entry in list of pending tasks.
Definition: scheduler.c:134
struct GNUNET_TIME_Absolute expiration
Expiration of this credential.
static void run(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c)
Main function that will be run.
Definition: gnunet-abd.c:732
int GNUNET_PROGRAM_run(int argc, char *const *argv, const char *binaryName, const char *binaryHelp, const struct GNUNET_GETOPT_CommandLineOption *options, GNUNET_PROGRAM_Main task, void *task_cls)
Run a standard GNUnet command startup sequence (initialize loggers and configuration, parse options).
Definition: program.c:367
Time for absolute times used by GNUnet, in microseconds.
#define GNUNET_YES
Definition: gnunet_common.h:77
static int etime_is_rel
Is expiration time relative or absolute time?
Definition: gnunet-abd.c:206
void GNUNET_ABD_disconnect(struct GNUNET_ABD_Handle *handle)
Shutdown connection with the ABD service.
Definition: abd_api.c:377
const char * issuer_attribute
The attribute.
enum GNUNET_GNSRECORD_Flags flags
Flags for the record.
This flag is currently unused; former RF_PENDING flag.
const char * issuer_attribute
The issuer attribute.
static uint64_t etime
Expiration string converted to numeric value.
Definition: gnunet-abd.c:201
const char * GNUNET_STRINGS_absolute_time_to_string(struct GNUNET_TIME_Absolute t)
Like asctime, except for GNUnet time.
Definition: strings.c:742
int GNUNET_log_setup(const char *comp, const char *loglevel, const char *logfile)
Setup logging.
static int sign_ss
Create mode.
Definition: gnunet-abd.c:147
struct GNUNET_ABD_Request * GNUNET_ABD_verify(struct GNUNET_ABD_Handle *handle, const struct GNUNET_CRYPTO_EcdsaPublicKey *issuer_key, const char *issuer_attribute, const struct GNUNET_CRYPTO_EcdsaPublicKey *subject_key, uint32_t delegate_count, const struct GNUNET_ABD_Delegate *delegates, enum GNUNET_ABD_AlgoDirectionFlags direction, GNUNET_ABD_CredentialResultProcessor proc, void *proc_cls, GNUNET_ABD_IntermediateResultProcessor proc2, void *proc2_cls)
Performs attribute verification.
Definition: abd_api.c:498
static int verify
Verify mode.
Definition: gnunet-abd.c:127
static struct GNUNET_IDENTITY_EgoLookup * el
EgoLookup.
Definition: gnunet-abd.c:51
static void add_continuation(void *cls, int32_t success, const char *emsg)
Definition: gnunet-abd.c:494
int main(int argc, char *const *argv)
The main function for gnunet-gns.
Definition: gnunet-abd.c:972
API to serialize and deserialize delegation chains and abds.
static char * ego_name
ego
Definition: gnunet-abd.c:117
static char * issuer_attr
Issuer attribute.
Definition: gnunet-abd.c:122
static void get_existing_record(void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key, const char *rec_name, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
Definition: gnunet-abd.c:509
static struct GNUNET_FS_DownloadContext * dc
#define GNUNET_free(ptr)
Wrapper around free.
Time for relative time used by GNUnet, in microseconds.
#define gettext_noop(String)
Definition: gettext.h:69
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:966
static void identity_cb(void *cls, const struct GNUNET_IDENTITY_Ego *ego)
Callback invoked from identity service with ego information.
Definition: gnunet-abd.c:387