diff options
author | Andreas Ebner <pansy007@googlemail.com> | 2019-08-18 13:46:05 +0200 |
---|---|---|
committer | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2019-10-07 12:17:29 +0200 |
commit | 6ad2e1f1dce42e5c998425e80f48d512638e278e (patch) | |
tree | bb8e2d7d10aca751dc5711746c802c061846aff0 /src | |
parent | 7b749c91759eb75eda5cac1e02954cc82ef27db3 (diff) | |
download | gnunet-6ad2e1f1dce42e5c998425e80f48d512638e278e.tar.gz gnunet-6ad2e1f1dce42e5c998425e80f48d512638e278e.zip |
Bidirectional implementation finished, more complex tests for bidirectional, cleanup fix, todos done:
- fixed cleanup to not cause errors and uncommented it again
- added new tests for AND, linked roles and fw/bw
- fixed an older bug to make test ..own_and2.sh work
- replaced bidirectional matching of bw with unresolved_attribute.. (because it contains all the subject attributes/roles)
- introduced extra function for bidirectional match handling (is the same for bw and fw and pretty long)
- commandline: if not specified to use bw or fw search -> assume it's bidirectional
- moved the bidirecitonal matching list to vrh and removed it from being global
- valgrind on service (one error remaining, to be solved in future commits)
- use the vrh->dsq_head/tail for the cleanup stuff
Diffstat (limited to 'src')
-rw-r--r-- | src/credential/gnunet-credential.c | 30 | ||||
-rw-r--r-- | src/credential/gnunet-service-credential.c | 368 | ||||
-rwxr-xr-x | src/credential/test_credential_bi_and.sh | 99 | ||||
-rwxr-xr-x | src/credential/test_credential_bi_and2.sh | 96 | ||||
-rwxr-xr-x | src/credential/test_credential_bi_bw.sh (renamed from src/credential/test_credential_bi.sh) | 0 | ||||
-rwxr-xr-x | src/credential/test_credential_bi_bw_link.sh | 93 | ||||
-rwxr-xr-x | src/credential/test_credential_bi_bw_link2.sh | 94 | ||||
-rwxr-xr-x | src/credential/test_credential_bi_fw.sh | 95 | ||||
-rwxr-xr-x | src/credential/test_credential_own_and2.sh | 88 |
9 files changed, 792 insertions, 171 deletions
diff --git a/src/credential/gnunet-credential.c b/src/credential/gnunet-credential.c index 5cc1a791e..f2d967eea 100644 --- a/src/credential/gnunet-credential.c +++ b/src/credential/gnunet-credential.c | |||
@@ -769,12 +769,9 @@ run (void *cls, | |||
769 | 769 | ||
770 | if (GNUNET_NO == forward && GNUNET_NO == backward) | 770 | if (GNUNET_NO == forward && GNUNET_NO == backward) |
771 | { | 771 | { |
772 | fprintf ( | 772 | // set default: bidirectional |
773 | stderr, | 773 | forward = GNUNET_YES; |
774 | _ ( | 774 | backward = GNUNET_YES; |
775 | "You must state which search direction: '--forward' or '--backward'\n")); | ||
776 | GNUNET_SCHEDULER_shutdown (); | ||
777 | return; | ||
778 | } | 775 | } |
779 | if (GNUNET_YES == forward) | 776 | if (GNUNET_YES == forward) |
780 | direction |= GNUNET_CREDENTIAL_FLAG_FORWARD; | 777 | direction |= GNUNET_CREDENTIAL_FLAG_FORWARD; |
@@ -834,15 +831,6 @@ run (void *cls, | |||
834 | 831 | ||
835 | if (GNUNET_YES == verify) | 832 | if (GNUNET_YES == verify) |
836 | { | 833 | { |
837 | if (GNUNET_NO == forward && GNUNET_NO == backward) | ||
838 | { | ||
839 | fprintf ( | ||
840 | stderr, | ||
841 | _ ( | ||
842 | "You must state which search direction: '-forward' or 'backward'\n")); | ||
843 | GNUNET_SCHEDULER_shutdown (); | ||
844 | return; | ||
845 | } | ||
846 | if (NULL == issuer_key) | 834 | if (NULL == issuer_key) |
847 | { | 835 | { |
848 | fprintf (stderr, _ ("Issuer public key not well-formed\n")); | 836 | fprintf (stderr, _ ("Issuer public key not well-formed\n")); |
@@ -973,12 +961,12 @@ main (int argc, char *const *argv) | |||
973 | "EGO", | 961 | "EGO", |
974 | gettext_noop ("The ego/zone name to use"), | 962 | gettext_noop ("The ego/zone name to use"), |
975 | &ego_name), | 963 | &ego_name), |
976 | GNUNET_GETOPT_option_string ( | 964 | GNUNET_GETOPT_option_string ( |
977 | 'a', | 965 | 'a', |
978 | "attribute", | 966 | "attribute", |
979 | "ATTR", | 967 | "ATTR", |
980 | gettext_noop ("The issuer attribute to verify against or to issue"), | 968 | gettext_noop ("The issuer attribute to verify against or to issue"), |
981 | &issuer_attr), | 969 | &issuer_attr), |
982 | GNUNET_GETOPT_option_string ('T', | 970 | GNUNET_GETOPT_option_string ('T', |
983 | "ttl", | 971 | "ttl", |
984 | "EXP", | 972 | "EXP", |
diff --git a/src/credential/gnunet-service-credential.c b/src/credential/gnunet-service-credential.c index 9de16bf72..ee02042c8 100644 --- a/src/credential/gnunet-service-credential.c +++ b/src/credential/gnunet-service-credential.c | |||
@@ -293,6 +293,16 @@ struct VerifyRequestHandle | |||
293 | struct DelegationChainEntry *delegation_chain_tail; | 293 | struct DelegationChainEntry *delegation_chain_tail; |
294 | 294 | ||
295 | /** | 295 | /** |
296 | * List for bidirectional matching | ||
297 | */ | ||
298 | struct DelegationSetQueueEntry *dsq_head; | ||
299 | |||
300 | /** | ||
301 | * List for bidirectional matching | ||
302 | */ | ||
303 | struct DelegationSetQueueEntry *dsq_tail; | ||
304 | |||
305 | /** | ||
296 | * Issuer public key | 306 | * Issuer public key |
297 | */ | 307 | */ |
298 | struct GNUNET_CRYPTO_EcdsaPublicKey issuer_key; | 308 | struct GNUNET_CRYPTO_EcdsaPublicKey issuer_key; |
@@ -357,12 +367,12 @@ struct VerifyRequestHandle | |||
357 | /** | 367 | /** |
358 | * Head of the DLL. | 368 | * Head of the DLL. |
359 | */ | 369 | */ |
360 | static struct VerifyRequestHandle *vrh_head; | 370 | static struct VerifyRequestHandle *vrh_head = NULL; |
361 | 371 | ||
362 | /** | 372 | /** |
363 | * Tail of the DLL. | 373 | * Tail of the DLL. |
364 | */ | 374 | */ |
365 | static struct VerifyRequestHandle *vrh_tail; | 375 | static struct VerifyRequestHandle *vrh_tail = NULL; |
366 | 376 | ||
367 | /** | 377 | /** |
368 | * Handle to the statistics service | 378 | * Handle to the statistics service |
@@ -374,11 +384,6 @@ static struct GNUNET_STATISTICS_Handle *statistics; | |||
374 | */ | 384 | */ |
375 | static struct GNUNET_GNS_Handle *gns; | 385 | static struct GNUNET_GNS_Handle *gns; |
376 | 386 | ||
377 | //TODO vrh dependent | ||
378 | static struct DelegationSetQueueEntry *dsq_head; | ||
379 | static struct DelegationSetQueueEntry *dsq_tail; | ||
380 | |||
381 | |||
382 | /** | 387 | /** |
383 | * Handle to namestore service | 388 | * Handle to namestore service |
384 | */ | 389 | */ |
@@ -429,6 +434,45 @@ cleanup_delegation_set (struct DelegationSetQueueEntry *ds_entry) | |||
429 | } | 434 | } |
430 | 435 | ||
431 | static void | 436 | static void |
437 | cleanup_dsq_list (struct VerifyRequestHandle *vrh) | ||
438 | { | ||
439 | struct DelegationSetQueueEntry *ds_entry; | ||
440 | |||
441 | if (NULL == vrh->dsq_head) | ||
442 | return; | ||
443 | |||
444 | for (ds_entry = vrh->dsq_head; NULL != vrh->dsq_head; | ||
445 | ds_entry = vrh->dsq_head) | ||
446 | { | ||
447 | GNUNET_CONTAINER_DLL_remove (vrh->dsq_head, vrh->dsq_tail, ds_entry); | ||
448 | GNUNET_free_non_null (ds_entry->issuer_key); | ||
449 | GNUNET_free_non_null (ds_entry->issuer_attribute); | ||
450 | GNUNET_free_non_null (ds_entry->attr_trailer); | ||
451 | // those fields are only set/used in bw search | ||
452 | if (ds_entry->from_bw) | ||
453 | { | ||
454 | GNUNET_free_non_null (ds_entry->lookup_attribute); | ||
455 | GNUNET_free_non_null (ds_entry->unresolved_attribute_delegation); | ||
456 | } | ||
457 | if (NULL != ds_entry->lookup_request) | ||
458 | { | ||
459 | GNUNET_GNS_lookup_cancel (ds_entry->lookup_request); | ||
460 | ds_entry->lookup_request = NULL; | ||
461 | } | ||
462 | if (NULL != ds_entry->delegation_chain_entry) | ||
463 | { | ||
464 | GNUNET_free_non_null ( | ||
465 | ds_entry->delegation_chain_entry->subject_attribute); | ||
466 | GNUNET_free_non_null (ds_entry->delegation_chain_entry->issuer_attribute); | ||
467 | GNUNET_free (ds_entry->delegation_chain_entry); | ||
468 | } | ||
469 | //TODO: Free dq_entry, how? | ||
470 | //GNUNET_free (ds_entry->parent_queue_entry); | ||
471 | GNUNET_free (ds_entry); | ||
472 | } | ||
473 | } | ||
474 | |||
475 | static void | ||
432 | cleanup_handle (struct VerifyRequestHandle *vrh) | 476 | cleanup_handle (struct VerifyRequestHandle *vrh) |
433 | { | 477 | { |
434 | struct DelegateRecordEntry *del_entry; | 478 | struct DelegateRecordEntry *del_entry; |
@@ -438,7 +482,8 @@ cleanup_handle (struct VerifyRequestHandle *vrh) | |||
438 | GNUNET_GNS_lookup_cancel (vrh->lookup_request); | 482 | GNUNET_GNS_lookup_cancel (vrh->lookup_request); |
439 | vrh->lookup_request = NULL; | 483 | vrh->lookup_request = NULL; |
440 | } | 484 | } |
441 | cleanup_delegation_set (vrh->root_set); | 485 | //cleanup_delegation_set (vrh->root_set); |
486 | cleanup_dsq_list (vrh); | ||
442 | GNUNET_free_non_null (vrh->issuer_attribute); | 487 | GNUNET_free_non_null (vrh->issuer_attribute); |
443 | for (del_entry = vrh->del_chain_head; NULL != vrh->del_chain_head; | 488 | for (del_entry = vrh->del_chain_head; NULL != vrh->del_chain_head; |
444 | del_entry = vrh->del_chain_head) | 489 | del_entry = vrh->del_chain_head) |
@@ -491,7 +536,6 @@ send_lookup_response (struct VerifyRequestHandle *vrh) | |||
491 | struct DelegationChainResultMessage *rmsg; | 536 | struct DelegationChainResultMessage *rmsg; |
492 | struct DelegationChainEntry *dce; | 537 | struct DelegationChainEntry *dce; |
493 | struct GNUNET_CREDENTIAL_Delegation dd[vrh->delegation_chain_size]; | 538 | struct GNUNET_CREDENTIAL_Delegation dd[vrh->delegation_chain_size]; |
494 | //TODO rename all methods using credential | ||
495 | struct GNUNET_CREDENTIAL_Delegate dele[vrh->del_chain_size]; | 539 | struct GNUNET_CREDENTIAL_Delegate dele[vrh->del_chain_size]; |
496 | struct DelegateRecordEntry *del; | 540 | struct DelegateRecordEntry *del; |
497 | struct DelegateRecordEntry *tmp; | 541 | struct DelegateRecordEntry *tmp; |
@@ -574,7 +618,7 @@ send_lookup_response (struct VerifyRequestHandle *vrh) | |||
574 | GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (vrh->client), env); | 618 | GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (vrh->client), env); |
575 | GNUNET_CONTAINER_DLL_remove (vrh_head, vrh_tail, vrh); | 619 | GNUNET_CONTAINER_DLL_remove (vrh_head, vrh_tail, vrh); |
576 | //TODO fix cleanup with bidirectional | 620 | //TODO fix cleanup with bidirectional |
577 | //cleanup_handle (vrh); | 621 | cleanup_handle (vrh); |
578 | 622 | ||
579 | GNUNET_STATISTICS_update (statistics, | 623 | GNUNET_STATISTICS_update (statistics, |
580 | "Completed verifications", | 624 | "Completed verifications", |
@@ -639,6 +683,84 @@ partial_match (char *tmp_trail, | |||
639 | } | 683 | } |
640 | 684 | ||
641 | static void | 685 | static void |
686 | print_deleset (struct DelegationSetQueueEntry *dsentry, char *text) | ||
687 | { | ||
688 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
689 | "%s %s.%s <- %s.%s\n", | ||
690 | text, | ||
691 | GNUNET_CRYPTO_ecdsa_public_key_to_string ( | ||
692 | &dsentry->delegation_chain_entry->issuer_key), | ||
693 | dsentry->delegation_chain_entry->issuer_attribute, | ||
694 | GNUNET_CRYPTO_ecdsa_public_key_to_string ( | ||
695 | &dsentry->delegation_chain_entry->subject_key), | ||
696 | dsentry->delegation_chain_entry->subject_attribute); | ||
697 | } | ||
698 | |||
699 | static int | ||
700 | handle_bidirectional_match (struct DelegationSetQueueEntry *actual_entry, | ||
701 | struct DelegationSetQueueEntry *match_entry, | ||
702 | struct VerifyRequestHandle *vrh) | ||
703 | { | ||
704 | struct DelegationSetQueueEntry *old_fw_parent; | ||
705 | struct DelegationSetQueueEntry *fw_entry = actual_entry; | ||
706 | struct DelegationSetQueueEntry *last_entry = match_entry; | ||
707 | // parent fixing, combine backward and forward chain parts | ||
708 | while (NULL != fw_entry->parent_queue_entry) | ||
709 | { | ||
710 | old_fw_parent = fw_entry->parent_queue_entry->parent_set; | ||
711 | // set parent | ||
712 | fw_entry->parent_queue_entry->parent_set = last_entry; | ||
713 | |||
714 | last_entry = fw_entry; | ||
715 | fw_entry = old_fw_parent; | ||
716 | } | ||
717 | // set last entry of chain as actual_entry | ||
718 | //actual_entry = last_entry; | ||
719 | // set refcount, loop all delegations | ||
720 | for (struct DelegateRecordEntry *del_entry = vrh->del_chain_head; | ||
721 | del_entry != NULL; | ||
722 | del_entry = del_entry->next) | ||
723 | { | ||
724 | if (0 != memcmp (&last_entry->delegation_chain_entry->subject_key, | ||
725 | &del_entry->delegate->issuer_key, | ||
726 | sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey))) | ||
727 | continue; | ||
728 | if (0 != strcmp (last_entry->delegation_chain_entry->subject_attribute, | ||
729 | del_entry->delegate->issuer_attribute)) | ||
730 | continue; | ||
731 | |||
732 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found delegate.\n"); | ||
733 | // increase refcount of the start delegation | ||
734 | del_entry->refcount++; | ||
735 | } | ||
736 | // backtrack | ||
737 | for (struct DelegationSetQueueEntry *tmp_set = last_entry; | ||
738 | NULL != tmp_set->parent_queue_entry; | ||
739 | tmp_set = tmp_set->parent_queue_entry->parent_set) | ||
740 | { | ||
741 | tmp_set->parent_queue_entry->required_solutions--; | ||
742 | |||
743 | // add new found entry to vrh | ||
744 | vrh->delegation_chain_size++; | ||
745 | GNUNET_CONTAINER_DLL_insert (vrh->delegation_chain_head, | ||
746 | vrh->delegation_chain_tail, | ||
747 | tmp_set->delegation_chain_entry); | ||
748 | |||
749 | // if one node on the path still needs solutions, this current | ||
750 | // patch cannot fullfil the conditions and therefore stops here | ||
751 | // however, it is in the vrh and can be used by the other paths | ||
752 | // related to this path/collection/verification | ||
753 | if (0 < tmp_set->parent_queue_entry->required_solutions) | ||
754 | { | ||
755 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
756 | "Chain requires more solutions, waiting...\n"); | ||
757 | return GNUNET_NO; | ||
758 | } | ||
759 | } | ||
760 | return GNUNET_YES; | ||
761 | } | ||
762 | |||
763 | static void | ||
642 | forward_resolution (void *cls, | 764 | forward_resolution (void *cls, |
643 | uint32_t rd_count, | 765 | uint32_t rd_count, |
644 | const struct GNUNET_GNSRECORD_Data *rd) | 766 | const struct GNUNET_GNSRECORD_Data *rd) |
@@ -747,7 +869,6 @@ forward_resolution (void *cls, | |||
747 | 869 | ||
748 | // Start: Credential Chain Entry | 870 | // Start: Credential Chain Entry |
749 | // issuer key is subject key, who needs to be contacted to resolve this (forward, therefore subject) | 871 | // issuer key is subject key, who needs to be contacted to resolve this (forward, therefore subject) |
750 | // TODO: new ds_entry struct with subject_key (or one for both with contact_key or sth) | ||
751 | ds_entry->issuer_key = GNUNET_new (struct GNUNET_CRYPTO_EcdsaPublicKey); | 872 | ds_entry->issuer_key = GNUNET_new (struct GNUNET_CRYPTO_EcdsaPublicKey); |
752 | GNUNET_memcpy (ds_entry->issuer_key, | 873 | GNUNET_memcpy (ds_entry->issuer_key, |
753 | &del->subject_key, | 874 | &del->subject_key, |
@@ -816,41 +937,44 @@ forward_resolution (void *cls, | |||
816 | } | 937 | } |
817 | } | 938 | } |
818 | 939 | ||
819 | // TODO testing area | 940 | // Check for bidirectional crossmatch |
820 | 941 | for (struct DelegationSetQueueEntry *del_entry = vrh->dsq_head; | |
821 | // Check list | 942 | del_entry != NULL; |
822 | for (struct DelegationSetQueueEntry *del_entry = dsq_head; | 943 | del_entry = del_entry->next) |
823 | del_entry != NULL; | ||
824 | del_entry = del_entry->next) | ||
825 | { | 944 | { |
826 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"--fw-------- %s.%s <- %s.%s\n", | 945 | // only check entries not by backward algorithm |
827 | GNUNET_CRYPTO_ecdsa_public_key_to_string(&del_entry->delegation_chain_entry->issuer_key), | 946 | if (del_entry->from_bw) |
828 | del_entry->delegation_chain_entry->issuer_attribute, | ||
829 | GNUNET_CRYPTO_ecdsa_public_key_to_string(&del_entry->delegation_chain_entry->subject_key), | ||
830 | del_entry->delegation_chain_entry->subject_attribute); | ||
831 | |||
832 | // only check entries not added by forward algorithm | ||
833 | if(del_entry->from_bw) | ||
834 | { | 947 | { |
835 | // key of list entry matches actual key | 948 | // key of list entry matches actual key |
836 | if (0 == memcmp (&del_entry->delegation_chain_entry->subject_key, | 949 | if (0 == memcmp (&del_entry->delegation_chain_entry->subject_key, |
837 | &ds_entry->delegation_chain_entry->issuer_key, | 950 | &ds_entry->delegation_chain_entry->issuer_key, |
838 | sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey))) | 951 | sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey))) |
839 | { | 952 | { |
840 | // compare entry subject attributes to this trailer (iss attr + old trailer) | 953 | // compare entry subject attributes to this trailer (iss attr + old trailer) |
841 | if (0 == strcmp (del_entry->delegation_chain_entry->subject_attribute, | 954 | if (0 == strcmp (del_entry->unresolved_attribute_delegation, |
842 | ds_entry->attr_trailer)) | 955 | ds_entry->attr_trailer)) |
843 | { | 956 | { |
844 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"--fw-------- Found match with above!\n"); | 957 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
958 | "Forward: %s!\n", | ||
959 | del_entry->unresolved_attribute_delegation); | ||
960 | print_deleset (del_entry, "Forward:"); | ||
961 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
962 | "Forward: Found match with above!\n"); | ||
963 | |||
964 | // one node on the path still needs solutions: return | ||
965 | if (GNUNET_NO == | ||
966 | handle_bidirectional_match (ds_entry, del_entry, vrh)) | ||
967 | return; | ||
968 | |||
845 | send_lookup_response (vrh); | 969 | send_lookup_response (vrh); |
846 | return; | 970 | return; |
847 | } | 971 | } |
848 | } | 972 | } |
849 | } | 973 | } |
850 | } | 974 | } |
851 | // No crossmatch/bidirectional result, add this ds_entry for the bw algo to match | 975 | // No crossmatch/bidirectional found, add this ds_entry for the bw algo to match |
852 | ds_entry->from_bw = false; | 976 | ds_entry->from_bw = false; |
853 | GNUNET_CONTAINER_DLL_insert (dsq_head, dsq_tail, ds_entry); | 977 | GNUNET_CONTAINER_DLL_insert (vrh->dsq_head, vrh->dsq_tail, ds_entry); |
854 | 978 | ||
855 | // Starting a new GNS lookup | 979 | // Starting a new GNS lookup |
856 | vrh->pending_lookups++; | 980 | vrh->pending_lookups++; |
@@ -879,17 +1003,6 @@ forward_resolution (void *cls, | |||
879 | } | 1003 | } |
880 | 1004 | ||
881 | static void | 1005 | static void |
882 | print_deleset(struct DelegationSetQueueEntry *dsentry, char* text) | ||
883 | { | ||
884 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"%s %s.%s <- %s.%s\n", | ||
885 | text, | ||
886 | GNUNET_CRYPTO_ecdsa_public_key_to_string(&dsentry->delegation_chain_entry->issuer_key), | ||
887 | dsentry->delegation_chain_entry->issuer_attribute, | ||
888 | GNUNET_CRYPTO_ecdsa_public_key_to_string(&dsentry->delegation_chain_entry->subject_key), | ||
889 | dsentry->delegation_chain_entry->subject_attribute); | ||
890 | } | ||
891 | |||
892 | static void | ||
893 | backward_resolution (void *cls, | 1006 | backward_resolution (void *cls, |
894 | uint32_t rd_count, | 1007 | uint32_t rd_count, |
895 | const struct GNUNET_GNSRECORD_Data *rd) | 1008 | const struct GNUNET_GNSRECORD_Data *rd) |
@@ -987,9 +1100,10 @@ backward_resolution (void *cls, | |||
987 | 1100 | ||
988 | ds_entry->parent_queue_entry = dq_entry; // current_delegation; | 1101 | ds_entry->parent_queue_entry = dq_entry; // current_delegation; |
989 | 1102 | ||
990 | GNUNET_CONTAINER_DLL_insert (dq_entry->set_entries_head, | 1103 | // TODO required? everything in dsq_head list, change cleanup |
1104 | /*GNUNET_CONTAINER_DLL_insert (dq_entry->set_entries_head, | ||
991 | dq_entry->set_entries_tail, | 1105 | dq_entry->set_entries_tail, |
992 | ds_entry); | 1106 | ds_entry);*/ |
993 | 1107 | ||
994 | /** | 1108 | /** |
995 | * Check if this delegation already matches one of our credentials | 1109 | * Check if this delegation already matches one of our credentials |
@@ -1000,7 +1114,7 @@ backward_resolution (void *cls, | |||
1000 | del_pointer = del_pointer->next) | 1114 | del_pointer = del_pointer->next) |
1001 | { | 1115 | { |
1002 | // If key and attribute match credential: continue and backtrack | 1116 | // If key and attribute match credential: continue and backtrack |
1003 | if (0 != memcmp (&set->subject_key, | 1117 | if (0 != memcmp (&set[j].subject_key, |
1004 | &del_pointer->delegate->issuer_key, | 1118 | &del_pointer->delegate->issuer_key, |
1005 | sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey))) | 1119 | sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey))) |
1006 | continue; | 1120 | continue; |
@@ -1033,7 +1147,7 @@ backward_resolution (void *cls, | |||
1033 | break; | 1147 | break; |
1034 | } | 1148 | } |
1035 | 1149 | ||
1036 | // if the break above is not called the condition of the for is met | 1150 | // if the break above is not called the condition of the for is met |
1037 | if (NULL == tmp_set->parent_queue_entry) | 1151 | if (NULL == tmp_set->parent_queue_entry) |
1038 | { | 1152 | { |
1039 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All solutions found\n"); | 1153 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All solutions found\n"); |
@@ -1073,94 +1187,33 @@ backward_resolution (void *cls, | |||
1073 | ds_entry->attr_trailer = GNUNET_strdup (next_attr); | 1187 | ds_entry->attr_trailer = GNUNET_strdup (next_attr); |
1074 | } | 1188 | } |
1075 | 1189 | ||
1076 | 1190 | // Check for bidirectional crossmatch | |
1077 | // TODO testing area | 1191 | for (struct DelegationSetQueueEntry *del_entry = vrh->dsq_head; |
1078 | // Check list | 1192 | del_entry != NULL; |
1079 | for (struct DelegationSetQueueEntry *del_entry = dsq_head; | 1193 | del_entry = del_entry->next) |
1080 | del_entry != NULL; | ||
1081 | del_entry = del_entry->next) | ||
1082 | { | 1194 | { |
1083 | print_deleset(del_entry, "-----bw----- "); | 1195 | // only check entries added by forward algorithm |
1084 | 1196 | if (!del_entry->from_bw) | |
1085 | // only check entries not added by forward algorithm | ||
1086 | if(!del_entry->from_bw) | ||
1087 | { | 1197 | { |
1088 | // key of list entry matches actual key | 1198 | // key of list entry matches actual key |
1089 | if (0 == memcmp (&del_entry->delegation_chain_entry->issuer_key, | 1199 | if (0 == memcmp (&del_entry->delegation_chain_entry->issuer_key, |
1090 | &ds_entry->delegation_chain_entry->subject_key, | 1200 | &ds_entry->delegation_chain_entry->subject_key, |
1091 | sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey))) | 1201 | sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey))) |
1092 | { | 1202 | { |
1093 | // compare entry subject attributes to this trailer (iss attr + old trailer) | 1203 | // compare entry subject attributes to this trailer (iss attr + old trailer) |
1094 | if (0 == strcmp (del_entry->attr_trailer, | 1204 | if (0 == strcmp (del_entry->attr_trailer, |
1095 | ds_entry->delegation_chain_entry->subject_attribute)) | 1205 | ds_entry->unresolved_attribute_delegation)) |
1096 | { | 1206 | { |
1097 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"--bw-------- Found match with above!\n"); | 1207 | print_deleset (del_entry, "Backward:"); |
1098 | 1208 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | |
1099 | //TODO parents are not set correctly, for FW parents are going down in the chain | 1209 | "Backward: Found match with above!\n"); |
1100 | // and for BW parents are going up | ||
1101 | // therefore: parent fixing needs to be done and then the stuff from above | ||
1102 | // backtrack(required solutions) and refcount++ | ||
1103 | // might need some functions cuz its getting real big in here | ||
1104 | |||
1105 | struct DelegationSetQueueEntry *old_fw_parent; | ||
1106 | struct DelegationSetQueueEntry *fw_entry = del_entry; | ||
1107 | struct DelegationSetQueueEntry *bw_entry = ds_entry; | ||
1108 | // parentset and add | ||
1109 | while(NULL != fw_entry->parent_queue_entry) | ||
1110 | { | ||
1111 | print_deleset(fw_entry, "-----in while----- "); | ||
1112 | old_fw_parent = fw_entry->parent_queue_entry->parent_set; | ||
1113 | // set parent | ||
1114 | fw_entry->parent_queue_entry->parent_set = bw_entry; | ||
1115 | 1210 | ||
1116 | bw_entry = fw_entry; | 1211 | // if one node on the path still needs solutions: return |
1117 | fw_entry = old_fw_parent; | 1212 | if (GNUNET_NO == |
1118 | } | 1213 | handle_bidirectional_match (del_entry, ds_entry, vrh)) |
1119 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "NACH WHILE\n"); | 1214 | break; |
1120 | // set last entry of chain as actual ds_entry | ||
1121 | ds_entry = bw_entry; | ||
1122 | // set refcount, loop all delegations | ||
1123 | for (del_pointer = vrh->del_chain_head; del_pointer != NULL; | ||
1124 | del_pointer = del_pointer->next) | ||
1125 | { | ||
1126 | if (0 != memcmp (&ds_entry->delegation_chain_entry->subject_key, | ||
1127 | &del_pointer->delegate->issuer_key, | ||
1128 | sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey))) | ||
1129 | continue; | ||
1130 | if (0 != strcmp (ds_entry->delegation_chain_entry->subject_attribute, | ||
1131 | del_pointer->delegate->issuer_attribute)) | ||
1132 | continue; | ||
1133 | |||
1134 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found delegate.\n"); | ||
1135 | // increase refcount of the start delegation | ||
1136 | del_pointer->refcount++; | ||
1137 | } | ||
1138 | // backtrack | ||
1139 | for (tmp_set = ds_entry; NULL != tmp_set->parent_queue_entry; | ||
1140 | tmp_set = tmp_set->parent_queue_entry->parent_set) | ||
1141 | { | ||
1142 | //TODO set refcount | ||
1143 | print_deleset(tmp_set, "-----ENDSET----- "); | ||
1144 | tmp_set->parent_queue_entry->required_solutions--; | ||
1145 | 1215 | ||
1146 | // add new found entry to vrh | 1216 | // Send lookup response |
1147 | vrh->delegation_chain_size++; | ||
1148 | GNUNET_CONTAINER_DLL_insert (vrh->delegation_chain_head, | ||
1149 | vrh->delegation_chain_tail, | ||
1150 | tmp_set->delegation_chain_entry); | ||
1151 | |||
1152 | // if one node on the path still needs solutions, this current | ||
1153 | // patch cannot fullfil the conditions and therefore stops here | ||
1154 | // however, it is in the vrh and can be used by the other paths | ||
1155 | // related to this path/collection/verification | ||
1156 | if (0 < tmp_set->parent_queue_entry->required_solutions) | ||
1157 | { | ||
1158 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Chain requires more solutions, waiting...\n"); | ||
1159 | return; | ||
1160 | } | ||
1161 | } | ||
1162 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "NACH FOR\n"); | ||
1163 | |||
1164 | send_lookup_response (vrh); | 1217 | send_lookup_response (vrh); |
1165 | return; | 1218 | return; |
1166 | } | 1219 | } |
@@ -1168,11 +1221,11 @@ backward_resolution (void *cls, | |||
1168 | } | 1221 | } |
1169 | } | 1222 | } |
1170 | // No crossmatch/bidirectional result, add this ds_entry for the bw algo to match | 1223 | // No crossmatch/bidirectional result, add this ds_entry for the bw algo to match |
1171 | ds_entry->from_bw = true; | 1224 | ds_entry->from_bw = true; |
1172 | GNUNET_CONTAINER_DLL_insert (dsq_head, dsq_tail, ds_entry); | ||
1173 | |||
1174 | 1225 | ||
1226 | GNUNET_CONTAINER_DLL_insert (vrh->dsq_head, vrh->dsq_tail, ds_entry); | ||
1175 | 1227 | ||
1228 | // Starting a new GNS lookup | ||
1176 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1229 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1177 | "Looking up %s\n", | 1230 | "Looking up %s\n", |
1178 | ds_entry->lookup_attribute); | 1231 | ds_entry->lookup_attribute); |
@@ -1225,6 +1278,13 @@ delegation_chain_bw_resolution_start (void *cls) | |||
1225 | return; | 1278 | return; |
1226 | } | 1279 | } |
1227 | 1280 | ||
1281 | // Pre-check with vrh->dele_chain_.. if match issuer_key | ||
1282 | // Backward: check every cred entry if match issuer key | ||
1283 | // otherwise: start at issuer and go down till match | ||
1284 | // A.a <- ... | ||
1285 | // X.x <- C | ||
1286 | // Y.y <- C | ||
1287 | // if not X.x or Y.y == A.a stat at A | ||
1228 | for (del_entry = vrh->del_chain_head; del_entry != NULL; | 1288 | for (del_entry = vrh->del_chain_head; del_entry != NULL; |
1229 | del_entry = del_entry->next) | 1289 | del_entry = del_entry->next) |
1230 | { | 1290 | { |
@@ -1283,19 +1343,6 @@ delegation_chain_fw_resolution_start (void *cls) | |||
1283 | // set to 0 and increase on each lookup: for fw multiple lookups (may be) started | 1343 | // set to 0 and increase on each lookup: for fw multiple lookups (may be) started |
1284 | vrh->pending_lookups = 0; | 1344 | vrh->pending_lookups = 0; |
1285 | 1345 | ||
1286 | //TODO no pre-check with vrh->dele_chain_bla if match issuer_key | ||
1287 | //otherwise: start mutliple lookups for each vrh->dele_chain | ||
1288 | // A.a <- ... | ||
1289 | // X.x <- C | ||
1290 | // Y.y <- C | ||
1291 | // wenn X.x oder Y.y nicht == A.a dann starte bei X und bei Y | ||
1292 | |||
1293 | // bei backward: check every cred entry if match issuer key | ||
1294 | // otherwise: start at issuer and go down till match | ||
1295 | // A.a <- ... | ||
1296 | // X.x <- C | ||
1297 | // Y.y <- C | ||
1298 | // wenn X.x oder Y.y nicht == A.a dann starte von A | ||
1299 | if (0 == vrh->del_chain_size) | 1346 | if (0 == vrh->del_chain_size) |
1300 | { | 1347 | { |
1301 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No delegations found\n"); | 1348 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No delegations found\n"); |
@@ -1303,7 +1350,12 @@ delegation_chain_fw_resolution_start (void *cls) | |||
1303 | return; | 1350 | return; |
1304 | } | 1351 | } |
1305 | 1352 | ||
1306 | // Check if one of the delegations of the subject already match | 1353 | // Pre-check with vrh->dele_chain_.. if match issuer_key |
1354 | // otherwise FW: start mutliple lookups for each vrh->dele_chain | ||
1355 | // A.a <- ... | ||
1356 | // X.x <- C | ||
1357 | // Y.y <- C | ||
1358 | // if not X.x or Y.y == A.a start at X and at Y | ||
1307 | for (del_entry = vrh->del_chain_head; del_entry != NULL; | 1359 | for (del_entry = vrh->del_chain_head; del_entry != NULL; |
1308 | del_entry = del_entry->next) | 1360 | del_entry = del_entry->next) |
1309 | { | 1361 | { |
@@ -1337,7 +1389,6 @@ delegation_chain_fw_resolution_start (void *cls) | |||
1337 | 1389 | ||
1338 | ds_entry = GNUNET_new (struct DelegationSetQueueEntry); | 1390 | ds_entry = GNUNET_new (struct DelegationSetQueueEntry); |
1339 | ds_entry->issuer_key = GNUNET_new (struct GNUNET_CRYPTO_EcdsaPublicKey); | 1391 | ds_entry->issuer_key = GNUNET_new (struct GNUNET_CRYPTO_EcdsaPublicKey); |
1340 | // TODO: new ds_entry struct with subject_key (or one for both with contact_key or sth) | ||
1341 | GNUNET_memcpy (ds_entry->issuer_key, | 1392 | GNUNET_memcpy (ds_entry->issuer_key, |
1342 | &del_entry->delegate->subject_key, | 1393 | &del_entry->delegate->subject_key, |
1343 | sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey)); | 1394 | sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey)); |
@@ -1416,6 +1467,13 @@ handle_verify (void *cls, const struct VerifyMessage *v_msg) | |||
1416 | vrh->issuer_attribute = GNUNET_strdup (issuer_attribute); | 1467 | vrh->issuer_attribute = GNUNET_strdup (issuer_attribute); |
1417 | vrh->resolution_algo = ntohs (v_msg->resolution_algo); | 1468 | vrh->resolution_algo = ntohs (v_msg->resolution_algo); |
1418 | 1469 | ||
1470 | vrh->del_chain_head = NULL; | ||
1471 | vrh->del_chain_tail = NULL; | ||
1472 | vrh->dsq_head = NULL; | ||
1473 | vrh->dsq_tail = NULL; | ||
1474 | vrh->del_chain_head = NULL; | ||
1475 | vrh->del_chain_tail = NULL; | ||
1476 | |||
1419 | GNUNET_SERVICE_client_continue (vrh->client); | 1477 | GNUNET_SERVICE_client_continue (vrh->client); |
1420 | if (0 == strlen (issuer_attribute)) | 1478 | if (0 == strlen (issuer_attribute)) |
1421 | { | 1479 | { |
@@ -1467,12 +1525,14 @@ handle_verify (void *cls, const struct VerifyMessage *v_msg) | |||
1467 | } | 1525 | } |
1468 | 1526 | ||
1469 | // Switch resolution algo | 1527 | // Switch resolution algo |
1470 | if(GNUNET_CREDENTIAL_FLAG_BACKWARD & vrh->resolution_algo && GNUNET_CREDENTIAL_FLAG_FORWARD & vrh->resolution_algo) | 1528 | if (GNUNET_CREDENTIAL_FLAG_BACKWARD & vrh->resolution_algo && |
1529 | GNUNET_CREDENTIAL_FLAG_FORWARD & vrh->resolution_algo) | ||
1471 | { | 1530 | { |
1472 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "--------BOTH\n"); | 1531 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "--------BOTH\n"); |
1473 | delegation_chain_fw_resolution_start (vrh); | 1532 | delegation_chain_fw_resolution_start (vrh); |
1474 | delegation_chain_bw_resolution_start (vrh); | 1533 | delegation_chain_bw_resolution_start (vrh); |
1475 | } else if (GNUNET_CREDENTIAL_FLAG_BACKWARD & vrh->resolution_algo) | 1534 | } |
1535 | else if (GNUNET_CREDENTIAL_FLAG_BACKWARD & vrh->resolution_algo) | ||
1476 | { | 1536 | { |
1477 | delegation_chain_bw_resolution_start (vrh); | 1537 | delegation_chain_bw_resolution_start (vrh); |
1478 | } | 1538 | } |
@@ -1498,13 +1558,14 @@ delegate_collection_finished (void *cls) | |||
1498 | struct VerifyRequestHandle *vrh = cls; | 1558 | struct VerifyRequestHandle *vrh = cls; |
1499 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Done collecting delegates.\n"); | 1559 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Done collecting delegates.\n"); |
1500 | 1560 | ||
1501 | //TODO correct calls | 1561 | // if both are set: bidirectional search, meaning start both chain resolutions |
1502 | if(GNUNET_CREDENTIAL_FLAG_BACKWARD & vrh->resolution_algo && GNUNET_CREDENTIAL_FLAG_FORWARD & vrh->resolution_algo) | 1562 | if (GNUNET_CREDENTIAL_FLAG_BACKWARD & vrh->resolution_algo && |
1563 | GNUNET_CREDENTIAL_FLAG_FORWARD & vrh->resolution_algo) | ||
1503 | { | 1564 | { |
1504 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "--------BOTH\n"); | ||
1505 | delegation_chain_fw_resolution_start (vrh); | 1565 | delegation_chain_fw_resolution_start (vrh); |
1506 | delegation_chain_bw_resolution_start (vrh); | 1566 | delegation_chain_bw_resolution_start (vrh); |
1507 | }else if (GNUNET_CREDENTIAL_FLAG_BACKWARD & vrh->resolution_algo) | 1567 | } |
1568 | else if (GNUNET_CREDENTIAL_FLAG_BACKWARD & vrh->resolution_algo) | ||
1508 | { | 1569 | { |
1509 | delegation_chain_bw_resolution_start (vrh); | 1570 | delegation_chain_bw_resolution_start (vrh); |
1510 | } | 1571 | } |
@@ -1581,6 +1642,13 @@ handle_collect (void *cls, const struct CollectMessage *c_msg) | |||
1581 | vrh->issuer_attribute = GNUNET_strdup (issuer_attribute); | 1642 | vrh->issuer_attribute = GNUNET_strdup (issuer_attribute); |
1582 | vrh->resolution_algo = ntohs (c_msg->resolution_algo); | 1643 | vrh->resolution_algo = ntohs (c_msg->resolution_algo); |
1583 | 1644 | ||
1645 | vrh->del_chain_head = NULL; | ||
1646 | vrh->del_chain_tail = NULL; | ||
1647 | vrh->dsq_head = NULL; | ||
1648 | vrh->dsq_tail = NULL; | ||
1649 | vrh->del_chain_head = NULL; | ||
1650 | vrh->del_chain_tail = NULL; | ||
1651 | |||
1584 | if (0 == strlen (issuer_attribute)) | 1652 | if (0 == strlen (issuer_attribute)) |
1585 | { | 1653 | { |
1586 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No issuer attribute provided!\n"); | 1654 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No issuer attribute provided!\n"); |
diff --git a/src/credential/test_credential_bi_and.sh b/src/credential/test_credential_bi_and.sh new file mode 100755 index 000000000..c69aea53f --- /dev/null +++ b/src/credential/test_credential_bi_and.sh | |||
@@ -0,0 +1,99 @@ | |||
1 | #!/usr/bin/env bash | ||
2 | trap "gnunet-arm -e -c test_credential_lookup.conf" SIGINT | ||
3 | |||
4 | LOCATION=$(which gnunet-config) | ||
5 | if [ -z $LOCATION ] | ||
6 | then | ||
7 | LOCATION="gnunet-config" | ||
8 | fi | ||
9 | $LOCATION --version 1> /dev/null | ||
10 | if test $? != 0 | ||
11 | then | ||
12 | echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX" | ||
13 | exit 77 | ||
14 | fi | ||
15 | |||
16 | rm -rf `gnunet-config -c test_credential_lookup.conf -s PATHS -o GNUNET_HOME -f` | ||
17 | |||
18 | |||
19 | |||
20 | |||
21 | which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 10" | ||
22 | gnunet-arm -s -c test_credential_lookup.conf | ||
23 | |||
24 | gnunet-identity -C a -c test_credential_lookup.conf | ||
25 | gnunet-identity -C b -c test_credential_lookup.conf | ||
26 | gnunet-identity -C c -c test_credential_lookup.conf | ||
27 | gnunet-identity -C d -c test_credential_lookup.conf | ||
28 | gnunet-identity -C e -c test_credential_lookup.conf | ||
29 | gnunet-identity -C f -c test_credential_lookup.conf | ||
30 | gnunet-identity -C g -c test_credential_lookup.conf | ||
31 | gnunet-identity -C h -c test_credential_lookup.conf | ||
32 | AKEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep a | awk '{print $3}') | ||
33 | BKEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep b | awk '{print $3}') | ||
34 | CKEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep c | awk '{print $3}') | ||
35 | DKEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep d | awk '{print $3}') | ||
36 | EKEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep e | awk '{print $3}') | ||
37 | FKEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep f | awk '{print $3}') | ||
38 | GKEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep g | awk '{print $3}') | ||
39 | HKEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep h | awk '{print $3}') | ||
40 | |||
41 | # (1) (A.a) <- B.b | ||
42 | # (2) (B.b) <- C.c AND G.g | ||
43 | # (3) C.c <- (D.D) | ||
44 | # (4) D.d <- (E.e) | ||
45 | # (5) E.e <- (F) priv | ||
46 | # (6) (G.g) <- H.h | ||
47 | # (7) H.h <- (F) priv | ||
48 | |||
49 | # BIDIRECTIONAL | ||
50 | gnunet-credential --createIssuerSide --ego=a --attribute="a" --subject="$BKEY b" --ttl=5m -c test_credential_lookup.conf | ||
51 | gnunet-namestore -D -z a | ||
52 | gnunet-credential --createIssuerSide --ego=b --attribute="b" --subject="$CKEY c, $GKEY g" --ttl=5m -c test_credential_lookup.conf | ||
53 | gnunet-namestore -D -z b | ||
54 | gnunet-credential --createIssuerSide --ego=g --attribute="g" --subject="$HKEY h" --ttl=5m -c test_credential_lookup.conf | ||
55 | gnunet-namestore -D -z b | ||
56 | |||
57 | SIGNED=`$DO_TIMEOUT gnunet-credential --signSubjectSide --ego=c --attribute="c" --subject="$DKEY d" --ttl="2019-12-12 10:00:00"` | ||
58 | gnunet-credential --createSubjectSide --ego=d --import "$SIGNED" | ||
59 | gnunet-namestore -D -z d | ||
60 | SIGNED=`$DO_TIMEOUT gnunet-credential --signSubjectSide --ego=d --attribute="d" --subject="$EKEY e" --ttl="2019-12-12 10:00:00"` | ||
61 | gnunet-credential --createSubjectSide --ego=e --import "$SIGNED" | ||
62 | gnunet-namestore -D -z e | ||
63 | SIGNED=`$DO_TIMEOUT gnunet-credential --signSubjectSide --ego=e --attribute="e" --subject="$FKEY" --ttl="2019-12-12 10:00:00"` | ||
64 | gnunet-credential --createSubjectSide --ego=f --import "$SIGNED" --private | ||
65 | gnunet-namestore -D -z f | ||
66 | SIGNED=`$DO_TIMEOUT gnunet-credential --signSubjectSide --ego=h --attribute="h" --subject="$FKEY" --ttl="2019-12-12 10:00:00"` | ||
67 | gnunet-credential --createSubjectSide --ego=f --import "$SIGNED" --private | ||
68 | gnunet-namestore -D -z h | ||
69 | |||
70 | # Starting to resolve | ||
71 | echo "+++ Starting to Resolve +++" | ||
72 | |||
73 | DELS=`$DO_TIMEOUT gnunet-credential --collect --issuer=$AKEY --attribute="a" --ego=f --forward --backward -c test_credential_lookup.conf | paste -d, -s` | ||
74 | echo $DELS | ||
75 | echo gnunet-credential --verify --issuer=$AKEY --attribute="a" --subject=$FKEY --delegate=\'$DELS\' --forward --backward -c test_credential_lookup.conf | ||
76 | RES_DELS=`gnunet-credential --verify --issuer=$AKEY --attribute="a" --subject=$FKEY --delegate="$DELS" --forward --backward -c test_credential_lookup.conf` | ||
77 | |||
78 | # Cleanup properly | ||
79 | gnunet-namestore -z epub -d -n $DISC_ATTR -t ATTR -c test_credential_lookup.conf | ||
80 | gnunet-namestore -z eorg -d -n $PREF_ATTR -t ATTR -c test_credential_lookup.conf | ||
81 | gnunet-namestore -z stateu -d -n $STATE_STUD_ATTR -t ATTR -c test_credential_lookup.conf | ||
82 | #gnunet-namestore -z a -d -n $STATE_STUD_ATTR -t ATTR -c test_credential_lookup.conf | ||
83 | #gnunet-namestore -z d -d -n $STATE_STUD_ATTR -t ATTR -c test_credential_lookup.conf | ||
84 | #gnunet-namestore -z e -d -n $STATE_STUD_ATTR -t ATTR -c test_credential_lookup.conf | ||
85 | #gnunet-namestore -z f -d -n $STATE_STUD_ATTR -t ATTR -c test_credential_lookup.conf | ||
86 | #gnunet-namestore -z g -d -n $STATE_STUD_ATTR -t ATTR -c test_credential_lookup.conf | ||
87 | |||
88 | gnunet-arm -e -c test_credential_lookup.conf | ||
89 | |||
90 | if [ "$RES_DELS" != "Failed." ] | ||
91 | then | ||
92 | # TODO: replace echo -e bashism | ||
93 | echo -e "${RES_DELS}" | ||
94 | exit 0 | ||
95 | else | ||
96 | echo "FAIL: Failed to verify credential $RES_DELS." | ||
97 | exit 1 | ||
98 | fi | ||
99 | |||
diff --git a/src/credential/test_credential_bi_and2.sh b/src/credential/test_credential_bi_and2.sh new file mode 100755 index 000000000..de3e718aa --- /dev/null +++ b/src/credential/test_credential_bi_and2.sh | |||
@@ -0,0 +1,96 @@ | |||
1 | #!/usr/bin/env bash | ||
2 | trap "gnunet-arm -e -c test_credential_lookup.conf" SIGINT | ||
3 | |||
4 | LOCATION=$(which gnunet-config) | ||
5 | if [ -z $LOCATION ] | ||
6 | then | ||
7 | LOCATION="gnunet-config" | ||
8 | fi | ||
9 | $LOCATION --version 1> /dev/null | ||
10 | if test $? != 0 | ||
11 | then | ||
12 | echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX" | ||
13 | exit 77 | ||
14 | fi | ||
15 | |||
16 | rm -rf `gnunet-config -c test_credential_lookup.conf -s PATHS -o GNUNET_HOME -f` | ||
17 | |||
18 | |||
19 | |||
20 | |||
21 | which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 10" | ||
22 | gnunet-arm -s -c test_credential_lookup.conf | ||
23 | |||
24 | gnunet-identity -C a -c test_credential_lookup.conf | ||
25 | gnunet-identity -C b -c test_credential_lookup.conf | ||
26 | gnunet-identity -C c -c test_credential_lookup.conf | ||
27 | gnunet-identity -C d -c test_credential_lookup.conf | ||
28 | gnunet-identity -C e -c test_credential_lookup.conf | ||
29 | gnunet-identity -C f -c test_credential_lookup.conf | ||
30 | gnunet-identity -C g -c test_credential_lookup.conf | ||
31 | gnunet-identity -C h -c test_credential_lookup.conf | ||
32 | AKEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep a | awk '{print $3}') | ||
33 | BKEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep b | awk '{print $3}') | ||
34 | CKEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep c | awk '{print $3}') | ||
35 | DKEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep d | awk '{print $3}') | ||
36 | EKEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep e | awk '{print $3}') | ||
37 | FKEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep f | awk '{print $3}') | ||
38 | GKEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep g | awk '{print $3}') | ||
39 | HKEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep h | awk '{print $3}') | ||
40 | |||
41 | # (1) (A.a) <- B.b | ||
42 | # (2) (B.b) <- C.c AND G.g | ||
43 | # (3) C.c <- (D.D) | ||
44 | # (4) D.d <- (E.e) | ||
45 | # (5) E.e <- (F) priv | ||
46 | # (6) G.g <- (F) priv | ||
47 | |||
48 | # BIDIRECTIONAL | ||
49 | gnunet-credential --createIssuerSide --ego=a --attribute="a" --subject="$BKEY b" --ttl=5m -c test_credential_lookup.conf | ||
50 | gnunet-namestore -D -z a | ||
51 | gnunet-credential --createIssuerSide --ego=b --attribute="b" --subject="$CKEY c, $GKEY g" --ttl=5m -c test_credential_lookup.conf | ||
52 | gnunet-namestore -D -z b | ||
53 | |||
54 | SIGNED=`$DO_TIMEOUT gnunet-credential --signSubjectSide --ego=c --attribute="c" --subject="$DKEY d" --ttl="2019-12-12 10:00:00"` | ||
55 | gnunet-credential --createSubjectSide --ego=d --import "$SIGNED" | ||
56 | gnunet-namestore -D -z d | ||
57 | SIGNED=`$DO_TIMEOUT gnunet-credential --signSubjectSide --ego=d --attribute="d" --subject="$EKEY e" --ttl="2019-12-12 10:00:00"` | ||
58 | gnunet-credential --createSubjectSide --ego=e --import "$SIGNED" | ||
59 | gnunet-namestore -D -z e | ||
60 | SIGNED=`$DO_TIMEOUT gnunet-credential --signSubjectSide --ego=e --attribute="e" --subject="$FKEY" --ttl="2019-12-12 10:00:00"` | ||
61 | gnunet-credential --createSubjectSide --ego=f --import "$SIGNED" --private | ||
62 | gnunet-namestore -D -z f | ||
63 | SIGNED=`$DO_TIMEOUT gnunet-credential --signSubjectSide --ego=g --attribute="g" --subject="$FKEY" --ttl="2019-12-12 10:00:00"` | ||
64 | gnunet-credential --createSubjectSide --ego=f --import "$SIGNED" --private | ||
65 | gnunet-namestore -D -z h | ||
66 | |||
67 | # Starting to resolve | ||
68 | echo "+++ Starting to Resolve +++" | ||
69 | |||
70 | DELS=`$DO_TIMEOUT gnunet-credential --collect --issuer=$AKEY --attribute="a" --ego=f -c test_credential_lookup.conf | paste -d, -s` | ||
71 | echo $DELS | ||
72 | echo gnunet-credential --verify --issuer=$AKEY --attribute="a" --subject=$FKEY --delegate=\'$DELS\' -c test_credential_lookup.conf | ||
73 | RES_DELS=`gnunet-credential --verify --issuer=$AKEY --attribute="a" --subject=$FKEY --delegate="$DELS" -c test_credential_lookup.conf` | ||
74 | |||
75 | # Cleanup properly | ||
76 | gnunet-namestore -z epub -d -n $DISC_ATTR -t ATTR -c test_credential_lookup.conf | ||
77 | gnunet-namestore -z eorg -d -n $PREF_ATTR -t ATTR -c test_credential_lookup.conf | ||
78 | gnunet-namestore -z stateu -d -n $STATE_STUD_ATTR -t ATTR -c test_credential_lookup.conf | ||
79 | #gnunet-namestore -z a -d -n $STATE_STUD_ATTR -t ATTR -c test_credential_lookup.conf | ||
80 | #gnunet-namestore -z d -d -n $STATE_STUD_ATTR -t ATTR -c test_credential_lookup.conf | ||
81 | #gnunet-namestore -z e -d -n $STATE_STUD_ATTR -t ATTR -c test_credential_lookup.conf | ||
82 | #gnunet-namestore -z f -d -n $STATE_STUD_ATTR -t ATTR -c test_credential_lookup.conf | ||
83 | #gnunet-namestore -z g -d -n $STATE_STUD_ATTR -t ATTR -c test_credential_lookup.conf | ||
84 | |||
85 | gnunet-arm -e -c test_credential_lookup.conf | ||
86 | |||
87 | if [ "$RES_DELS" != "Failed." ] | ||
88 | then | ||
89 | # TODO: replace echo -e bashism | ||
90 | echo -e "${RES_DELS}" | ||
91 | exit 0 | ||
92 | else | ||
93 | echo "FAIL: Failed to verify credential $RES_DELS." | ||
94 | exit 1 | ||
95 | fi | ||
96 | |||
diff --git a/src/credential/test_credential_bi.sh b/src/credential/test_credential_bi_bw.sh index 2b8cfc452..2b8cfc452 100755 --- a/src/credential/test_credential_bi.sh +++ b/src/credential/test_credential_bi_bw.sh | |||
diff --git a/src/credential/test_credential_bi_bw_link.sh b/src/credential/test_credential_bi_bw_link.sh new file mode 100755 index 000000000..dd66741fa --- /dev/null +++ b/src/credential/test_credential_bi_bw_link.sh | |||
@@ -0,0 +1,93 @@ | |||
1 | #!/usr/bin/env bash | ||
2 | trap "gnunet-arm -e -c test_credential_lookup.conf" SIGINT | ||
3 | |||
4 | LOCATION=$(which gnunet-config) | ||
5 | if [ -z $LOCATION ] | ||
6 | then | ||
7 | LOCATION="gnunet-config" | ||
8 | fi | ||
9 | $LOCATION --version 1> /dev/null | ||
10 | if test $? != 0 | ||
11 | then | ||
12 | echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX" | ||
13 | exit 77 | ||
14 | fi | ||
15 | |||
16 | rm -rf `gnunet-config -c test_credential_lookup.conf -s PATHS -o GNUNET_HOME -f` | ||
17 | |||
18 | |||
19 | |||
20 | |||
21 | which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 10" | ||
22 | gnunet-arm -s -c test_credential_lookup.conf | ||
23 | |||
24 | gnunet-identity -C a -c test_credential_lookup.conf | ||
25 | gnunet-identity -C b -c test_credential_lookup.conf | ||
26 | gnunet-identity -C c -c test_credential_lookup.conf | ||
27 | gnunet-identity -C d -c test_credential_lookup.conf | ||
28 | gnunet-identity -C e -c test_credential_lookup.conf | ||
29 | gnunet-identity -C f -c test_credential_lookup.conf | ||
30 | gnunet-identity -C g -c test_credential_lookup.conf | ||
31 | AKEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep a | awk '{print $3}') | ||
32 | BKEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep b | awk '{print $3}') | ||
33 | CKEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep c | awk '{print $3}') | ||
34 | DKEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep d | awk '{print $3}') | ||
35 | EKEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep e | awk '{print $3}') | ||
36 | FKEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep f | awk '{print $3}') | ||
37 | GKEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep g | awk '{print $3}') | ||
38 | |||
39 | # (1) (A.a) <- B.b | ||
40 | # (2) (B.b) <- G.g.c | ||
41 | # (3) (G.g) <- C | ||
42 | # (3) C.c <- (D.D) | ||
43 | # (4) D.d <- (E.e) | ||
44 | # (5) E.e <- (F) | ||
45 | |||
46 | # BIDIRECTIONAL | ||
47 | gnunet-credential --createIssuerSide --ego=a --attribute="a" --subject="$BKEY b" --ttl=5m -c test_credential_lookup.conf | ||
48 | gnunet-namestore -D -z a | ||
49 | gnunet-credential --createIssuerSide --ego=b --attribute="b" --subject="$GKEY g.c" --ttl=5m -c test_credential_lookup.conf | ||
50 | gnunet-namestore -D -z b | ||
51 | gnunet-credential --createIssuerSide --ego=g --attribute="g" --subject="$CKEY" --ttl=5m -c test_credential_lookup.conf | ||
52 | gnunet-namestore -D -z b | ||
53 | |||
54 | SIGNED=`$DO_TIMEOUT gnunet-credential --signSubjectSide --ego=c --attribute="c" --subject="$DKEY d" --ttl="2019-12-12 10:00:00"` | ||
55 | gnunet-credential --createSubjectSide --ego=d --import "$SIGNED" | ||
56 | gnunet-namestore -D -z d | ||
57 | SIGNED=`$DO_TIMEOUT gnunet-credential --signSubjectSide --ego=d --attribute="d" --subject="$EKEY e" --ttl="2019-12-12 10:00:00"` | ||
58 | gnunet-credential --createSubjectSide --ego=e --import "$SIGNED" | ||
59 | gnunet-namestore -D -z e | ||
60 | SIGNED=`$DO_TIMEOUT gnunet-credential --signSubjectSide --ego=e --attribute="e" --subject="$FKEY" --ttl="2019-12-12 10:00:00"` | ||
61 | gnunet-credential --createSubjectSide --ego=f --import "$SIGNED" --private | ||
62 | gnunet-namestore -D -z f | ||
63 | |||
64 | # Starting to resolve | ||
65 | echo "+++ Starting to Resolve +++" | ||
66 | |||
67 | DELS=`$DO_TIMEOUT gnunet-credential --collect --issuer=$AKEY --attribute="a" --ego=f --forward --backward -c test_credential_lookup.conf | paste -d, -s` | ||
68 | echo $DELS | ||
69 | echo gnunet-credential --verify --issuer=$AKEY --attribute="a" --subject=$FKEY --delegate=\'$DELS\' --forward --backward -c test_credential_lookup.conf | ||
70 | RES_DELS=`gnunet-credential --verify --issuer=$AKEY --attribute="a" --subject=$FKEY --delegate="$DELS" --forward --backward -c test_credential_lookup.conf` | ||
71 | |||
72 | # Cleanup properly | ||
73 | gnunet-namestore -z epub -d -n $DISC_ATTR -t ATTR -c test_credential_lookup.conf | ||
74 | gnunet-namestore -z eorg -d -n $PREF_ATTR -t ATTR -c test_credential_lookup.conf | ||
75 | gnunet-namestore -z stateu -d -n $STATE_STUD_ATTR -t ATTR -c test_credential_lookup.conf | ||
76 | #gnunet-namestore -z a -d -n $STATE_STUD_ATTR -t ATTR -c test_credential_lookup.conf | ||
77 | #gnunet-namestore -z d -d -n $STATE_STUD_ATTR -t ATTR -c test_credential_lookup.conf | ||
78 | #gnunet-namestore -z e -d -n $STATE_STUD_ATTR -t ATTR -c test_credential_lookup.conf | ||
79 | #gnunet-namestore -z f -d -n $STATE_STUD_ATTR -t ATTR -c test_credential_lookup.conf | ||
80 | #gnunet-namestore -z g -d -n $STATE_STUD_ATTR -t ATTR -c test_credential_lookup.conf | ||
81 | |||
82 | gnunet-arm -e -c test_credential_lookup.conf | ||
83 | |||
84 | if [ "$RES_DELS" != "Failed." ] | ||
85 | then | ||
86 | # TODO: replace echo -e bashism | ||
87 | echo -e "${RES_DELS}" | ||
88 | exit 0 | ||
89 | else | ||
90 | echo "FAIL: Failed to verify credential $RES_DELS." | ||
91 | exit 1 | ||
92 | fi | ||
93 | |||
diff --git a/src/credential/test_credential_bi_bw_link2.sh b/src/credential/test_credential_bi_bw_link2.sh new file mode 100755 index 000000000..46a04a26e --- /dev/null +++ b/src/credential/test_credential_bi_bw_link2.sh | |||
@@ -0,0 +1,94 @@ | |||
1 | #!/usr/bin/env bash | ||
2 | trap "gnunet-arm -e -c test_credential_lookup.conf" SIGINT | ||
3 | |||
4 | LOCATION=$(which gnunet-config) | ||
5 | if [ -z $LOCATION ] | ||
6 | then | ||
7 | LOCATION="gnunet-config" | ||
8 | fi | ||
9 | $LOCATION --version 1> /dev/null | ||
10 | if test $? != 0 | ||
11 | then | ||
12 | echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX" | ||
13 | exit 77 | ||
14 | fi | ||
15 | |||
16 | rm -rf `gnunet-config -c test_credential_lookup.conf -s PATHS -o GNUNET_HOME -f` | ||
17 | |||
18 | |||
19 | |||
20 | |||
21 | which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 10" | ||
22 | gnunet-arm -s -c test_credential_lookup.conf | ||
23 | |||
24 | gnunet-identity -C a -c test_credential_lookup.conf | ||
25 | gnunet-identity -C b -c test_credential_lookup.conf | ||
26 | gnunet-identity -C c -c test_credential_lookup.conf | ||
27 | gnunet-identity -C d -c test_credential_lookup.conf | ||
28 | gnunet-identity -C e -c test_credential_lookup.conf | ||
29 | gnunet-identity -C f -c test_credential_lookup.conf | ||
30 | gnunet-identity -C g -c test_credential_lookup.conf | ||
31 | AKEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep a | awk '{print $3}') | ||
32 | BKEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep b | awk '{print $3}') | ||
33 | CKEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep c | awk '{print $3}') | ||
34 | DKEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep d | awk '{print $3}') | ||
35 | EKEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep e | awk '{print $3}') | ||
36 | FKEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep f | awk '{print $3}') | ||
37 | GKEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep g | awk '{print $3}') | ||
38 | |||
39 | # (1) (A.a) <- B.b | ||
40 | # (2) (B.b) <- G.g.c | ||
41 | # (3) G.g <- (C) | ||
42 | # (3) C.c <- (D.d) | ||
43 | # (4) D.d <- (E.e) | ||
44 | # (5) E.e <- (F) | ||
45 | |||
46 | # BIDIRECTIONAL | ||
47 | gnunet-credential --createIssuerSide --ego=a --attribute="a" --subject="$BKEY b" --ttl=5m -c test_credential_lookup.conf | ||
48 | gnunet-namestore -D -z a | ||
49 | gnunet-credential --createIssuerSide --ego=b --attribute="b" --subject="$GKEY g.c" --ttl=5m -c test_credential_lookup.conf | ||
50 | gnunet-namestore -D -z b | ||
51 | |||
52 | SIGNED=`$DO_TIMEOUT gnunet-credential --signSubjectSide --ego=g --attribute="g" --subject="$CKEY" --ttl="2019-12-12 10:00:00"` | ||
53 | gnunet-credential --createSubjectSide --ego=c --import "$SIGNED" | ||
54 | gnunet-namestore -D -z c | ||
55 | SIGNED=`$DO_TIMEOUT gnunet-credential --signSubjectSide --ego=c --attribute="c" --subject="$DKEY d" --ttl="2019-12-12 10:00:00"` | ||
56 | gnunet-credential --createSubjectSide --ego=d --import "$SIGNED" | ||
57 | gnunet-namestore -D -z d | ||
58 | SIGNED=`$DO_TIMEOUT gnunet-credential --signSubjectSide --ego=d --attribute="d" --subject="$EKEY e" --ttl="2019-12-12 10:00:00"` | ||
59 | gnunet-credential --createSubjectSide --ego=e --import "$SIGNED" | ||
60 | gnunet-namestore -D -z e | ||
61 | SIGNED=`$DO_TIMEOUT gnunet-credential --signSubjectSide --ego=e --attribute="e" --subject="$FKEY" --ttl="2019-12-12 10:00:00"` | ||
62 | gnunet-credential --createSubjectSide --ego=f --import "$SIGNED" --private | ||
63 | gnunet-namestore -D -z f | ||
64 | |||
65 | # Starting to resolve | ||
66 | echo "+++ Starting to Resolve +++" | ||
67 | |||
68 | DELS=`$DO_TIMEOUT gnunet-credential --collect --issuer=$AKEY --attribute="a" --ego=f --forward --backward -c test_credential_lookup.conf | paste -d, -s` | ||
69 | echo $DELS | ||
70 | echo gnunet-credential --verify --issuer=$AKEY --attribute="a" --subject=$FKEY --delegate=\'$DELS\' --forward --backward -c test_credential_lookup.conf | ||
71 | RES_DELS=`gnunet-credential --verify --issuer=$AKEY --attribute="a" --subject=$FKEY --delegate="$DELS" --forward --backward -c test_credential_lookup.conf` | ||
72 | |||
73 | # Cleanup properly | ||
74 | gnunet-namestore -z epub -d -n $DISC_ATTR -t ATTR -c test_credential_lookup.conf | ||
75 | gnunet-namestore -z eorg -d -n $PREF_ATTR -t ATTR -c test_credential_lookup.conf | ||
76 | gnunet-namestore -z stateu -d -n $STATE_STUD_ATTR -t ATTR -c test_credential_lookup.conf | ||
77 | #gnunet-namestore -z a -d -n $STATE_STUD_ATTR -t ATTR -c test_credential_lookup.conf | ||
78 | #gnunet-namestore -z d -d -n $STATE_STUD_ATTR -t ATTR -c test_credential_lookup.conf | ||
79 | #gnunet-namestore -z e -d -n $STATE_STUD_ATTR -t ATTR -c test_credential_lookup.conf | ||
80 | #gnunet-namestore -z f -d -n $STATE_STUD_ATTR -t ATTR -c test_credential_lookup.conf | ||
81 | #gnunet-namestore -z g -d -n $STATE_STUD_ATTR -t ATTR -c test_credential_lookup.conf | ||
82 | |||
83 | gnunet-arm -e -c test_credential_lookup.conf | ||
84 | |||
85 | if [ "$RES_DELS" != "Failed." ] | ||
86 | then | ||
87 | # TODO: replace echo -e bashism | ||
88 | echo -e "${RES_DELS}" | ||
89 | exit 0 | ||
90 | else | ||
91 | echo "FAIL: Failed to verify credential $RES_DELS." | ||
92 | exit 1 | ||
93 | fi | ||
94 | |||
diff --git a/src/credential/test_credential_bi_fw.sh b/src/credential/test_credential_bi_fw.sh new file mode 100755 index 000000000..5df73a4fd --- /dev/null +++ b/src/credential/test_credential_bi_fw.sh | |||
@@ -0,0 +1,95 @@ | |||
1 | #!/usr/bin/env bash | ||
2 | trap "gnunet-arm -e -c test_credential_lookup.conf" SIGINT | ||
3 | |||
4 | LOCATION=$(which gnunet-config) | ||
5 | if [ -z $LOCATION ] | ||
6 | then | ||
7 | LOCATION="gnunet-config" | ||
8 | fi | ||
9 | $LOCATION --version 1> /dev/null | ||
10 | if test $? != 0 | ||
11 | then | ||
12 | echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX" | ||
13 | exit 77 | ||
14 | fi | ||
15 | |||
16 | rm -rf `gnunet-config -c test_credential_lookup.conf -s PATHS -o GNUNET_HOME -f` | ||
17 | |||
18 | |||
19 | |||
20 | |||
21 | which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 10" | ||
22 | gnunet-arm -s -c test_credential_lookup.conf | ||
23 | |||
24 | gnunet-identity -C a -c test_credential_lookup.conf | ||
25 | gnunet-identity -C b -c test_credential_lookup.conf | ||
26 | gnunet-identity -C c -c test_credential_lookup.conf | ||
27 | gnunet-identity -C d -c test_credential_lookup.conf | ||
28 | gnunet-identity -C e -c test_credential_lookup.conf | ||
29 | gnunet-identity -C f -c test_credential_lookup.conf | ||
30 | gnunet-identity -C g -c test_credential_lookup.conf | ||
31 | AKEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep a | awk '{print $3}') | ||
32 | BKEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep b | awk '{print $3}') | ||
33 | CKEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep c | awk '{print $3}') | ||
34 | DKEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep d | awk '{print $3}') | ||
35 | EKEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep e | awk '{print $3}') | ||
36 | FKEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep f | awk '{print $3}') | ||
37 | GKEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep g | awk '{print $3}') | ||
38 | |||
39 | # (1) (A.a) <- B.b | ||
40 | # (2) (B.b) <- C.c | ||
41 | # (3) C.c <- (D.D) | ||
42 | # (4) D.d <- (E.e) | ||
43 | # (5) E.e <- (F.f) | ||
44 | # (6) F.f <- (G) | ||
45 | |||
46 | # BIDIRECTIONAL | ||
47 | gnunet-credential --createIssuerSide --ego=a --attribute="a" --subject="$BKEY b" --ttl=5m -c test_credential_lookup.conf | ||
48 | gnunet-namestore -D -z a | ||
49 | gnunet-credential --createIssuerSide --ego=b --attribute="b" --subject="$CKEY c" --ttl=5m -c test_credential_lookup.conf | ||
50 | gnunet-namestore -D -z b | ||
51 | |||
52 | SIGNED=`$DO_TIMEOUT gnunet-credential --signSubjectSide --ego=c --attribute="c" --subject="$DKEY d" --ttl="2019-12-12 10:00:00"` | ||
53 | gnunet-credential --createSubjectSide --ego=d --import "$SIGNED" | ||
54 | gnunet-namestore -D -z d | ||
55 | SIGNED=`$DO_TIMEOUT gnunet-credential --signSubjectSide --ego=d --attribute="d" --subject="$EKEY e" --ttl="2019-12-12 10:00:00"` | ||
56 | gnunet-credential --createSubjectSide --ego=e --import "$SIGNED" | ||
57 | gnunet-namestore -D -z e | ||
58 | SIGNED=`$DO_TIMEOUT gnunet-credential --signSubjectSide --ego=e --attribute="e" --subject="$FKEY f" --ttl="2019-12-12 10:00:00"` | ||
59 | gnunet-credential --createSubjectSide --ego=f --import "$SIGNED" | ||
60 | gnunet-namestore -D -z f | ||
61 | SIGNED=`$DO_TIMEOUT gnunet-credential --signSubjectSide --ego=f --attribute="f" --subject="$GKEY" --ttl="2019-12-12 10:00:00"` | ||
62 | gnunet-credential --createSubjectSide --ego=g --import "$SIGNED" --private | ||
63 | gnunet-namestore -D -z g | ||
64 | |||
65 | # Starting to resolve | ||
66 | echo "+++ Starting to Resolve +++" | ||
67 | |||
68 | DELS=`$DO_TIMEOUT gnunet-credential --collect --issuer=$AKEY --attribute="a" --ego=g --forward --backward -c test_credential_lookup.conf | paste -d, -s` | ||
69 | echo $DELS | ||
70 | echo gnunet-credential --verify --issuer=$AKEY --attribute="a" --subject=$GKEY --delegate=\'$DELS\' --forward --backward -c test_credential_lookup.conf | ||
71 | RES_DELS=`gnunet-credential --verify --issuer=$AKEY --attribute="a" --subject=$GKEY --delegate="$DELS" --forward --backward -c test_credential_lookup.conf` | ||
72 | |||
73 | # Cleanup properly | ||
74 | gnunet-namestore -z a -d -n "@"-t DELE -c test_credential_lookup.conf | ||
75 | gnunet-namestore -z epub -d -n $DISC_ATTR -t ATTR -c test_credential_lookup.conf | ||
76 | gnunet-namestore -z eorg -d -n $PREF_ATTR -t ATTR -c test_credential_lookup.conf | ||
77 | gnunet-namestore -z stateu -d -n $STATE_STUD_ATTR -t ATTR -c test_credential_lookup.conf | ||
78 | #gnunet-namestore -z a -d -n $STATE_STUD_ATTR -t ATTR -c test_credential_lookup.conf | ||
79 | #gnunet-namestore -z d -d -n $STATE_STUD_ATTR -t ATTR -c test_credential_lookup.conf | ||
80 | #gnunet-namestore -z e -d -n $STATE_STUD_ATTR -t ATTR -c test_credential_lookup.conf | ||
81 | #gnunet-namestore -z f -d -n $STATE_STUD_ATTR -t ATTR -c test_credential_lookup.conf | ||
82 | #gnunet-namestore -z g -d -n $STATE_STUD_ATTR -t ATTR -c test_credential_lookup.conf | ||
83 | |||
84 | gnunet-arm -e -c test_credential_lookup.conf | ||
85 | |||
86 | if [ "$RES_DELS" != "Failed." ] | ||
87 | then | ||
88 | # TODO: replace echo -e bashism | ||
89 | echo -e "${RES_DELS}" | ||
90 | exit 0 | ||
91 | else | ||
92 | echo "FAIL: Failed to verify credential $RES_DELS." | ||
93 | exit 1 | ||
94 | fi | ||
95 | |||
diff --git a/src/credential/test_credential_own_and2.sh b/src/credential/test_credential_own_and2.sh new file mode 100755 index 000000000..bbce251ec --- /dev/null +++ b/src/credential/test_credential_own_and2.sh | |||
@@ -0,0 +1,88 @@ | |||
1 | #!/usr/bin/env bash | ||
2 | trap "gnunet-arm -e -c test_credential_lookup.conf" SIGINT | ||
3 | |||
4 | LOCATION=$(which gnunet-config) | ||
5 | if [ -z $LOCATION ] | ||
6 | then | ||
7 | LOCATION="gnunet-config" | ||
8 | fi | ||
9 | $LOCATION --version 1> /dev/null | ||
10 | if test $? != 0 | ||
11 | then | ||
12 | echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX" | ||
13 | exit 77 | ||
14 | fi | ||
15 | |||
16 | rm -rf `gnunet-config -c test_credential_lookup.conf -s PATHS -o GNUNET_HOME -f` | ||
17 | |||
18 | |||
19 | |||
20 | |||
21 | which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 10" | ||
22 | gnunet-arm -s -c test_credential_lookup.conf | ||
23 | |||
24 | gnunet-identity -C a -c test_credential_lookup.conf | ||
25 | gnunet-identity -C b -c test_credential_lookup.conf | ||
26 | gnunet-identity -C c -c test_credential_lookup.conf | ||
27 | gnunet-identity -C d -c test_credential_lookup.conf | ||
28 | gnunet-identity -C e -c test_credential_lookup.conf | ||
29 | gnunet-identity -C f -c test_credential_lookup.conf | ||
30 | gnunet-identity -C g -c test_credential_lookup.conf | ||
31 | gnunet-identity -C h -c test_credential_lookup.conf | ||
32 | AKEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep a | awk '{print $3}') | ||
33 | BKEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep b | awk '{print $3}') | ||
34 | CKEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep c | awk '{print $3}') | ||
35 | DKEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep d | awk '{print $3}') | ||
36 | EKEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep e | awk '{print $3}') | ||
37 | FKEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep f | awk '{print $3}') | ||
38 | GKEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep g | awk '{print $3}') | ||
39 | HKEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep h | awk '{print $3}') | ||
40 | |||
41 | # (1) (A.a) <- B.b | ||
42 | # (2) (B.b) <- C.c AND G.g | ||
43 | # (3) C.c <- (F) priv | ||
44 | # (4) G.g <- (F) priv | ||
45 | |||
46 | # BIDIRECTIONAL | ||
47 | gnunet-credential --createIssuerSide --ego=a --attribute="a" --subject="$BKEY b" --ttl=5m -c test_credential_lookup.conf | ||
48 | gnunet-namestore -D -z a | ||
49 | gnunet-credential --createIssuerSide --ego=b --attribute="b" --subject="$CKEY c, $GKEY g" --ttl=5m -c test_credential_lookup.conf | ||
50 | gnunet-namestore -D -z b | ||
51 | |||
52 | SIGNED=`$DO_TIMEOUT gnunet-credential --signSubjectSide --ego=g --attribute="g" --subject="$FKEY" --ttl="2019-12-12 10:00:00"` | ||
53 | gnunet-credential --createSubjectSide --ego=f --import "$SIGNED" --private | ||
54 | gnunet-namestore -D -z h | ||
55 | SIGNED=`$DO_TIMEOUT gnunet-credential --signSubjectSide --ego=c --attribute="c" --subject="$FKEY" --ttl="2019-12-12 10:00:00"` | ||
56 | gnunet-credential --createSubjectSide --ego=f --import "$SIGNED" --private | ||
57 | gnunet-namestore -D -z f | ||
58 | |||
59 | # Starting to resolve | ||
60 | echo "+++ Starting to Resolve +++" | ||
61 | |||
62 | DELS=`$DO_TIMEOUT gnunet-credential --collect --issuer=$AKEY --attribute="a" --ego=f --backward -c test_credential_lookup.conf | paste -d, -s` | ||
63 | echo $DELS | ||
64 | echo gnunet-credential --verify --issuer=$AKEY --attribute="a" --subject=$FKEY --delegate=\'$DELS\' --backward -c test_credential_lookup.conf | ||
65 | RES_DELS=`gnunet-credential --verify --issuer=$AKEY --attribute="a" --subject=$FKEY --delegate="$DELS" --backward -c test_credential_lookup.conf` | ||
66 | |||
67 | # Cleanup properly | ||
68 | gnunet-namestore -z epub -d -n $DISC_ATTR -t ATTR -c test_credential_lookup.conf | ||
69 | gnunet-namestore -z eorg -d -n $PREF_ATTR -t ATTR -c test_credential_lookup.conf | ||
70 | gnunet-namestore -z stateu -d -n $STATE_STUD_ATTR -t ATTR -c test_credential_lookup.conf | ||
71 | #gnunet-namestore -z a -d -n $STATE_STUD_ATTR -t ATTR -c test_credential_lookup.conf | ||
72 | #gnunet-namestore -z d -d -n $STATE_STUD_ATTR -t ATTR -c test_credential_lookup.conf | ||
73 | #gnunet-namestore -z e -d -n $STATE_STUD_ATTR -t ATTR -c test_credential_lookup.conf | ||
74 | #gnunet-namestore -z f -d -n $STATE_STUD_ATTR -t ATTR -c test_credential_lookup.conf | ||
75 | #gnunet-namestore -z g -d -n $STATE_STUD_ATTR -t ATTR -c test_credential_lookup.conf | ||
76 | |||
77 | gnunet-arm -e -c test_credential_lookup.conf | ||
78 | |||
79 | if [ "$RES_DELS" != "Failed." ] | ||
80 | then | ||
81 | # TODO: replace echo -e bashism | ||
82 | echo -e "${RES_DELS}" | ||
83 | exit 0 | ||
84 | else | ||
85 | echo "FAIL: Failed to verify credential $RES_DELS." | ||
86 | exit 1 | ||
87 | fi | ||
88 | |||