GNUnet 0.21.2
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 "gnunet_error_codes.h"
26#include "platform.h"
27#include <gnunet_util_lib.h>
28#include <gnunet_abd_service.h>
31#include "delegate_misc.h"
32#include "abd_serialization.h"
33
37static const struct GNUNET_CONFIGURATION_Handle *cfg;
38
43
48
53
57static struct GNUNET_ABD_Handle *abd;
58
63
68
73
78
82static int ret = 0;
83
87static char *subject;
88
92static char *subject_delegate;
93
97static char *expiration;
98
103
108
109
113static char *issuer_key;
114
118static char *ego_name;
119
123static char *issuer_attr;
124
128static int verify;
129
133static int collect;
134
138static int create_is;
139
143static int create_ss;
144
148static int sign_ss;
149
153static char *import;
154
158static int is_private;
159
163static int forward;
164
168static int backward;
169
174
179
183static void *data;
184
188static size_t data_size;
189
193static uint32_t type;
194
198static char *typestring;
202static uint64_t etime;
203
208
212static char *record_label;
213
219static void
220do_shutdown (void *cls)
221{
222 if (NULL != verify_request)
223 {
225 verify_request = NULL;
226 }
227 if (NULL != abd)
228 {
230 abd = NULL;
231 }
232 if (NULL != tt)
233 {
235 tt = NULL;
236 }
237 if (NULL != el)
238 {
240 el = NULL;
241 }
242 if (NULL != add_qe)
243 {
245 add_qe = NULL;
246 }
247 if (NULL != ns)
248 {
250 ns = NULL;
251 }
252}
253
254
260static void
261do_timeout (void *cls)
262{
263 tt = NULL;
265}
266
267
268static void
270 struct GNUNET_ABD_Delegation *dd,
271 bool is_bw)
272{
273 char *prefix = "";
274 if (is_bw)
275 prefix = "Backward -";
276 else
277 prefix = "Forward -";
278
279 printf ("%s Intermediate result: %s.%s <- %s.%s\n",
280 prefix,
285}
286
287
288static void
290 unsigned int d_count,
292 unsigned int c_count,
293 struct GNUNET_ABD_Delegate *dele)
294{
295 int i;
296 char *line;
297
298 verify_request = NULL;
299 if (NULL != dele)
300 {
301 for (i = 0; i < c_count; i++)
302 {
304 printf ("%s\n", line);
306 }
307 }
308 else
309 {
310 printf ("Received NULL\n");
311 }
312
314}
315
316
317static void
319 unsigned int d_count,
321 unsigned int c_count,
322 struct GNUNET_ABD_Delegate *dele)
323{
324 int i;
325 char *iss_key;
326 char *sub_key;
327
328 verify_request = NULL;
329 if (NULL == dele)
330 ret = 1;
331 else
332 {
333 printf ("Delegation Chain:\n");
334 for (i = 0; i < d_count; i++)
335 {
337 sub_key = GNUNET_CRYPTO_public_key_to_string (&dc[i].subject_key);
338
339 if (0 != dc[i].subject_attribute_len)
340 {
341 printf ("(%d) %s.%s <- %s.%s\n",
342 i,
343 iss_key,
344 dc[i].issuer_attribute,
345 sub_key,
346 dc[i].subject_attribute);
347 }
348 else
349 {
350 printf ("(%d) %s.%s <- %s\n",
351 i,
352 iss_key,
353 dc[i].issuer_attribute,
354 sub_key);
355 }
356 GNUNET_free (iss_key);
357 GNUNET_free (sub_key);
358 }
359 printf ("\nDelegate(s):\n");
360 for (i = 0; i < c_count; i++)
361 {
363 sub_key = GNUNET_CRYPTO_public_key_to_string (&dele[i].subject_key);
364 printf ("%s.%s <- %s\n", iss_key, dele[i].issuer_attribute, sub_key);
365 GNUNET_free (iss_key);
366 GNUNET_free (sub_key);
367 }
368 printf ("Successful.\n");
369 }
370
372}
373
374
382static void
383identity_cb (void *cls, struct GNUNET_IDENTITY_Ego *ego)
384{
385 const struct GNUNET_CRYPTO_PrivateKey *privkey;
386
387 el = NULL;
388 if (NULL == ego)
389 {
390 if (NULL != ego_name)
391 {
392 fprintf (stderr,
393 _ ("Ego `%s' not known to identity service\n"),
394 ego_name);
395 }
397 return;
398 }
399
400 if (GNUNET_YES == collect)
401 {
402
403 if (GNUNET_OK !=
405 &issuer_pkey))
406 {
407 fprintf (stderr,
408 _ ("Issuer public key `%s' is not well-formed\n"),
409 issuer_key);
411 }
413
417 privkey,
418 direction,
420 NULL,
422 NULL);
423 return;
424 }
426}
427
428
437static int
439 int *etime_is_rel,
440 uint64_t *etime)
441{
442 // copied from namestore/gnunet-namestore.c
443 struct GNUNET_TIME_Relative etime_rel;
444 struct GNUNET_TIME_Absolute etime_abs;
445
446 if (0 == strcmp (expirationstring, "never"))
447 {
448 *etime = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us;
450 return GNUNET_OK;
451 }
452 if (GNUNET_OK ==
454 {
456 *etime = etime_rel.rel_value_us;
458 "Storing record with relative expiration time of %s\n",
460 return GNUNET_OK;
461 }
462 if (GNUNET_OK ==
464 {
466 *etime = etime_abs.abs_value_us;
468 "Storing record with absolute expiration time of %s\n",
470 return GNUNET_OK;
471 }
472 return GNUNET_SYSERR;
473}
474
475
479static void
480error_cb (void *cls)
481{
482 fprintf (stderr, "Error occurred during lookup, shutting down.\n");
484 return;
485}
486
487
488static void
490{
491 struct GNUNET_NAMESTORE_QueueEntry **qe = cls;
492 *qe = NULL;
493
495 printf ("Adding successful.\n");
496 else
497 fprintf (stderr, "Error occurred during adding, shutting down.\n");
498
500}
501
502
503static void
505 const struct GNUNET_CRYPTO_PrivateKey *zone_key,
506 const char *rec_name,
507 unsigned int rd_count,
508 const struct GNUNET_GNSRECORD_Data *rd)
509{
510 struct GNUNET_GNSRECORD_Data *rde;
511 struct GNUNET_GNSRECORD_Data*rdn =
512 GNUNET_malloc (sizeof(*rdn) * (rd_count + 1));
513
514 memset (rdn, 0, sizeof (struct GNUNET_GNSRECORD_Data));
515 GNUNET_memcpy (&rdn[1], rd,
516 rd_count * sizeof (struct GNUNET_GNSRECORD_Data));
517 rde = &rdn[0];
518 rde->data = data;
519 rde->data_size = data_size;
520 rde->record_type = type;
521
522 // Set flags
523 if (GNUNET_YES == is_private)
525 rde->expiration_time = etime;
528 else if (GNUNET_NO != etime_is_rel)
530
531 GNUNET_assert (NULL != rec_name);
533 &zone_pkey,
534 rec_name,
535 rd_count + 1,
536 rde,
538 &add_qe);
539 GNUNET_free (rdn);
540 return;
541}
542
543
544static void
545store_cb (void *cls, struct GNUNET_IDENTITY_Ego *ego)
546{
547 const struct GNUNET_CONFIGURATION_Handle *cfg = cls;
548 struct GNUNET_ABD_Delegate *cred;
549 struct GNUNET_CRYPTO_PublicKey zone_pubkey;
550 char *subject_pubkey_str;
551 char *zone_pubkey_str;
552
553 el = NULL;
554
556 if (NULL == ns)
557 {
559 _ ("Failed to connect to namestore\n"));
561 return;
562 }
563
564 if (NULL == ego)
565 {
567 _("Ego does not exist!\n"));
569 return;
570 }
571
572 // Key handling
574
576 {
577 // Parse import
578 cred = GNUNET_ABD_delegate_from_string (import);
579
580 if (NULL == cred)
581 {
582 fprintf (stderr,
583 "%s is not a valid credential\n", import);
585 return;
586 }
587
588 // Get import subject public key string
589 subject_pubkey_str =
591
592 // Get zone public key string
593 GNUNET_IDENTITY_ego_get_public_key (ego, &zone_pubkey);
594 zone_pubkey_str =
596
597 // Check if the subject key in the signed import matches the zone's key it is issued to
598 if (strcmp (zone_pubkey_str, subject_pubkey_str) != 0)
599 {
600 fprintf (stderr,
601 "Import signed delegate does not match this ego's public key.\n");
602 GNUNET_free (cred);
604 return;
605 }
606
607 // Expiration
610
611 // Prepare the data to be store in the record
612 data_size = GNUNET_ABD_delegate_serialize (cred, (char **) &data);
613 GNUNET_free (cred);
614 }
615 else
616 {
617 // For all other types e.g. GNUNET_GNSRECORD_TYPE_ATTRIBUTE
618 if (GNUNET_OK !=
620 {
621 if (typestring == NULL)
622 {
623 fputs ("Value for unknown record type not well-formed.\n", stderr);
624 }
625 else if (subject == NULL)
626 {
627 fprintf (stderr,
628 "Value for record type `%s' not well-formed.\n",
629 typestring);
630 }
631 else
632 {
633 fprintf (stderr,
634 "Value `%s' invalid for record type `%s'\n",
635 subject,
636 typestring);
637 }
639 return;
640 }
641
642 // Take care of expiration
643 if (NULL == expiration)
644 {
645 fprintf (stderr, "Missing option -e for operation 'create'\n");
647 return;
648 }
650 {
651 fprintf (stderr, "Invalid time format `%s'\n", expiration);
653 return;
654 }
655 }
656
657 // Start lookup
659 &zone_pkey,
661 &error_cb,
662 NULL,
664 NULL);
665 return;
666}
667
668
669static void
670sign_cb (void *cls, struct GNUNET_IDENTITY_Ego *ego)
671{
672 const struct GNUNET_CRYPTO_PrivateKey *privkey;
673 struct GNUNET_ABD_Delegate *dele;
674 struct GNUNET_TIME_Absolute etime_abs;
675 char *res;
676
677 el = NULL;
678
679 // work on expiration time
680 if (NULL == expiration)
681 {
682 fprintf (stderr, "Please specify a TTL\n");
684 return;
685 }
686 else if (GNUNET_OK !=
688 {
689 fprintf (stderr,
690 "%s is not a valid ttl! Only absolute times are accepted!\n",
691 expiration);
693 return;
694 }
695
696 // If contains a space - split it by the first space only - assume first entry is subject followed by attribute(s)
697 char *subject_pubkey_str;
698 char *subject_attr = NULL;
699 char *token;
700
701 // Subject Public Key
702 token = strtok (subject, " ");
703 subject_pubkey_str = token;
704 // Subject Attribute(s)
705 token = strtok (NULL, " ");
706 if (NULL != token)
707 {
708 subject_attr = token;
709 }
710
711 // work on keys
713
714 if (NULL == subject_pubkey_str)
715 {
716 fprintf (stderr,
717 "Subject pubkey not given\n");
719 return;
720 }
721 if (GNUNET_OK !=
722 GNUNET_CRYPTO_public_key_from_string (subject_pubkey_str,
723 &subject_pkey))
724 {
725 fprintf (stderr,
726 "Subject public key `%s' is not well-formed\n",
727 subject_pubkey_str);
729 return;
730 }
731
732 // Sign delegate
733 dele = GNUNET_ABD_delegate_issue (privkey,
736 subject_attr,
737 &etime_abs);
739 GNUNET_free (dele);
740 printf ("%s\n", res);
741
743 ego_name = NULL;
744
746}
747
748
757static void
758run (void *cls,
759 char *const *args,
760 const char *cfgfile,
761 const struct GNUNET_CONFIGURATION_Handle *c)
762{
763 cfg = c;
764
767
768 // Check relevant cmdline parameters
769 if (GNUNET_YES == create_is)
770 {
771 if (NULL == ego_name)
772 {
773 fprintf (stderr, "Missing option '-ego'\n");
775 return;
776 }
777 if (NULL == issuer_attr)
778 {
779 fprintf (stderr, "Missing option '-attribute' for issuer attribute\n");
781 return;
782 }
783 if (NULL == subject)
784 {
785 fprintf (stderr, "Missing option -subject for operation 'create'.'\n");
787 return;
788 }
789
790 // Lookup ego, on success call store_cb and store as ATTRIBUTE type
794 return;
795 }
796
797 if (GNUNET_YES == create_ss)
798 {
799
800 // check if signed parameter has been passed in cmd line call
801 if (NULL == import)
802 {
803 fprintf (stderr, "'import' required\n");
805 return;
806 }
807
810 // Store subject side
812
813 return;
814 }
815
816 if (GNUNET_YES == sign_ss)
817 {
818 if (NULL == ego_name)
819 {
820 fprintf (stderr, "ego required\n");
822 return;
823 }
824 if (NULL == subject)
825 {
826 fprintf (stderr, "Subject public key needed\n");
828 return;
829 }
830
831 // lookup ego and call function sign_cb on success
833 return;
834 }
835
836 if ((GNUNET_NO == forward) && (GNUNET_NO == backward))
837 {
838 // set default: bidirectional
841 }
842 if (GNUNET_YES == forward)
844 if (GNUNET_YES == backward)
846
847 if (GNUNET_YES == collect)
848 {
849 if (NULL == issuer_key)
850 {
851 fprintf (stderr, _ ("Issuer public key not well-formed\n"));
853 return;
854 }
855
857
858 if (NULL == abd)
859 {
860 fprintf (stderr, _ ("Failed to connect to ABD\n"));
862 return;
863 }
864 if (NULL == issuer_attr)
865 {
866 fprintf (stderr, _ ("You must provide issuer the attribute\n"));
868 return;
869 }
870
871 if (NULL == ego_name)
872 {
873 fprintf (stderr, _ ("ego required\n"));
875 return;
876 }
878 return;
879 }
880
881 if (NULL == subject)
882 {
883 fprintf (stderr, _ ("Subject public key needed\n"));
885 return;
886 }
888 &subject_pkey))
889 {
890 fprintf (stderr,
891 _ ("Subject public key `%s' is not well-formed\n"),
892 subject);
894 return;
895 }
896
897 if (GNUNET_YES == verify)
898 {
899 if (NULL == issuer_key)
900 {
901 fprintf (stderr, _ ("Issuer public key not well-formed\n"));
903 return;
904 }
905 if (GNUNET_OK !=
907 &issuer_pkey))
908 {
909 fprintf (stderr,
910 _ ("Issuer public key `%s' is not well-formed\n"),
911 issuer_key);
913 return;
914 }
916
917 if (NULL == abd)
918 {
919 fprintf (stderr, _ ("Failed to connect to ABD\n"));
921 return;
922 }
923 if ((NULL == issuer_attr) || (NULL == subject_delegate))
924 {
925 fprintf (stderr, _ ("You must provide issuer and subject attributes\n"));
927 return;
928 }
929
930 // Subject credentials are comma separated
931 char *tmp = GNUNET_strdup (subject_delegate);
932 char *tok = strtok (tmp, ",");
933 if (NULL == tok)
934 {
935 fprintf (stderr, "Invalid subject credentials\n");
936 GNUNET_free (tmp);
938 return;
939 }
940 int count = 1;
941 int i;
942 while (NULL != (tok = strtok (NULL, ",")))
943 count++;
944 struct GNUNET_ABD_Delegate*delegates =
945 GNUNET_malloc (sizeof(*delegates) * count);
946 struct GNUNET_ABD_Delegate *dele;
947 GNUNET_free (tmp);
949 tok = strtok (tmp, ",");
950 for (i = 0; i < count; i++)
951 {
953 GNUNET_memcpy (&delegates[i],
954 dele,
955 sizeof (struct GNUNET_ABD_Delegate));
956 delegates[i].issuer_attribute = GNUNET_strdup (dele->issuer_attribute);
957 tok = strtok (NULL, ",");
958 GNUNET_free (dele);
959 }
960
965 count,
966 delegates,
967 direction,
969 NULL,
971 NULL);
972 for (i = 0; i < count; i++)
973 {
974 GNUNET_free_nz ((char *) delegates[i].issuer_attribute);
975 delegates[i].issuer_attribute = NULL;
976 }
977 GNUNET_free (tmp);
978 GNUNET_free (delegates);
979 }
980 else
981 {
982 fprintf (stderr,
983 _ (
984 "Please specify name to lookup, subject key and issuer key!\n"));
986 }
987 return;
988}
989
990
998int
999main (int argc, char *const *argv)
1000{
1003 "verify",
1004 gettext_noop (
1005 "verify credential against attribute"),
1006 &verify),
1008 's',
1009 "subject",
1010 "PKEY",
1011 gettext_noop (
1012 "The public key of the subject to lookup the"
1013 "credential for, or for issuer side storage: subject and its attributes"),
1014 &subject),
1016 'd',
1017 "delegate",
1018 "DELE",
1019 gettext_noop ("The private, signed delegate presented by the subject"),
1022 'i',
1023 "issuer",
1024 "PKEY",
1025 gettext_noop (
1026 "The public key of the authority to verify the credential against"),
1027 &issuer_key),
1029 "ego",
1030 "EGO",
1031 gettext_noop ("The ego/zone name to use"),
1032 &ego_name),
1034 'a',
1035 "attribute",
1036 "ATTR",
1037 gettext_noop ("The issuer attribute to verify against or to issue"),
1038 &issuer_attr),
1040 "ttl",
1041 "EXP",
1042 gettext_noop (
1043 "The time to live for the credential."
1044 "e.g. 5m, 6h, \"1990-12-30 12:00:00\""),
1045 &expiration),
1047 "collect",
1048 gettext_noop ("collect credentials"),
1049 &collect),
1051 "createIssuerSide",
1052 gettext_noop (
1053 "Create and issue a credential issuer side."),
1054 &create_is),
1056 "createSubjectSide",
1057 gettext_noop (
1058 "Issue a credential subject side."),
1059 &create_ss),
1061 'S',
1062 "signSubjectSide",
1063 gettext_noop ("Create, sign and return a credential subject side."),
1064 &sign_ss),
1066 'x',
1067 "import",
1068 "IMP",
1069 gettext_noop (
1070 "Import signed credentials that should be issued to a zone/ego"),
1071 &import),
1073 "private",
1074 gettext_noop ("Create private record entry."),
1075 &is_private),
1077 'F',
1078 "forward",
1079 gettext_noop (
1080 "Indicates that the collect/verify process is done via forward search."),
1081 &forward),
1083 'B',
1084 "backward",
1085 gettext_noop (
1086 "Indicates that the collect/verify process is done via forward search."),
1087 &backward),
1089
1090
1092 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
1093 return 2;
1094
1095 GNUNET_log_setup ("gnunet-abd", "WARNING", NULL);
1096 if (GNUNET_OK != GNUNET_PROGRAM_run (argc,
1097 argv,
1098 "gnunet-abd",
1099 _ ("GNUnet abd resolver tool"),
1100 options,
1101 &run,
1102 NULL))
1103 ret = 1;
1104 GNUNET_free_nz ((void *) argv);
1105 return ret;
1106}
1107
1108
1109/* end of gnunet-abd.c */
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_OPTION_END
Definition: 002.c:13
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
int GNUNET_ABD_delegate_serialize(struct GNUNET_ABD_Delegate *dele, char **data)
API to serialize and deserialize delegation chains and abds.
char * GNUNET_ABD_delegate_to_string(const struct GNUNET_ABD_Delegate *cred)
Definition: delegate_misc.c:37
struct GNUNET_ABD_Delegate * GNUNET_ABD_delegate_from_string(const char *s)
Definition: delegate_misc.c:80
Delegate helper functions.
#define gettext_noop(String)
Definition: gettext.h:74
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:318
static struct GNUNET_ABD_Request * collect_request
Handle to collect request.
Definition: gnunet-abd.c:72
static int create_ss
Create mode.
Definition: gnunet-abd.c:143
static char * record_label
Record label for storing delegations.
Definition: gnunet-abd.c:212
static struct GNUNET_CRYPTO_PrivateKey zone_pkey
Private key for the our zone.
Definition: gnunet-abd.c:47
static char * issuer_attr
Issuer attribute.
Definition: gnunet-abd.c:123
static char * expiration
Credential TTL.
Definition: gnunet-abd.c:97
static struct GNUNET_NAMESTORE_QueueEntry * add_qe
Queue entry for the 'add' operation.
Definition: gnunet-abd.c:178
static int is_private
Is record private.
Definition: gnunet-abd.c:158
static int create_is
Create mode.
Definition: gnunet-abd.c:138
static void identity_cb(void *cls, struct GNUNET_IDENTITY_Ego *ego)
Callback invoked from identity service with ego information.
Definition: gnunet-abd.c:383
static char * subject_delegate
Subject delegate string.
Definition: gnunet-abd.c:92
static void do_timeout(void *cls)
Task run on timeout.
Definition: gnunet-abd.c:261
static char * issuer_key
Issuer pubkey string.
Definition: gnunet-abd.c:113
static void sign_cb(void *cls, struct GNUNET_IDENTITY_Ego *ego)
Definition: gnunet-abd.c:670
struct GNUNET_CRYPTO_PublicKey issuer_pkey
Issuer key.
Definition: gnunet-abd.c:107
static int collect
Collect mode.
Definition: gnunet-abd.c:133
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:37
static int sign_ss
Create mode.
Definition: gnunet-abd.c:148
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:82
static void store_cb(void *cls, struct GNUNET_IDENTITY_Ego *ego)
Definition: gnunet-abd.c:545
static void * data
Value in binary format.
Definition: gnunet-abd.c:183
static void do_shutdown(void *cls)
Task run on shutdown.
Definition: gnunet-abd.c:220
static struct GNUNET_IDENTITY_EgoLookup * el
EgoLookup.
Definition: gnunet-abd.c:52
static int backward
Search direction: backward.
Definition: gnunet-abd.c:168
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:289
static char * ego_name
ego
Definition: gnunet-abd.c:118
static struct GNUNET_SCHEDULER_Task * tt
Task scheduled to handle timeout.
Definition: gnunet-abd.c:77
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:758
static int verify
Verify mode.
Definition: gnunet-abd.c:128
static void add_continuation(void *cls, enum GNUNET_ErrorCode ec)
Definition: gnunet-abd.c:489
static int forward
Search direction: forward.
Definition: gnunet-abd.c:163
static int etime_is_rel
Is expiration time relative or absolute time?
Definition: gnunet-abd.c:207
static struct GNUNET_NAMESTORE_Handle * ns
Handle to the namestore.
Definition: gnunet-abd.c:42
static int parse_expiration(const char *expirationstring, int *etime_is_rel, uint64_t *etime)
Parse expiration time.
Definition: gnunet-abd.c:438
static struct GNUNET_TIME_Relative timeout
Desired timeout for the lookup (default is no timeout).
Definition: gnunet-abd.c:62
static void error_cb(void *cls)
Function called if lookup fails.
Definition: gnunet-abd.c:480
static struct GNUNET_ABD_Handle * abd
Handle to Credential service.
Definition: gnunet-abd.c:57
int main(int argc, char *const *argv)
The main function for gnunet-gns.
Definition: gnunet-abd.c:999
static uint32_t type
Type string converted to DNS type value.
Definition: gnunet-abd.c:193
static size_t data_size
Number of bytes in data.
Definition: gnunet-abd.c:188
static char * subject
Subject pubkey string.
Definition: gnunet-abd.c:87
static struct GNUNET_ABD_Request * verify_request
Handle to verify request.
Definition: gnunet-abd.c:67
enum GNUNET_ABD_AlgoDirectionFlags direction
API enum, filled and passed for collect/verify.
Definition: gnunet-abd.c:173
static void get_existing_record(void *cls, const struct GNUNET_CRYPTO_PrivateKey *zone_key, const char *rec_name, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
Definition: gnunet-abd.c:504
static char * typestring
Type of the record to add/remove, NULL to remove all.
Definition: gnunet-abd.c:198
static void handle_intermediate_result(void *cls, struct GNUNET_ABD_Delegation *dd, bool is_bw)
Definition: gnunet-abd.c:269
struct GNUNET_CRYPTO_PublicKey subject_pkey
Subject key.
Definition: gnunet-abd.c:102
static uint64_t etime
Expiration string converted to numeric value.
Definition: gnunet-abd.c:202
static int prefix
If printing the value of PREFIX has been requested.
Definition: gnunet-config.c:66
static char * line
Desired phone line (string to be converted to a hash).
static struct GNUNET_DATASTORE_QueueEntry * qe
Current operation.
static struct GNUNET_FS_DownloadContext * dc
static unsigned int rd_count
Number of records for currently parsed set.
static char * res
Currently read line or NULL on EOF.
static struct GNUNET_GNSRECORD_Data rd[50]
The record data under a single label.
static char * expirationstring
Desired expiration time.
API to the Credential service.
API that can be used to manipulate GNS record data.
API that can be used to store naming information on a GNUnet node;.
GNUNET_ABD_AlgoDirectionFlags
struct GNUNET_ABD_Handle * GNUNET_ABD_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Initialize the connection with the ABD service.
Definition: abd_api.c:354
struct GNUNET_ABD_Delegate * GNUNET_ABD_delegate_issue(const struct GNUNET_CRYPTO_PrivateKey *issuer, struct GNUNET_CRYPTO_PublicKey *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_verify(struct GNUNET_ABD_Handle *handle, const struct GNUNET_CRYPTO_PublicKey *issuer_key, const char *issuer_attribute, const struct GNUNET_CRYPTO_PublicKey *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:497
void GNUNET_ABD_disconnect(struct GNUNET_ABD_Handle *handle)
Shutdown connection with the ABD service.
Definition: abd_api.c:376
void GNUNET_ABD_request_cancel(struct GNUNET_ABD_Request *lr)
Cancel pending verify request.
Definition: abd_api.c:399
struct GNUNET_ABD_Request * GNUNET_ABD_collect(struct GNUNET_ABD_Handle *handle, const struct GNUNET_CRYPTO_PublicKey *issuer_key, const char *issuer_attribute, const struct GNUNET_CRYPTO_PrivateKey *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:423
@ GNUNET_ABD_FLAG_BACKWARD
@ GNUNET_ABD_FLAG_FORWARD
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_flag(char shortName, const char *name, const char *description, int *val)
Allow user to specify a flag (which internally means setting an integer to 1/GNUNET_YES/GNUNET_OK.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_string(char shortName, const char *name, const char *argumentHelp, const char *description, char **str)
Allow user to specify a string.
int GNUNET_GNSRECORD_string_to_value(uint32_t type, const char *s, void **data, size_t *data_size)
Convert human-readable version of the value s of a record of type type to the respective binary repre...
Definition: gnsrecord.c:177
#define GNUNET_GNS_EMPTY_LABEL_AT
String we use to indicate an empty label (top-level entry in the zone).
@ GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION
This expiration time of the record is a relative time (not an absolute time).
@ GNUNET_GNSRECORD_RF_PRIVATE
This is a private record of this peer and it should thus not be published.
const struct GNUNET_CRYPTO_PrivateKey * GNUNET_IDENTITY_ego_get_private_key(const struct GNUNET_IDENTITY_Ego *ego)
Obtain the ECC key associated with a ego.
Definition: identity_api.c:517
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.
void GNUNET_IDENTITY_ego_lookup_cancel(struct GNUNET_IDENTITY_EgoLookup *el)
Abort ego lookup attempt.
void GNUNET_IDENTITY_ego_get_public_key(struct GNUNET_IDENTITY_Ego *ego, struct GNUNET_CRYPTO_PublicKey *pk)
Get the identifier (public key) of an ego.
Definition: identity_api.c:529
#define GNUNET_log(kind,...)
char * GNUNET_CRYPTO_public_key_to_string(const struct GNUNET_CRYPTO_PublicKey *key)
Creates a (Base32) string representation of the public key.
Definition: crypto_pkey.c:568
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_public_key_from_string(const char *str, struct GNUNET_CRYPTO_PublicKey *key)
Parses a (Base32) string representation of the public key.
Definition: crypto_pkey.c:588
@ GNUNET_OK
@ GNUNET_YES
@ GNUNET_NO
@ GNUNET_SYSERR
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
enum GNUNET_GenericReturnValue GNUNET_log_setup(const char *comp, const char *loglevel, const char *logfile)
Setup logging.
@ GNUNET_ERROR_TYPE_ERROR
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
#define GNUNET_free_nz(ptr)
Wrapper around free.
struct GNUNET_NAMESTORE_QueueEntry * GNUNET_NAMESTORE_records_lookup(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_PrivateKey *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_NAMESTORE_QueueEntry * GNUNET_NAMESTORE_record_set_store(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_PrivateKey *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.
void GNUNET_NAMESTORE_disconnect(struct GNUNET_NAMESTORE_Handle *h)
Disconnect from the namestore service (and free associated resources).
void GNUNET_NAMESTORE_cancel(struct GNUNET_NAMESTORE_QueueEntry *qe)
Cancel a namestore operation.
struct GNUNET_NAMESTORE_Handle * GNUNET_NAMESTORE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the namestore service.
enum GNUNET_GenericReturnValue GNUNET_PROGRAM_run(int argc, char *const *argv, const char *binaryName, const char *binaryHelp, const struct GNUNET_GETOPT_CommandLineOption *options, GNUNET_PROGRAM_Main task, void *task_cls)
Run a standard GNUnet command startup sequence (initialize loggers and configuration,...
Definition: program.c:400
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:567
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,...
Definition: scheduler.c:1340
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:981
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:1278
enum GNUNET_GenericReturnValue 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:260
enum GNUNET_GenericReturnValue GNUNET_STRINGS_get_utf8_args(int argc, char *const *argv, int *u8argc, char *const **u8argv)
Returns utf-8 encoded arguments.
Definition: strings.c:1230
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
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:570
const char * GNUNET_STRINGS_absolute_time_to_string(struct GNUNET_TIME_Absolute t)
Like asctime, except for GNUnet time.
Definition: strings.c:617
#define GNUNET_TIME_UNIT_FOREVER_ABS
Constant used to specify "forever".
enum GNUNET_GenericReturnValue 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:302
#define _(String)
GNU gettext support macro.
Definition: platform.h:178
#define GNUNET_GNSRECORD_TYPE_ATTRIBUTE
For ABD reverse lookups.
#define GNUNET_GNSRECORD_TYPE_DELEGATE
For ABD policies.
GNUNET_ErrorCode
Taler error codes.
@ GNUNET_EC_NONE
No error (success).
const char * issuer_attribute
The issuer attribute.
struct GNUNET_TIME_Absolute expiration
Expiration of this credential.
struct GNUNET_CRYPTO_PublicKey subject_key
Public key of the subject this credential was issued to.
struct GNUNET_CRYPTO_PublicKey subject_key
Public key of the subject this attribute was delegated to.
const char * issuer_attribute
The attribute.
const char * subject_attribute
The attribute.
struct GNUNET_CRYPTO_PublicKey issuer_key
The issuer of the delegation.
Connection to the ABD service.
Definition: abd_api.c:96
Handle to a verify request.
Definition: abd_api.c:43
A private key for an identity as per LSD0001.
An identity key as per LSD0001.
Definition of a command line option.
uint32_t record_type
Type of the GNS/DNS record.
const void * data
Binary value stored in the DNS record.
size_t data_size
Number of bytes in data.
enum GNUNET_GNSRECORD_Flags flags
Flags for the record.
uint64_t expiration_time
Expiration time for the DNS record.
Handle for ego lookup.
Handle for an ego.
Definition: identity.h:37
Connection to the NAMESTORE service.
An QueueEntry used to store information for a pending NAMESTORE record operation.
Definition: namestore_api.c:49
Entry in list of pending tasks.
Definition: scheduler.c:136
Time for absolute times used by GNUnet, in microseconds.
uint64_t abs_value_us
The actual value.
Time for relative time used by GNUnet, in microseconds.
uint64_t rel_value_us
The actual value.