diff options
Diffstat (limited to 'src/identity/gnunet-service-identity.c')
-rw-r--r-- | src/identity/gnunet-service-identity.c | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/src/identity/gnunet-service-identity.c b/src/identity/gnunet-service-identity.c index b509e7e9a..42ad94df1 100644 --- a/src/identity/gnunet-service-identity.c +++ b/src/identity/gnunet-service-identity.c | |||
@@ -57,7 +57,7 @@ struct Ego | |||
57 | /** | 57 | /** |
58 | * Private key of the ego. | 58 | * Private key of the ego. |
59 | */ | 59 | */ |
60 | struct GNUNET_CRYPTO_EcdsaPrivateKey *pk; | 60 | struct GNUNET_CRYPTO_EcdsaPrivateKey pk; |
61 | 61 | ||
62 | /** | 62 | /** |
63 | * String identifier for the ego. | 63 | * String identifier for the ego. |
@@ -190,7 +190,6 @@ shutdown_task (void *cls) | |||
190 | while (NULL != (e = ego_head)) | 190 | while (NULL != (e = ego_head)) |
191 | { | 191 | { |
192 | GNUNET_CONTAINER_DLL_remove (ego_head, ego_tail, e); | 192 | GNUNET_CONTAINER_DLL_remove (ego_head, ego_tail, e); |
193 | GNUNET_free (e->pk); | ||
194 | GNUNET_free (e->identifier); | 193 | GNUNET_free (e->identifier); |
195 | GNUNET_free (e); | 194 | GNUNET_free (e); |
196 | } | 195 | } |
@@ -247,7 +246,7 @@ create_update_message (struct Ego *ego) | |||
247 | env = GNUNET_MQ_msg_extra (um, name_len, GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE); | 246 | env = GNUNET_MQ_msg_extra (um, name_len, GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE); |
248 | um->name_len = htons (name_len); | 247 | um->name_len = htons (name_len); |
249 | um->end_of_list = htons (GNUNET_NO); | 248 | um->end_of_list = htons (GNUNET_NO); |
250 | um->private_key = *ego->pk; | 249 | um->private_key = ego->pk; |
251 | GNUNET_memcpy (&um[1], ego->identifier, name_len); | 250 | GNUNET_memcpy (&um[1], ego->identifier, name_len); |
252 | return env; | 251 | return env; |
253 | } | 252 | } |
@@ -273,7 +272,7 @@ create_set_default_message (struct Ego *ego, const char *servicename) | |||
273 | GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT); | 272 | GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT); |
274 | sdm->name_len = htons (name_len); | 273 | sdm->name_len = htons (name_len); |
275 | sdm->reserved = htons (0); | 274 | sdm->reserved = htons (0); |
276 | sdm->private_key = *ego->pk; | 275 | sdm->private_key = ego->pk; |
277 | GNUNET_memcpy (&sdm[1], servicename, name_len); | 276 | GNUNET_memcpy (&sdm[1], servicename, name_len); |
278 | return env; | 277 | return env; |
279 | } | 278 | } |
@@ -584,7 +583,8 @@ handle_set_default_message (void *cls, const struct SetDefaultMessage *sdm) | |||
584 | str); | 583 | str); |
585 | for (ego = ego_head; NULL != ego; ego = ego->next) | 584 | for (ego = ego_head; NULL != ego; ego = ego->next) |
586 | { | 585 | { |
587 | if (0 == key_cmp (ego->pk, &sdm->private_key)) | 586 | if (0 == key_cmp (&ego->pk, |
587 | &sdm->private_key)) | ||
588 | { | 588 | { |
589 | GNUNET_CONFIGURATION_set_value_string (subsystem_cfg, | 589 | GNUNET_CONFIGURATION_set_value_string (subsystem_cfg, |
590 | str, | 590 | str, |
@@ -627,7 +627,7 @@ notify_listeners (struct Ego *ego) | |||
627 | um->header.size = htons (sizeof(struct UpdateMessage) + name_len); | 627 | um->header.size = htons (sizeof(struct UpdateMessage) + name_len); |
628 | um->name_len = htons (name_len); | 628 | um->name_len = htons (name_len); |
629 | um->end_of_list = htons (GNUNET_NO); | 629 | um->end_of_list = htons (GNUNET_NO); |
630 | um->private_key = *ego->pk; | 630 | um->private_key = ego->pk; |
631 | GNUNET_memcpy (&um[1], ego->identifier, name_len); | 631 | GNUNET_memcpy (&um[1], ego->identifier, name_len); |
632 | GNUNET_notification_context_broadcast (nc, &um->header, GNUNET_NO); | 632 | GNUNET_notification_context_broadcast (nc, &um->header, GNUNET_NO); |
633 | GNUNET_free (um); | 633 | GNUNET_free (um); |
@@ -704,8 +704,7 @@ handle_create_message (void *cls, const struct CreateRequestMessage *crm) | |||
704 | } | 704 | } |
705 | } | 705 | } |
706 | ego = GNUNET_new (struct Ego); | 706 | ego = GNUNET_new (struct Ego); |
707 | ego->pk = GNUNET_new (struct GNUNET_CRYPTO_EcdsaPrivateKey); | 707 | ego->pk = crm->private_key; |
708 | *ego->pk = crm->private_key; | ||
709 | ego->identifier = GNUNET_strdup (str); | 708 | ego->identifier = GNUNET_strdup (str); |
710 | GNUNET_CONTAINER_DLL_insert (ego_head, ego_tail, ego); | 709 | GNUNET_CONTAINER_DLL_insert (ego_head, ego_tail, ego); |
711 | send_result_code (client, 0, NULL); | 710 | send_result_code (client, 0, NULL); |
@@ -997,7 +996,6 @@ handle_delete_message (void *cls, const struct DeleteMessage *dm) | |||
997 | GNUNET_free (ego->identifier); | 996 | GNUNET_free (ego->identifier); |
998 | ego->identifier = NULL; | 997 | ego->identifier = NULL; |
999 | notify_listeners (ego); | 998 | notify_listeners (ego); |
1000 | GNUNET_free (ego->pk); | ||
1001 | GNUNET_free (ego); | 999 | GNUNET_free (ego); |
1002 | GNUNET_free (name); | 1000 | GNUNET_free (name); |
1003 | send_result_code (client, 0, NULL); | 1001 | send_result_code (client, 0, NULL); |
@@ -1023,7 +1021,8 @@ handle_delete_message (void *cls, const struct DeleteMessage *dm) | |||
1023 | * #GNUNET_SYSERR to abort iteration with error! | 1021 | * #GNUNET_SYSERR to abort iteration with error! |
1024 | */ | 1022 | */ |
1025 | static int | 1023 | static int |
1026 | process_ego_file (void *cls, const char *filename) | 1024 | process_ego_file (void *cls, |
1025 | const char *filename) | ||
1027 | { | 1026 | { |
1028 | struct Ego *ego; | 1027 | struct Ego *ego; |
1029 | const char *fn; | 1028 | const char *fn; |
@@ -1035,8 +1034,10 @@ process_ego_file (void *cls, const char *filename) | |||
1035 | return GNUNET_OK; | 1034 | return GNUNET_OK; |
1036 | } | 1035 | } |
1037 | ego = GNUNET_new (struct Ego); | 1036 | ego = GNUNET_new (struct Ego); |
1038 | ego->pk = GNUNET_CRYPTO_ecdsa_key_create_from_file (filename); | 1037 | if (GNUNET_OK != |
1039 | if (NULL == ego->pk) | 1038 | GNUNET_CRYPTO_ecdsa_key_from_file (filename, |
1039 | GNUNET_NO, | ||
1040 | &ego->pk)) | ||
1040 | { | 1041 | { |
1041 | GNUNET_free (ego); | 1042 | GNUNET_free (ego); |
1042 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 1043 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
@@ -1044,7 +1045,9 @@ process_ego_file (void *cls, const char *filename) | |||
1044 | filename); | 1045 | filename); |
1045 | return GNUNET_OK; | 1046 | return GNUNET_OK; |
1046 | } | 1047 | } |
1047 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Loaded ego `%s'\n", fn + 1); | 1048 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1049 | "Loaded ego `%s'\n", | ||
1050 | fn + 1); | ||
1048 | ego->identifier = GNUNET_strdup (fn + 1); | 1051 | ego->identifier = GNUNET_strdup (fn + 1); |
1049 | GNUNET_CONTAINER_DLL_insert (ego_head, ego_tail, ego); | 1052 | GNUNET_CONTAINER_DLL_insert (ego_head, ego_tail, ego); |
1050 | return GNUNET_OK; | 1053 | return GNUNET_OK; |
@@ -1108,7 +1111,9 @@ run (void *cls, | |||
1108 | _ ("Failed to create directory `%s' for storing egos\n"), | 1111 | _ ("Failed to create directory `%s' for storing egos\n"), |
1109 | ego_directory); | 1112 | ego_directory); |
1110 | } | 1113 | } |
1111 | GNUNET_DISK_directory_scan (ego_directory, &process_ego_file, NULL); | 1114 | GNUNET_DISK_directory_scan (ego_directory, |
1115 | &process_ego_file, | ||
1116 | NULL); | ||
1112 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL); | 1117 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL); |
1113 | } | 1118 | } |
1114 | 1119 | ||