GNUnet 0.22.0
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 const 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 const 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;
449 *etime_is_rel_ = GNUNET_NO;
450 return GNUNET_OK;
451 }
452 if (GNUNET_OK ==
454 {
455 *etime_is_rel_ = GNUNET_YES;
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 {
465 *etime_is_rel_ = GNUNET_NO;
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
494 if (GNUNET_EC_NONE == ec)
495 printf ("Adding successful.\n");
496 else
497 fprintf (stderr, "Error: `%s'.\n", GNUNET_ErrorCode_get_hint (ec));
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;
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
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 ;
605 return;
606 }
607
608 // Expiration
609 etime = cred->expiration.abs_value_us;
611
612 // Prepare the data to be store in the record
615 }
616 else
617 {
618 // For all other types e.g. GNUNET_GNSRECORD_TYPE_ATTRIBUTE
619 if (GNUNET_OK !=
621 {
622 if (typestring == NULL)
623 {
624 fputs ("Value for unknown record type not well-formed.\n", stderr);
625 }
626 else if (subject == NULL)
627 {
628 fprintf (stderr,
629 "Value for record type `%s' not well-formed.\n",
630 typestring);
631 }
632 else
633 {
634 fprintf (stderr,
635 "Value `%s' invalid for record type `%s'\n",
636 subject,
637 typestring);
638 }
640 return;
641 }
642
643 // Take care of expiration
644 if (NULL == expiration)
645 {
646 fprintf (stderr, "Missing option -e for operation 'create'\n");
648 return;
649 }
651 {
652 fprintf (stderr, "Invalid time format `%s'\n", expiration);
654 return;
655 }
656 }
657
658 // Start lookup
660 &zone_pkey,
662 &error_cb,
663 NULL,
665 NULL);
666 return;
667}
668
669
670static void
671sign_cb (void *cls, struct GNUNET_IDENTITY_Ego *ego)
672{
673 const struct GNUNET_CRYPTO_PrivateKey *privkey;
674 struct GNUNET_ABD_Delegate *dele;
675 struct GNUNET_TIME_Absolute etime_abs;
676 char *res;
677 char *subject_pubkey_str;
678 char *subject_attr = NULL;
679 char *token;
680
681 el = NULL;
682
683 // work on expiration time
684 if (NULL == expiration)
685 {
686 fprintf (stderr, "Please specify a TTL\n");
688 return;
689 }
690 else if (GNUNET_OK !=
692 {
693 fprintf (stderr,
694 "%s is not a valid ttl! Only absolute times are accepted!\n",
695 expiration);
697 return;
698 }
699
700 // If contains a space - split it by the first space only - assume first entry is subject followed by attribute(s)
701
702 // Subject Public Key
703 token = strtok (subject, " ");
704 subject_pubkey_str = token;
705 // Subject Attribute(s)
706 token = strtok (NULL, " ");
707 if (NULL != token)
708 {
709 subject_attr = token;
710 }
711
712 // work on keys
714
715 if (NULL == subject_pubkey_str)
716 {
717 fprintf (stderr,
718 "Subject pubkey not given\n");
720 return;
721 }
722 if (GNUNET_OK !=
723 GNUNET_CRYPTO_public_key_from_string (subject_pubkey_str,
724 &subject_pkey))
725 {
726 fprintf (stderr,
727 "Subject public key `%s' is not well-formed\n",
728 subject_pubkey_str);
730 return;
731 }
732
733 // Sign delegate
734 dele = GNUNET_ABD_delegate_issue (privkey,
737 subject_attr,
738 &etime_abs);
740 GNUNET_free (dele);
741 printf ("%s\n", res);
742
744 ego_name = NULL;
745
747}
748
749
758static void
759run (void *cls,
760 char *const *args,
761 const char *cfgfile,
762 const struct GNUNET_CONFIGURATION_Handle *c)
763{
764 cfg = c;
765
768
769 // Check relevant cmdline parameters
770 if (GNUNET_YES == create_is)
771 {
772 if (NULL == ego_name)
773 {
774 fprintf (stderr, "Missing option '-ego'\n");
776 return;
777 }
778 if (NULL == issuer_attr)
779 {
780 fprintf (stderr, "Missing option '-attribute' for issuer attribute\n");
782 return;
783 }
784 if (NULL == subject)
785 {
786 fprintf (stderr, "Missing option -subject for operation 'create'.'\n");
788 return;
789 }
790
791 // Lookup ego, on success call store_cb and store as ATTRIBUTE type
795 return;
796 }
797
798 if (GNUNET_YES == create_ss)
799 {
800
801 // check if signed parameter has been passed in cmd line call
802 if (NULL == import)
803 {
804 fprintf (stderr, "'import' required\n");
806 return;
807 }
808
811 // Store subject side
813
814 return;
815 }
816
817 if (GNUNET_YES == sign_ss)
818 {
819 if (NULL == ego_name)
820 {
821 fprintf (stderr, "ego required\n");
823 return;
824 }
825 if (NULL == subject)
826 {
827 fprintf (stderr, "Subject public key needed\n");
829 return;
830 }
831
832 // lookup ego and call function sign_cb on success
834 return;
835 }
836
837 if ((GNUNET_NO == forward) && (GNUNET_NO == backward))
838 {
839 // set default: bidirectional
842 }
843 if (GNUNET_YES == forward)
845 if (GNUNET_YES == backward)
847
848 if (GNUNET_YES == collect)
849 {
850 if (NULL == issuer_key)
851 {
852 fprintf (stderr, _ ("Issuer public key not well-formed\n"));
854 return;
855 }
856
858
859 if (NULL == abd)
860 {
861 fprintf (stderr, _ ("Failed to connect to ABD\n"));
863 return;
864 }
865 if (NULL == issuer_attr)
866 {
867 fprintf (stderr, _ ("You must provide issuer the attribute\n"));
869 return;
870 }
871
872 if (NULL == ego_name)
873 {
874 fprintf (stderr, _ ("ego required\n"));
876 return;
877 }
879 return;
880 }
881
882 if (NULL == subject)
883 {
884 fprintf (stderr, _ ("Subject public key needed\n"));
886 return;
887 }
889 &subject_pkey))
890 {
891 fprintf (stderr,
892 _ ("Subject public key `%s' is not well-formed\n"),
893 subject);
895 return;
896 }
897
898 if (GNUNET_YES == verify)
899 {
900 if (NULL == issuer_key)
901 {
902 fprintf (stderr, _ ("Issuer public key not well-formed\n"));
904 return;
905 }
906 if (GNUNET_OK !=
908 &issuer_pkey))
909 {
910 fprintf (stderr,
911 _ ("Issuer public key `%s' is not well-formed\n"),
912 issuer_key);
914 return;
915 }
917
918 if (NULL == abd)
919 {
920 fprintf (stderr, _ ("Failed to connect to ABD\n"));
922 return;
923 }
924 if ((NULL == issuer_attr) || (NULL == subject_delegate))
925 {
926 fprintf (stderr, _ ("You must provide issuer and subject attributes\n"));
928 return;
929 }
930
931 // Subject credentials are comma separated
932 {
933 struct GNUNET_ABD_Delegate *delegates;
934 struct GNUNET_ABD_Delegate *dele;
935 char *tmp = GNUNET_strdup (subject_delegate);
936 char *tok = strtok (tmp, ",");
937 int count = 1;
938 int i;
939 if (NULL == tok)
940 {
941 fprintf (stderr, "Invalid subject credentials\n");
942 GNUNET_free (tmp);
944 return;
945 }
946 while (NULL != (tok = strtok (NULL, ",")))
947 count++;
948 delegates = GNUNET_malloc (sizeof(*delegates) * count);
949 GNUNET_free (tmp);
951 tok = strtok (tmp, ",");
952 for (i = 0; i < count; i++)
953 {
955 GNUNET_memcpy (&delegates[i],
956 dele,
957 sizeof (struct GNUNET_ABD_Delegate));
958 delegates[i].issuer_attribute = GNUNET_strdup (dele->issuer_attribute);
959 tok = strtok (NULL, ",");
960 GNUNET_free (dele);
961 }
962
967 count,
968 delegates,
969 direction,
971 NULL,
973 NULL);
974 for (i = 0; i < count; i++)
975 {
976 GNUNET_free_nz ((char *) delegates[i].issuer_attribute);
977 delegates[i].issuer_attribute = NULL;
978 }
979 GNUNET_free (tmp);
980 GNUNET_free (delegates);
981 }
982 }
983 else
984 {
985 fprintf (stderr,
986 _ (
987 "Please specify name to lookup, subject key and issuer key!\n"));
989 }
990 return;
991}
992
993
1001int
1002main (int argc, char *const *argv)
1003{
1006 "verify",
1007 gettext_noop (
1008 "verify credential against attribute"),
1009 &verify),
1011 's',
1012 "subject",
1013 "PKEY",
1014 gettext_noop (
1015 "The public key of the subject to lookup the"
1016 "credential for, or for issuer side storage: subject and its attributes")
1017 ,
1018 &subject),
1020 'd',
1021 "delegate",
1022 "DELE",
1023 gettext_noop ("The private, signed delegate presented by the subject"),
1026 'i',
1027 "issuer",
1028 "PKEY",
1029 gettext_noop (
1030 "The public key of the authority to verify the credential against"),
1031 &issuer_key),
1033 "ego",
1034 "EGO",
1035 gettext_noop ("The ego/zone name to use"),
1036 &ego_name),
1038 'a',
1039 "attribute",
1040 "ATTR",
1041 gettext_noop ("The issuer attribute to verify against or to issue"),
1042 &issuer_attr),
1044 "ttl",
1045 "EXP",
1046 gettext_noop (
1047 "The time to live for the credential."
1048 "e.g. 5m, 6h, \"1990-12-30 12:00:00\""),
1049 &expiration),
1051 "collect",
1052 gettext_noop ("collect credentials"),
1053 &collect),
1055 "createIssuerSide",
1056 gettext_noop (
1057 "Create and issue a credential issuer side."),
1058 &create_is),
1060 "createSubjectSide",
1061 gettext_noop (
1062 "Issue a credential subject side."),
1063 &create_ss),
1065 'S',
1066 "signSubjectSide",
1067 gettext_noop ("Create, sign and return a credential subject side."),
1068 &sign_ss),
1070 'x',
1071 "import",
1072 "IMP",
1073 gettext_noop (
1074 "Import signed credentials that should be issued to a zone/ego"),
1075 &import),
1077 "private",
1078 gettext_noop ("Create private record entry."),
1079 &is_private),
1081 'F',
1082 "forward",
1083 gettext_noop (
1084 "Indicates that the collect/verify process is done via forward search."),
1085 &forward),
1087 'B',
1088 "backward",
1089 gettext_noop (
1090 "Indicates that the collect/verify process is done via forward search."),
1091 &backward),
1093
1094
1096 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
1097 return 2;
1098
1099 GNUNET_log_setup ("gnunet-abd", "WARNING", NULL);
1100 if (GNUNET_OK != GNUNET_PROGRAM_run (argc,
1101 argv,
1102 "gnunet-abd",
1103 _ ("GNUnet abd resolver tool"),
1104 options,
1105 &run,
1106 NULL))
1107 ret = 1;
1108 GNUNET_free_nz ((void *) argv);
1109 return ret;
1110}
1111
1112
1113/* 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:82
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 struct GNUNET_CRYPTO_PrivateKey zone_pkey
Private key for the our zone.
Definition: gnunet-abd.c:47
static const char * record_label
Record label for storing delegations.
Definition: gnunet-abd.c:212
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:671
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 parse_expiration(const char *expirationstring, int *etime_is_rel_, uint64_t *etime_)
Parse expiration time.
Definition: gnunet-abd.c:438
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:759
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 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:1002
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 gnutls_certificate_credentials_t cred
The credential.
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 char * expirationstring
Optional expiration string -E.
Definition: gnunet-hello.c:72
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.
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:379
#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:399
@ 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:566
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:1338
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:979
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:1276
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:259
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:1253
#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:579
const char * GNUNET_STRINGS_absolute_time_to_string(struct GNUNET_TIME_Absolute t)
Like asctime, except for GNUnet time.
Definition: strings.c:640
#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:301
#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.
const char * GNUNET_ErrorCode_get_hint(enum GNUNET_ErrorCode ec)
Returns a hint for a given error code.
GNUNET_ErrorCode
Taler error codes.
@ GNUNET_EC_NONE
No error (success).
const char * issuer_attribute
The issuer attribute.
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:135
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.