aboutsummaryrefslogtreecommitdiff
path: root/src/abd/gnunet-abd.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2019-10-31 13:03:48 +0100
committerChristian Grothoff <christian@grothoff.org>2019-10-31 13:03:48 +0100
commit7e3cf5f461eb4fbb7581672bf0835da07c378136 (patch)
treebdc3874b7894242b095b892f1ed3e81a4d4f06c0 /src/abd/gnunet-abd.c
parent01b480d6d026e0c537dc284a7e7df2c0320a3528 (diff)
downloadgnunet-7e3cf5f461eb4fbb7581672bf0835da07c378136.tar.gz
gnunet-7e3cf5f461eb4fbb7581672bf0835da07c378136.zip
tighten formatting rules
Diffstat (limited to 'src/abd/gnunet-abd.c')
-rw-r--r--src/abd/gnunet-abd.c268
1 files changed, 140 insertions, 128 deletions
diff --git a/src/abd/gnunet-abd.c b/src/abd/gnunet-abd.c
index 23083ec68..a5d32c3dd 100644
--- a/src/abd/gnunet-abd.c
+++ b/src/abd/gnunet-abd.c
@@ -11,7 +11,7 @@
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU Affero General Public License 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/>. 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 17
@@ -268,25 +268,27 @@ do_timeout (void *cls)
268 GNUNET_SCHEDULER_shutdown (); 268 GNUNET_SCHEDULER_shutdown ();
269} 269}
270 270
271
271static void 272static void
272handle_intermediate_result(void *cls, 273handle_intermediate_result (void *cls,
273 struct GNUNET_ABD_Delegation *dd, 274 struct GNUNET_ABD_Delegation *dd,
274 bool is_bw) 275 bool is_bw)
275{ 276{
276 char *prefix = ""; 277 char *prefix = "";
277 if(is_bw) 278 if (is_bw)
278 prefix = "Backward -"; 279 prefix = "Backward -";
279 else 280 else
280 prefix = "Forward -"; 281 prefix = "Forward -";
281 282
282 printf ("%s Intermediate result: %s.%s <- %s.%s\n", 283 printf ("%s Intermediate result: %s.%s <- %s.%s\n",
283 prefix, 284 prefix,
284 GNUNET_CRYPTO_ecdsa_public_key_to_string (&dd->issuer_key), 285 GNUNET_CRYPTO_ecdsa_public_key_to_string (&dd->issuer_key),
285 dd->issuer_attribute, 286 dd->issuer_attribute,
286 GNUNET_CRYPTO_ecdsa_public_key_to_string (&dd->subject_key), 287 GNUNET_CRYPTO_ecdsa_public_key_to_string (&dd->subject_key),
287 dd->subject_attribute); 288 dd->subject_attribute);
288} 289}
289 290
291
290static void 292static void
291handle_collect_result (void *cls, 293handle_collect_result (void *cls,
292 unsigned int d_count, 294 unsigned int d_count,
@@ -373,6 +375,7 @@ handle_verify_result (void *cls,
373 GNUNET_SCHEDULER_shutdown (); 375 GNUNET_SCHEDULER_shutdown ();
374} 376}
375 377
378
376/** 379/**
377 * Callback invoked from identity service with ego information. 380 * Callback invoked from identity service with ego information.
378 * An @a ego of NULL means the ego was not found. 381 * An @a ego of NULL means the ego was not found.
@@ -414,19 +417,20 @@ identity_cb (void *cls, const struct GNUNET_IDENTITY_Ego *ego)
414 privkey = GNUNET_IDENTITY_ego_get_private_key (ego); 417 privkey = GNUNET_IDENTITY_ego_get_private_key (ego);
415 418
416 collect_request = GNUNET_ABD_collect (abd, 419 collect_request = GNUNET_ABD_collect (abd,
417 &issuer_pkey, 420 &issuer_pkey,
418 issuer_attr, 421 issuer_attr,
419 privkey, 422 privkey,
420 direction, 423 direction,
421 &handle_collect_result, 424 &handle_collect_result,
422 NULL, 425 NULL,
423 &handle_intermediate_result, 426 &handle_intermediate_result,
424 NULL); 427 NULL);
425 return; 428 return;
426 } 429 }
427 GNUNET_SCHEDULER_shutdown (); 430 GNUNET_SCHEDULER_shutdown ();
428} 431}
429 432
433
430/** 434/**
431 * Parse expiration time. 435 * Parse expiration time.
432 * 436 *
@@ -473,6 +477,7 @@ parse_expiration (const char *expirationstring,
473 return GNUNET_SYSERR; 477 return GNUNET_SYSERR;
474} 478}
475 479
480
476/** 481/**
477 * Function called if lookup fails. 482 * Function called if lookup fails.
478 */ 483 */
@@ -483,13 +488,15 @@ error_cb (void *cls)
483 GNUNET_SCHEDULER_shutdown (); 488 GNUNET_SCHEDULER_shutdown ();
484 return; 489 return;
485} 490}
491
492
486static void 493static void
487add_continuation (void *cls, int32_t success, const char *emsg) 494add_continuation (void *cls, int32_t success, const char *emsg)
488{ 495{
489 struct GNUNET_NAMESTORE_QueueEntry **qe = cls; 496 struct GNUNET_NAMESTORE_QueueEntry **qe = cls;
490 *qe = NULL; 497 *qe = NULL;
491 498
492 if(GNUNET_OK == success) 499 if (GNUNET_OK == success)
493 printf ("Adding successful.\n"); 500 printf ("Adding successful.\n");
494 else 501 else
495 fprintf (stderr, "Error occured during adding, shutting down.\n"); 502 fprintf (stderr, "Error occured during adding, shutting down.\n");
@@ -497,6 +504,7 @@ add_continuation (void *cls, int32_t success, const char *emsg)
497 GNUNET_SCHEDULER_shutdown (); 504 GNUNET_SCHEDULER_shutdown ();
498} 505}
499 506
507
500static void 508static void
501get_existing_record (void *cls, 509get_existing_record (void *cls,
502 const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key, 510 const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key,
@@ -535,6 +543,7 @@ get_existing_record (void *cls,
535 return; 543 return;
536} 544}
537 545
546
538static void 547static void
539store_cb (void *cls, const struct GNUNET_IDENTITY_Ego *ego) 548store_cb (void *cls, const struct GNUNET_IDENTITY_Ego *ego)
540{ 549{
@@ -627,6 +636,7 @@ store_cb (void *cls, const struct GNUNET_IDENTITY_Ego *ego)
627 return; 636 return;
628} 637}
629 638
639
630static void 640static void
631sign_cb (void *cls, const struct GNUNET_IDENTITY_Ego *ego) 641sign_cb (void *cls, const struct GNUNET_IDENTITY_Ego *ego)
632{ 642{
@@ -695,10 +705,10 @@ sign_cb (void *cls, const struct GNUNET_IDENTITY_Ego *ego)
695 705
696 // Sign delegate 706 // Sign delegate
697 dele = GNUNET_ABD_delegate_issue (privkey, 707 dele = GNUNET_ABD_delegate_issue (privkey,
698 &subject_pkey, 708 &subject_pkey,
699 issuer_attr, 709 issuer_attr,
700 subject_attr, 710 subject_attr,
701 &etime_abs); 711 &etime_abs);
702 res = GNUNET_ABD_delegate_to_string (dele); 712 res = GNUNET_ABD_delegate_to_string (dele);
703 GNUNET_free (dele); 713 GNUNET_free (dele);
704 printf ("%s\n", res); 714 printf ("%s\n", res);
@@ -709,6 +719,7 @@ sign_cb (void *cls, const struct GNUNET_IDENTITY_Ego *ego)
709 GNUNET_SCHEDULER_shutdown (); 719 GNUNET_SCHEDULER_shutdown ();
710} 720}
711 721
722
712/** 723/**
713 * Main function that will be run. 724 * Main function that will be run.
714 * 725 *
@@ -796,7 +807,7 @@ run (void *cls,
796 return; 807 return;
797 } 808 }
798 809
799 if (GNUNET_NO == forward && GNUNET_NO == backward) 810 if ((GNUNET_NO == forward) && (GNUNET_NO == backward))
800 { 811 {
801 // set default: bidirectional 812 // set default: bidirectional
802 forward = GNUNET_YES; 813 forward = GNUNET_YES;
@@ -885,14 +896,14 @@ run (void *cls,
885 GNUNET_SCHEDULER_shutdown (); 896 GNUNET_SCHEDULER_shutdown ();
886 return; 897 return;
887 } 898 }
888 if (NULL == issuer_attr || NULL == subject_delegate) 899 if ((NULL == issuer_attr) || (NULL == subject_delegate))
889 { 900 {
890 fprintf (stderr, _ ("You must provide issuer and subject attributes\n")); 901 fprintf (stderr, _ ("You must provide issuer and subject attributes\n"));
891 GNUNET_SCHEDULER_shutdown (); 902 GNUNET_SCHEDULER_shutdown ();
892 return; 903 return;
893 } 904 }
894 905
895 //Subject credentials are comma separated 906 // Subject credentials are comma separated
896 char *tmp = GNUNET_strdup (subject_delegate); 907 char *tmp = GNUNET_strdup (subject_delegate);
897 char *tok = strtok (tmp, ","); 908 char *tok = strtok (tmp, ",");
898 if (NULL == tok) 909 if (NULL == tok)
@@ -923,16 +934,16 @@ run (void *cls,
923 } 934 }
924 935
925 verify_request = GNUNET_ABD_verify (abd, 936 verify_request = GNUNET_ABD_verify (abd,
926 &issuer_pkey, 937 &issuer_pkey,
927 issuer_attr, 938 issuer_attr,
928 &subject_pkey, 939 &subject_pkey,
929 count, 940 count,
930 delegates, 941 delegates,
931 direction, 942 direction,
932 &handle_verify_result, 943 &handle_verify_result,
933 NULL, 944 NULL,
934 &handle_intermediate_result, 945 &handle_intermediate_result,
935 NULL); 946 NULL);
936 for (i = 0; i < count; i++) 947 for (i = 0; i < count; i++)
937 { 948 {
938 GNUNET_free ((char *) delegates[i].issuer_attribute); 949 GNUNET_free ((char *) delegates[i].issuer_attribute);
@@ -961,93 +972,93 @@ int
961main (int argc, char *const *argv) 972main (int argc, char *const *argv)
962{ 973{
963 struct GNUNET_GETOPT_CommandLineOption options[] = 974 struct GNUNET_GETOPT_CommandLineOption options[] =
964 {GNUNET_GETOPT_option_flag ('V', 975 {GNUNET_GETOPT_option_flag ('V',
965 "verify", 976 "verify",
977 gettext_noop (
978 "verify credential against attribute"),
979 &verify),
980 GNUNET_GETOPT_option_string (
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),
988 GNUNET_GETOPT_option_string (
989 'd',
990 "delegate",
991 "DELE",
992 gettext_noop ("The private, signed delegate presented by the subject"),
993 &subject_delegate),
994 GNUNET_GETOPT_option_string (
995 'i',
996 "issuer",
997 "PKEY",
998 gettext_noop (
999 "The public key of the authority to verify the credential against"),
1000 &issuer_key),
1001 GNUNET_GETOPT_option_string ('e',
1002 "ego",
1003 "EGO",
1004 gettext_noop ("The ego/zone name to use"),
1005 &ego_name),
1006 GNUNET_GETOPT_option_string (
1007 'a',
1008 "attribute",
1009 "ATTR",
1010 gettext_noop ("The issuer attribute to verify against or to issue"),
1011 &issuer_attr),
1012 GNUNET_GETOPT_option_string ('T',
1013 "ttl",
1014 "EXP",
966 gettext_noop ( 1015 gettext_noop (
967 "verify credential against attribute"), 1016 "The time to live for the credential."
968 &verify), 1017 "e.g. 5m, 6h, \"1990-12-30 12:00:00\""),
969 GNUNET_GETOPT_option_string ( 1018 &expiration),
970 's', 1019 GNUNET_GETOPT_option_flag ('g',
971 "subject", 1020 "collect",
972 "PKEY", 1021 gettext_noop ("collect credentials"),
973 gettext_noop ( 1022 &collect),
974 "The public key of the subject to lookup the" 1023 GNUNET_GETOPT_option_flag ('U',
975 "credential for, or for issuer side storage: subject and its attributes"), 1024 "createIssuerSide",
976 &subject), 1025 gettext_noop (
977 GNUNET_GETOPT_option_string ( 1026 "Create and issue a credential issuer side."),
978 'd', 1027 &create_is),
979 "delegate", 1028 GNUNET_GETOPT_option_flag ('C',
980 "DELE", 1029 "createSubjectSide",
981 gettext_noop ("The private, signed delegate presented by the subject"), 1030 gettext_noop (
982 &subject_delegate), 1031 "Issue a credential subject side."),
983 GNUNET_GETOPT_option_string ( 1032 &create_ss),
984 'i', 1033 GNUNET_GETOPT_option_flag (
985 "issuer", 1034 'S',
986 "PKEY", 1035 "signSubjectSide",
987 gettext_noop ( 1036 gettext_noop ("Create, sign and return a credential subject side."),
988 "The public key of the authority to verify the credential against"), 1037 &sign_ss),
989 &issuer_key), 1038 GNUNET_GETOPT_option_string (
990 GNUNET_GETOPT_option_string ('e', 1039 'x',
991 "ego", 1040 "import",
992 "EGO", 1041 "IMP",
993 gettext_noop ("The ego/zone name to use"), 1042 gettext_noop (
994 &ego_name), 1043 "Import signed credentials that should be issued to a zone/ego"),
995 GNUNET_GETOPT_option_string ( 1044 &import),
996 'a', 1045 GNUNET_GETOPT_option_flag ('P',
997 "attribute", 1046 "private",
998 "ATTR", 1047 gettext_noop ("Create private record entry."),
999 gettext_noop ("The issuer attribute to verify against or to issue"), 1048 &is_private),
1000 &issuer_attr), 1049 GNUNET_GETOPT_option_flag (
1001 GNUNET_GETOPT_option_string ('T', 1050 'F',
1002 "ttl", 1051 "forward",
1003 "EXP", 1052 gettext_noop (
1004 gettext_noop ( 1053 "Indicates that the collect/verify process is done via forward search."),
1005 "The time to live for the credential." 1054 &forward),
1006 "e.g. 5m, 6h, \"1990-12-30 12:00:00\""), 1055 GNUNET_GETOPT_option_flag (
1007 &expiration), 1056 'B',
1008 GNUNET_GETOPT_option_flag ('g', 1057 "backward",
1009 "collect", 1058 gettext_noop (
1010 gettext_noop ("collect credentials"), 1059 "Indicates that the collect/verify process is done via forward search."),
1011 &collect), 1060 &backward),
1012 GNUNET_GETOPT_option_flag ('U', 1061 GNUNET_GETOPT_OPTION_END};
1013 "createIssuerSide",
1014 gettext_noop (
1015 "Create and issue a credential issuer side."),
1016 &create_is),
1017 GNUNET_GETOPT_option_flag ('C',
1018 "createSubjectSide",
1019 gettext_noop (
1020 "Issue a credential subject side."),
1021 &create_ss),
1022 GNUNET_GETOPT_option_flag (
1023 'S',
1024 "signSubjectSide",
1025 gettext_noop ("Create, sign and return a credential subject side."),
1026 &sign_ss),
1027 GNUNET_GETOPT_option_string (
1028 'x',
1029 "import",
1030 "IMP",
1031 gettext_noop (
1032 "Import signed credentials that should be issued to a zone/ego"),
1033 &import),
1034 GNUNET_GETOPT_option_flag ('P',
1035 "private",
1036 gettext_noop ("Create private record entry."),
1037 &is_private),
1038 GNUNET_GETOPT_option_flag (
1039 'F',
1040 "forward",
1041 gettext_noop (
1042 "Indicates that the collect/verify process is done via forward search."),
1043 &forward),
1044 GNUNET_GETOPT_option_flag (
1045 'B',
1046 "backward",
1047 gettext_noop (
1048 "Indicates that the collect/verify process is done via forward search."),
1049 &backward),
1050 GNUNET_GETOPT_OPTION_END};
1051 1062
1052 1063
1053 timeout = GNUNET_TIME_UNIT_FOREVER_REL; 1064 timeout = GNUNET_TIME_UNIT_FOREVER_REL;
@@ -1056,15 +1067,16 @@ main (int argc, char *const *argv)
1056 1067
1057 GNUNET_log_setup ("gnunet-abd", "WARNING", NULL); 1068 GNUNET_log_setup ("gnunet-abd", "WARNING", NULL);
1058 if (GNUNET_OK != GNUNET_PROGRAM_run (argc, 1069 if (GNUNET_OK != GNUNET_PROGRAM_run (argc,
1059 argv, 1070 argv,
1060 "gnunet-abd", 1071 "gnunet-abd",
1061 _ ("GNUnet abd resolver tool"), 1072 _ ("GNUnet abd resolver tool"),
1062 options, 1073 options,
1063 &run, 1074 &run,
1064 NULL)) 1075 NULL))
1065 ret = 1; 1076 ret = 1;
1066 GNUNET_free ((void *) argv); 1077 GNUNET_free ((void *) argv);
1067 return ret; 1078 return ret;
1068} 1079}
1069 1080
1081
1070/* end of gnunet-abd.c */ 1082/* end of gnunet-abd.c */