aboutsummaryrefslogtreecommitdiff
path: root/src/credential/gnunet-service-credential.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/credential/gnunet-service-credential.c')
-rw-r--r--src/credential/gnunet-service-credential.c66
1 files changed, 34 insertions, 32 deletions
diff --git a/src/credential/gnunet-service-credential.c b/src/credential/gnunet-service-credential.c
index 399371a2e..a6468c47e 100644
--- a/src/credential/gnunet-service-credential.c
+++ b/src/credential/gnunet-service-credential.c
@@ -2,20 +2,18 @@
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 Copyright (C) 2011-2013 GNUnet e.V. 3 Copyright (C) 2011-2013 GNUnet e.V.
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software: you can redistribute it and/or modify it
6 it under the terms of the GNU General Public License as published 6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation; either version 3, or (at your 7 by the Free Software Foundation, either version 3 of the License,
8 option) any later version. 8 or (at your option) any later version.
9 9
10 GNUnet is distributed in the hope that it will be useful, but 10 GNUnet is distributed in the hope that it will be useful, but
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 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 General Public License 15 You should have received a copy of the GNU Affero General Public License
16 along with GNUnet; see the file COPYING. If not, write to the 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19*/ 17*/
20/** 18/**
21 * @file credential/gnunet-service-credential.c 19 * @file credential/gnunet-service-credential.c
@@ -61,17 +59,17 @@ struct DelegationChainEntry
61 * The issuer 59 * The issuer
62 */ 60 */
63 struct GNUNET_CRYPTO_EcdsaPublicKey issuer_key; 61 struct GNUNET_CRYPTO_EcdsaPublicKey issuer_key;
64 62
65 /** 63 /**
66 * The subject 64 * The subject
67 */ 65 */
68 struct GNUNET_CRYPTO_EcdsaPublicKey subject_key; 66 struct GNUNET_CRYPTO_EcdsaPublicKey subject_key;
69 67
70 /** 68 /**
71 * The issued attribute 69 * The issued attribute
72 */ 70 */
73 char *issuer_attribute; 71 char *issuer_attribute;
74 72
75 /** 73 /**
76 * The delegated attribute 74 * The delegated attribute
77 */ 75 */
@@ -92,7 +90,7 @@ struct CredentialRecordEntry
92 * DLL 90 * DLL
93 */ 91 */
94 struct CredentialRecordEntry *prev; 92 struct CredentialRecordEntry *prev;
95 93
96 /** 94 /**
97 * Number of references in delegation chains 95 * Number of references in delegation chains
98 */ 96 */
@@ -409,7 +407,7 @@ cleanup_handle (struct VerifyRequestHandle *vrh)
409 } 407 }
410 cleanup_delegation_set (vrh->root_set); 408 cleanup_delegation_set (vrh->root_set);
411 GNUNET_free_non_null (vrh->issuer_attribute); 409 GNUNET_free_non_null (vrh->issuer_attribute);
412 for (cr_entry = vrh->cred_chain_head; 410 for (cr_entry = vrh->cred_chain_head;
413 NULL != vrh->cred_chain_head; 411 NULL != vrh->cred_chain_head;
414 cr_entry = vrh->cred_chain_head) 412 cr_entry = vrh->cred_chain_head)
415 { 413 {
@@ -543,7 +541,7 @@ send_lookup_response (struct VerifyRequestHandle *vrh)
543 else 541 else
544 rmsg->cred_found = htonl (GNUNET_NO); 542 rmsg->cred_found = htonl (GNUNET_NO);
545 543
546 GNUNET_assert (-1 != 544 GNUNET_assert (-1 !=
547 GNUNET_CREDENTIAL_delegation_chain_serialize (vrh->delegation_chain_size, 545 GNUNET_CREDENTIAL_delegation_chain_serialize (vrh->delegation_chain_size,
548 dd, 546 dd,
549 vrh->cred_chain_size, 547 vrh->cred_chain_size,
@@ -587,7 +585,7 @@ backward_resolution (void* cls,
587 "Got %d attrs\n", rd_count); 585 "Got %d attrs\n", rd_count);
588 586
589 // Each OR 587 // Each OR
590 for (uint32_t i=0; i < rd_count; i++) 588 for (uint32_t i=0; i < rd_count; i++)
591 { 589 {
592 if (GNUNET_GNSRECORD_TYPE_ATTRIBUTE != rd[i].record_type) 590 if (GNUNET_GNSRECORD_TYPE_ATTRIBUTE != rd[i].record_type)
593 continue; 591 continue;
@@ -665,10 +663,10 @@ backward_resolution (void* cls,
665 /** 663 /**
666 * Check if this delegation already matches one of our credentials 664 * Check if this delegation already matches one of our credentials
667 */ 665 */
668 for(cred_pointer = vrh->cred_chain_head; cred_pointer != NULL; 666 for(cred_pointer = vrh->cred_chain_head; cred_pointer != NULL;
669 cred_pointer = cred_pointer->next) 667 cred_pointer = cred_pointer->next)
670 { 668 {
671 if(0 != memcmp (&set->subject_key, 669 if(0 != memcmp (&set->subject_key,
672 &cred_pointer->credential->issuer_key, 670 &cred_pointer->credential->issuer_key,
673 sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey))) 671 sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey)))
674 continue; 672 continue;
@@ -769,7 +767,7 @@ backward_resolution (void* cls,
769 return; 767 return;
770 768
771 } 769 }
772} 770}
773 771
774 772
775/** 773/**
@@ -809,7 +807,7 @@ delegation_chain_resolution_start (void* cls)
809 } 807 }
810 808
811 /** 809 /**
812 * Check for attributes from the issuer and follow the chain 810 * Check for attributes from the issuer and follow the chain
813 * till you get the required subject's attributes 811 * till you get the required subject's attributes
814 */ 812 */
815 char issuer_attribute_name[strlen (vrh->issuer_attribute) + strlen (".gnu") + 1]; 813 char issuer_attribute_name[strlen (vrh->issuer_attribute) + strlen (".gnu") + 1];
@@ -821,9 +819,9 @@ delegation_chain_resolution_start (void* cls)
821 "Looking up %s\n", issuer_attribute_name); 819 "Looking up %s\n", issuer_attribute_name);
822 ds_entry = GNUNET_new (struct DelegationSetQueueEntry); 820 ds_entry = GNUNET_new (struct DelegationSetQueueEntry);
823 ds_entry->issuer_key = GNUNET_new (struct GNUNET_CRYPTO_EcdsaPublicKey); 821 ds_entry->issuer_key = GNUNET_new (struct GNUNET_CRYPTO_EcdsaPublicKey);
824 memcpy (ds_entry->issuer_key, 822 GNUNET_memcpy (ds_entry->issuer_key,
825 &vrh->issuer_key, 823 &vrh->issuer_key,
826 sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey)); 824 sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey));
827 ds_entry->issuer_attribute = GNUNET_strdup (vrh->issuer_attribute); 825 ds_entry->issuer_attribute = GNUNET_strdup (vrh->issuer_attribute);
828 ds_entry->handle = vrh; 826 ds_entry->handle = vrh;
829 ds_entry->lookup_attribute = GNUNET_strdup (vrh->issuer_attribute); 827 ds_entry->lookup_attribute = GNUNET_strdup (vrh->issuer_attribute);
@@ -869,7 +867,7 @@ check_verify (void *cls,
869 867
870static void 868static void
871handle_verify (void *cls, 869handle_verify (void *cls,
872 const struct VerifyMessage *v_msg) 870 const struct VerifyMessage *v_msg)
873{ 871{
874 struct VerifyRequestHandle *vrh; 872 struct VerifyRequestHandle *vrh;
875 struct GNUNET_SERVICE_Client *client = cls; 873 struct GNUNET_SERVICE_Client *client = cls;
@@ -886,7 +884,9 @@ handle_verify (void *cls,
886 "Received VERIFY message\n"); 884 "Received VERIFY message\n");
887 utf_in = (const char *) &v_msg[1]; 885 utf_in = (const char *) &v_msg[1];
888 GNUNET_STRINGS_utf8_tolower (utf_in, attrptr); 886 GNUNET_STRINGS_utf8_tolower (utf_in, attrptr);
889 GNUNET_memcpy (issuer_attribute, attr, ntohs (v_msg->issuer_attribute_len)); 887 GNUNET_memcpy (issuer_attribute,
888 attr,
889 ntohs (v_msg->issuer_attribute_len));
890 issuer_attribute[ntohs (v_msg->issuer_attribute_len)] = '\0'; 890 issuer_attribute[ntohs (v_msg->issuer_attribute_len)] = '\0';
891 vrh = GNUNET_new (struct VerifyRequestHandle); 891 vrh = GNUNET_new (struct VerifyRequestHandle);
892 GNUNET_CONTAINER_DLL_insert (vrh_head, vrh_tail, vrh); 892 GNUNET_CONTAINER_DLL_insert (vrh_head, vrh_tail, vrh);
@@ -897,7 +897,7 @@ handle_verify (void *cls,
897 vrh->issuer_attribute = GNUNET_strdup (issuer_attribute); 897 vrh->issuer_attribute = GNUNET_strdup (issuer_attribute);
898 if (0 == strlen (issuer_attribute)) 898 if (0 == strlen (issuer_attribute))
899 { 899 {
900 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 900 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
901 "No issuer attribute provided!\n"); 901 "No issuer attribute provided!\n");
902 send_lookup_response (vrh); 902 send_lookup_response (vrh);
903 return; 903 return;
@@ -907,7 +907,7 @@ handle_verify (void *cls,
907 * TODO: cleanup! 907 * TODO: cleanup!
908 */ 908 */
909 credentials_count = ntohl(v_msg->c_count); 909 credentials_count = ntohl(v_msg->c_count);
910 credential_data_size = ntohs (v_msg->header.size) 910 credential_data_size = ntohs (v_msg->header.size)
911 - sizeof (struct VerifyMessage) 911 - sizeof (struct VerifyMessage)
912 - ntohs (v_msg->issuer_attribute_len) 912 - ntohs (v_msg->issuer_attribute_len)
913 - 1; 913 - 1;
@@ -918,7 +918,7 @@ handle_verify (void *cls,
918 credentials_count, 918 credentials_count,
919 credentials)) 919 credentials))
920 { 920 {
921 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 921 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
922 "Cannot deserialize credentials!\n"); 922 "Cannot deserialize credentials!\n");
923 send_lookup_response (vrh); 923 send_lookup_response (vrh);
924 return; 924 return;
@@ -1015,7 +1015,7 @@ handle_cred_collection_finished_cb (void *cls)
1015 1015
1016static void 1016static void
1017handle_collect (void *cls, 1017handle_collect (void *cls,
1018 const struct CollectMessage *c_msg) 1018 const struct CollectMessage *c_msg)
1019{ 1019{
1020 char attr[GNUNET_CREDENTIAL_MAX_LENGTH + 1]; 1020 char attr[GNUNET_CREDENTIAL_MAX_LENGTH + 1];
1021 char issuer_attribute[GNUNET_CREDENTIAL_MAX_LENGTH + 1]; 1021 char issuer_attribute[GNUNET_CREDENTIAL_MAX_LENGTH + 1];
@@ -1030,7 +1030,9 @@ handle_collect (void *cls,
1030 utf_in = (const char *) &c_msg[1]; 1030 utf_in = (const char *) &c_msg[1];
1031 GNUNET_STRINGS_utf8_tolower (utf_in, attrptr); 1031 GNUNET_STRINGS_utf8_tolower (utf_in, attrptr);
1032 1032
1033 GNUNET_memcpy (issuer_attribute, attr, ntohs (c_msg->issuer_attribute_len)); 1033 GNUNET_memcpy (issuer_attribute,
1034 attr,
1035 ntohs (c_msg->issuer_attribute_len));
1034 issuer_attribute[ntohs (c_msg->issuer_attribute_len)] = '\0'; 1036 issuer_attribute[ntohs (c_msg->issuer_attribute_len)] = '\0';
1035 vrh = GNUNET_new (struct VerifyRequestHandle); 1037 vrh = GNUNET_new (struct VerifyRequestHandle);
1036 GNUNET_CONTAINER_DLL_insert (vrh_head, vrh_tail, vrh); 1038 GNUNET_CONTAINER_DLL_insert (vrh_head, vrh_tail, vrh);
@@ -1043,7 +1045,7 @@ handle_collect (void *cls,
1043 1045
1044 if (0 == strlen (issuer_attribute)) 1046 if (0 == strlen (issuer_attribute))
1045 { 1047 {
1046 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1048 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1047 "No issuer attribute provided!\n"); 1049 "No issuer attribute provided!\n");
1048 send_lookup_response (vrh); 1050 send_lookup_response (vrh);
1049 return; 1051 return;