diff options
author | Martin Schanzenbach <mschanzenbach@posteo.de> | 2016-01-09 17:09:37 +0000 |
---|---|---|
committer | Martin Schanzenbach <mschanzenbach@posteo.de> | 2016-01-09 17:09:37 +0000 |
commit | 3941d4252602eb9e6689897a8264380012fdf7e6 (patch) | |
tree | 1c080b9cefc132bb728a92b4ff02a72c511f9f4c /src/identity-provider/gnunet-service-identity-provider.c | |
parent | 8feaa39e16ba33a192b32097e8087c9aca2d27d8 (diff) | |
download | gnunet-3941d4252602eb9e6689897a8264380012fdf7e6.tar.gz gnunet-3941d4252602eb9e6689897a8264380012fdf7e6.zip |
- fix build, fix bugs
Diffstat (limited to 'src/identity-provider/gnunet-service-identity-provider.c')
-rw-r--r-- | src/identity-provider/gnunet-service-identity-provider.c | 61 |
1 files changed, 46 insertions, 15 deletions
diff --git a/src/identity-provider/gnunet-service-identity-provider.c b/src/identity-provider/gnunet-service-identity-provider.c index 85471e657..2e914428e 100644 --- a/src/identity-provider/gnunet-service-identity-provider.c +++ b/src/identity-provider/gnunet-service-identity-provider.c | |||
@@ -535,8 +535,9 @@ token_collect (void *cls, | |||
535 | &clear_ego_attrs, | 535 | &clear_ego_attrs, |
536 | ego_entry); | 536 | ego_entry); |
537 | GNUNET_CONTAINER_multihashmap_clear (ego_entry->attr_map); | 537 | GNUNET_CONTAINER_multihashmap_clear (ego_entry->attr_map); |
538 | GNUNET_SCHEDULER_add_now (&update_identities, ego_entry->next); | 538 | update_task = GNUNET_SCHEDULER_add_now (&update_identities, |
539 | return; | 539 | ego_entry->next); |
540 | return; | ||
540 | } | 541 | } |
541 | 542 | ||
542 | //There should be only a single record for a token under a label | 543 | //There should be only a single record for a token under a label |
@@ -554,8 +555,16 @@ token_collect (void *cls, | |||
554 | token_record = &rd[0]; | 555 | token_record = &rd[0]; |
555 | token_metadata_record = &rd[1]; | 556 | token_metadata_record = &rd[1]; |
556 | } | 557 | } |
557 | GNUNET_assert (token_metadata_record->record_type == GNUNET_GNSRECORD_TYPE_ID_TOKEN_METADATA); | 558 | if (token_metadata_record->record_type != GNUNET_GNSRECORD_TYPE_ID_TOKEN_METADATA) |
558 | GNUNET_assert (token_record->record_type == GNUNET_GNSRECORD_TYPE_ID_TOKEN); | 559 | { |
560 | GNUNET_NAMESTORE_zone_iterator_next (ns_it); | ||
561 | return; | ||
562 | } | ||
563 | if (token_record->record_type == GNUNET_GNSRECORD_TYPE_ID_TOKEN) | ||
564 | { | ||
565 | GNUNET_NAMESTORE_zone_iterator_next (ns_it); | ||
566 | return; | ||
567 | } | ||
559 | 568 | ||
560 | //Get metadata and decrypt token | 569 | //Get metadata and decrypt token |
561 | ecdhe_privkey = *((struct GNUNET_CRYPTO_EcdhePrivateKey *)token_metadata_record->data); | 570 | ecdhe_privkey = *((struct GNUNET_CRYPTO_EcdhePrivateKey *)token_metadata_record->data); |
@@ -607,7 +616,7 @@ attribute_collect (void *cls, | |||
607 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 616 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
608 | ">>> Updating Attributes finished\n"); | 617 | ">>> Updating Attributes finished\n"); |
609 | ego_entry->attributes_dirty = GNUNET_NO; | 618 | ego_entry->attributes_dirty = GNUNET_NO; |
610 | GNUNET_SCHEDULER_add_now (&update_identities, ego_entry); | 619 | update_task = GNUNET_SCHEDULER_add_now (&update_identities, ego_entry); |
611 | return; | 620 | return; |
612 | } | 621 | } |
613 | 622 | ||
@@ -674,6 +683,7 @@ update_identities(void *cls, | |||
674 | { | 683 | { |
675 | struct EgoEntry *next_ego = cls; | 684 | struct EgoEntry *next_ego = cls; |
676 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv_key; | 685 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv_key; |
686 | update_task = NULL; | ||
677 | if (NULL == next_ego) | 687 | if (NULL == next_ego) |
678 | { | 688 | { |
679 | if (min_rel_exp.rel_value_us < MIN_WAIT_TIME.rel_value_us) | 689 | if (min_rel_exp.rel_value_us < MIN_WAIT_TIME.rel_value_us) |
@@ -885,9 +895,14 @@ store_token_issue_cont (void *cls, | |||
885 | handle->client, | 895 | handle->client, |
886 | &irm->header, | 896 | &irm->header, |
887 | GNUNET_NO); | 897 | GNUNET_NO); |
898 | GNUNET_SERVER_client_set_user_context (handle->client, NULL); | ||
899 | GNUNET_CONTAINER_multihashmap_destroy (handle->attr_map); | ||
900 | GNUNET_free (handle->scopes); | ||
901 | token_destroy (handle->token); | ||
902 | ticket_destroy (handle->ticket); | ||
903 | GNUNET_free (handle); | ||
888 | GNUNET_free (irm); | 904 | GNUNET_free (irm); |
889 | GNUNET_free (token_ticket_str); | 905 | GNUNET_free (token_ticket_str); |
890 | GNUNET_SERVER_receive_done (handle->client, GNUNET_OK); | ||
891 | } | 906 | } |
892 | 907 | ||
893 | /** | 908 | /** |
@@ -904,7 +919,6 @@ sign_and_return_token (void *cls, | |||
904 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 919 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
905 | { | 920 | { |
906 | struct GNUNET_CRYPTO_EcdsaPublicKey pub_key; | 921 | struct GNUNET_CRYPTO_EcdsaPublicKey pub_key; |
907 | struct GNUNET_CRYPTO_EcdsaPublicKey aud_pkey; | ||
908 | struct GNUNET_CRYPTO_EcdhePrivateKey *ecdhe_privkey; | 922 | struct GNUNET_CRYPTO_EcdhePrivateKey *ecdhe_privkey; |
909 | struct IssueHandle *handle = cls; | 923 | struct IssueHandle *handle = cls; |
910 | struct GNUNET_GNSRECORD_Data token_record[2]; | 924 | struct GNUNET_GNSRECORD_Data token_record[2]; |
@@ -925,16 +939,18 @@ sign_and_return_token (void *cls, | |||
925 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Request nonce: %s\n", nonce_str); | 939 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Request nonce: %s\n", nonce_str); |
926 | 940 | ||
927 | //Label | 941 | //Label |
928 | rnd_key = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_STRONG, UINT64_MAX); | 942 | rnd_key = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_STRONG, |
929 | GNUNET_STRINGS_base64_encode ((char*)&rnd_key, sizeof (uint64_t), &lbl_str); | 943 | UINT64_MAX); |
944 | GNUNET_STRINGS_base64_encode ((char*)&rnd_key, | ||
945 | sizeof (uint64_t), | ||
946 | &lbl_str); | ||
930 | GNUNET_CRYPTO_ecdsa_key_get_public (&handle->iss_key, | 947 | GNUNET_CRYPTO_ecdsa_key_get_public (&handle->iss_key, |
931 | &pub_key); | 948 | &pub_key); |
932 | 949 | ||
933 | handle->ticket = ticket_create (nonce_str, | 950 | handle->ticket = ticket_create (nonce_str, |
934 | &pub_key, | 951 | &pub_key, |
935 | lbl_str, | 952 | lbl_str, |
936 | &aud_pkey); | 953 | &handle->aud_key); |
937 | |||
938 | 954 | ||
939 | 955 | ||
940 | if (GNUNET_OK != | 956 | if (GNUNET_OK != |
@@ -994,10 +1010,12 @@ sign_and_return_token (void *cls, | |||
994 | lbl_str, | 1010 | lbl_str, |
995 | 2, | 1011 | 2, |
996 | token_record, | 1012 | token_record, |
997 | &store_token_issue_cont, | 1013 | &store_token_issue_cont, |
998 | handle); | 1014 | handle); |
999 | GNUNET_free (lbl_str); | 1015 | GNUNET_free (lbl_str); |
1016 | GNUNET_free (nonce_str); | ||
1000 | GNUNET_free (enc_token_str); | 1017 | GNUNET_free (enc_token_str); |
1018 | GNUNET_free (token_metadata); | ||
1001 | } | 1019 | } |
1002 | 1020 | ||
1003 | /** | 1021 | /** |
@@ -1123,8 +1141,13 @@ process_lookup_result (void *cls, uint32_t rd_count, | |||
1123 | handle->client, | 1141 | handle->client, |
1124 | &erm->header, | 1142 | &erm->header, |
1125 | GNUNET_NO); | 1143 | GNUNET_NO); |
1144 | GNUNET_SERVER_client_set_user_context (handle->client, NULL); | ||
1145 | ticket_destroy (handle->ticket); | ||
1146 | token_destroy (handle->token); | ||
1147 | GNUNET_free (record_str); | ||
1148 | GNUNET_free (token_str); | ||
1149 | GNUNET_free (handle); | ||
1126 | GNUNET_free (erm); | 1150 | GNUNET_free (erm); |
1127 | GNUNET_SERVER_receive_done (handle->client, GNUNET_OK); | ||
1128 | 1151 | ||
1129 | } | 1152 | } |
1130 | 1153 | ||
@@ -1161,12 +1184,12 @@ handle_exchange_message (void *cls, | |||
1161 | ticket); | 1184 | ticket); |
1162 | xchange_handle = GNUNET_malloc (sizeof (struct ExchangeHandle)); | 1185 | xchange_handle = GNUNET_malloc (sizeof (struct ExchangeHandle)); |
1163 | xchange_handle->aud_privkey = em->aud_privkey; | 1186 | xchange_handle->aud_privkey = em->aud_privkey; |
1187 | |||
1164 | if (GNUNET_SYSERR == ticket_parse (ticket, | 1188 | if (GNUNET_SYSERR == ticket_parse (ticket, |
1165 | &xchange_handle->aud_privkey, | 1189 | &xchange_handle->aud_privkey, |
1166 | &xchange_handle->ticket)) | 1190 | &xchange_handle->ticket)) |
1167 | { | 1191 | { |
1168 | GNUNET_free (xchange_handle); | 1192 | GNUNET_free (xchange_handle); |
1169 | GNUNET_break (0); | ||
1170 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 1193 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); |
1171 | return; | 1194 | return; |
1172 | } | 1195 | } |
@@ -1175,6 +1198,10 @@ handle_exchange_message (void *cls, | |||
1175 | GNUNET_asprintf (&lookup_query, | 1198 | GNUNET_asprintf (&lookup_query, |
1176 | "%s.gnu", | 1199 | "%s.gnu", |
1177 | xchange_handle->ticket->payload->label); | 1200 | xchange_handle->ticket->payload->label); |
1201 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | ||
1202 | GNUNET_SERVER_notification_context_add (nc, client); | ||
1203 | GNUNET_SERVER_client_set_user_context (client, xchange_handle); | ||
1204 | xchange_handle->client = client; | ||
1178 | xchange_handle->lookup_request = GNUNET_GNS_lookup (gns_handle, | 1205 | xchange_handle->lookup_request = GNUNET_GNS_lookup (gns_handle, |
1179 | lookup_query, | 1206 | lookup_query, |
1180 | &xchange_handle->ticket->payload->identity_key, | 1207 | &xchange_handle->ticket->payload->identity_key, |
@@ -1241,6 +1268,11 @@ handle_issue_message (void *cls, | |||
1241 | issue_handle->iss_key = im->iss_key; | 1268 | issue_handle->iss_key = im->iss_key; |
1242 | issue_handle->expiration = GNUNET_TIME_absolute_ntoh (im->expiration); | 1269 | issue_handle->expiration = GNUNET_TIME_absolute_ntoh (im->expiration); |
1243 | issue_handle->nonce = im->nonce; | 1270 | issue_handle->nonce = im->nonce; |
1271 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | ||
1272 | GNUNET_SERVER_notification_context_add (nc, client); | ||
1273 | GNUNET_SERVER_client_set_user_context (client, issue_handle); | ||
1274 | issue_handle->client = client; | ||
1275 | issue_handle->scopes = GNUNET_strdup (scopes); | ||
1244 | GNUNET_CRYPTO_ecdsa_key_get_public (&im->iss_key, | 1276 | GNUNET_CRYPTO_ecdsa_key_get_public (&im->iss_key, |
1245 | &issue_handle->iss_pkey); | 1277 | &issue_handle->iss_pkey); |
1246 | issue_handle->token = token_create (&issue_handle->iss_pkey, | 1278 | issue_handle->token = token_create (&issue_handle->iss_pkey, |
@@ -1250,7 +1282,6 @@ handle_issue_message (void *cls, | |||
1250 | &im->iss_key, | 1282 | &im->iss_key, |
1251 | &attr_collect, | 1283 | &attr_collect, |
1252 | issue_handle); | 1284 | issue_handle); |
1253 | GNUNET_SERVER_receive_done (client, GNUNET_OK); //TODO here? | ||
1254 | 1285 | ||
1255 | 1286 | ||
1256 | } | 1287 | } |