aboutsummaryrefslogtreecommitdiff
path: root/src/identity/identity_api.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2019-05-08 14:54:42 +0200
committerChristian Grothoff <christian@grothoff.org>2019-05-08 14:54:42 +0200
commit1b80ff9ee79b3fbe2028a8c22a01e45e9131cda2 (patch)
tree742185e47289bbed654eb641bf8f3d2409ee7976 /src/identity/identity_api.c
parentfba6afbd58e0b37b33850db4b1341dbf9392d1f3 (diff)
downloadgnunet-1b80ff9ee79b3fbe2028a8c22a01e45e9131cda2.tar.gz
gnunet-1b80ff9ee79b3fbe2028a8c22a01e45e9131cda2.zip
make generated ego key available in continuation when creating egos
Diffstat (limited to 'src/identity/identity_api.c')
-rw-r--r--src/identity/identity_api.c38
1 files changed, 33 insertions, 5 deletions
diff --git a/src/identity/identity_api.c b/src/identity/identity_api.c
index a058c5426..f16500ab5 100644
--- a/src/identity/identity_api.c
+++ b/src/identity/identity_api.c
@@ -88,13 +88,24 @@ struct GNUNET_IDENTITY_Operation
88 88
89 /** 89 /**
90 * Continuation to invoke with the result of the transmission; @e cb 90 * Continuation to invoke with the result of the transmission; @e cb
91 * will be NULL in this case. 91 * and @e create_cont will be NULL in this case.
92 */ 92 */
93 GNUNET_IDENTITY_Continuation cont; 93 GNUNET_IDENTITY_Continuation cont;
94 94
95 /** 95 /**
96 * Continuation to invoke with the result of the transmission; @e cb
97 * and @a cb will be NULL in this case.
98 */
99 GNUNET_IDENTITY_CreateContinuation create_cont;
100
101 /**
102 * Private key to return to @e create_cont, or NULL.
103 */
104 struct GNUNET_CRYPTO_EcdsaPrivateKey *pk;
105
106 /**
96 * Continuation to invoke with the result of the transmission for 107 * Continuation to invoke with the result of the transmission for
97 * 'get' operations (@e cont will be NULL in this case). 108 * 'get' operations (@e cont and @a create_cont will be NULL in this case).
98 */ 109 */
99 GNUNET_IDENTITY_Callback cb; 110 GNUNET_IDENTITY_Callback cb;
100 111
@@ -259,6 +270,11 @@ reschedule_connect (struct GNUNET_IDENTITY_Handle *h)
259 NULL, 270 NULL,
260 NULL, 271 NULL,
261 NULL); 272 NULL);
273 else if (NULL != op->create_cont)
274 op->create_cont (op->cls,
275 NULL,
276 "Failed to communicate with the identity service");
277 GNUNET_free_non_null (op->pk);
262 GNUNET_free (op); 278 GNUNET_free (op);
263 } 279 }
264 GNUNET_CONTAINER_multihashmap_iterate (h->egos, 280 GNUNET_CONTAINER_multihashmap_iterate (h->egos,
@@ -350,6 +366,11 @@ handle_identity_result_code (void *cls,
350 str); 366 str);
351 else if (NULL != op->cb) 367 else if (NULL != op->cb)
352 op->cb (op->cls, NULL, NULL, NULL); 368 op->cb (op->cls, NULL, NULL, NULL);
369 else if (NULL != op->create_cont)
370 op->create_cont (op->cls,
371 (NULL == str) ? op->pk : NULL,
372 str);
373 GNUNET_free_non_null (op->pk);
353 GNUNET_free (op); 374 GNUNET_free (op);
354} 375}
355 376
@@ -761,7 +782,7 @@ GNUNET_IDENTITY_set (struct GNUNET_IDENTITY_Handle *h,
761struct GNUNET_IDENTITY_Operation * 782struct GNUNET_IDENTITY_Operation *
762GNUNET_IDENTITY_create (struct GNUNET_IDENTITY_Handle *h, 783GNUNET_IDENTITY_create (struct GNUNET_IDENTITY_Handle *h,
763 const char *name, 784 const char *name,
764 GNUNET_IDENTITY_Continuation cont, 785 GNUNET_IDENTITY_CreateContinuation cont,
765 void *cont_cls) 786 void *cont_cls)
766{ 787{
767 struct GNUNET_IDENTITY_Operation *op; 788 struct GNUNET_IDENTITY_Operation *op;
@@ -780,7 +801,7 @@ GNUNET_IDENTITY_create (struct GNUNET_IDENTITY_Handle *h,
780 } 801 }
781 op = GNUNET_new (struct GNUNET_IDENTITY_Operation); 802 op = GNUNET_new (struct GNUNET_IDENTITY_Operation);
782 op->h = h; 803 op->h = h;
783 op->cont = cont; 804 op->create_cont = cont;
784 op->cls = cont_cls; 805 op->cls = cont_cls;
785 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, 806 GNUNET_CONTAINER_DLL_insert_tail (h->op_head,
786 h->op_tail, 807 h->op_tail,
@@ -792,7 +813,7 @@ GNUNET_IDENTITY_create (struct GNUNET_IDENTITY_Handle *h,
792 crm->reserved = htons (0); 813 crm->reserved = htons (0);
793 pk = GNUNET_CRYPTO_ecdsa_key_create (); 814 pk = GNUNET_CRYPTO_ecdsa_key_create ();
794 crm->private_key = *pk; 815 crm->private_key = *pk;
795 GNUNET_free (pk); 816 op->pk = pk;
796 GNUNET_memcpy (&crm[1], 817 GNUNET_memcpy (&crm[1],
797 name, 818 name,
798 slen); 819 slen);
@@ -924,6 +945,12 @@ GNUNET_IDENTITY_cancel (struct GNUNET_IDENTITY_Operation *op)
924{ 945{
925 op->cont = NULL; 946 op->cont = NULL;
926 op->cb = NULL; 947 op->cb = NULL;
948 op->create_cont = NULL;
949 if (NULL != op->pk)
950 {
951 GNUNET_free (op->pk);
952 op->pk = NULL;
953 }
927} 954}
928 955
929 956
@@ -957,6 +984,7 @@ GNUNET_IDENTITY_disconnect (struct GNUNET_IDENTITY_Handle *h)
957 GNUNET_CONTAINER_DLL_remove (h->op_head, 984 GNUNET_CONTAINER_DLL_remove (h->op_head,
958 h->op_tail, 985 h->op_tail,
959 op); 986 op);
987 GNUNET_free_non_null (op->pk);
960 GNUNET_free (op); 988 GNUNET_free (op);
961 } 989 }
962 if (NULL != h->mq) 990 if (NULL != h->mq)