From 3777e05a09dc9f375354bf01542f4fd6807e58c5 Mon Sep 17 00:00:00 2001 From: "Schanzenbach, Martin" Date: Sun, 17 Sep 2017 21:44:35 +0200 Subject: [PATCH] -minor fixed, start consume --- src/identity-provider/gnunet-idp.c | 8 --- .../gnunet-service-identity-provider.c | 12 ++--- src/identity-provider/identity_provider.h | 25 +++++++++ src/identity-provider/identity_provider_api.c | 51 +++++++++++++++++++ .../plugin_gnsrecord_identity_provider.c | 6 ++- .../gnunet_identity_provider_service.h | 2 +- 6 files changed, 87 insertions(+), 17 deletions(-) diff --git a/src/identity-provider/gnunet-idp.c b/src/identity-provider/gnunet-idp.c index fdd4720e0..f85ede7aa 100644 --- a/src/identity-provider/gnunet-idp.c +++ b/src/identity-provider/gnunet-idp.c @@ -138,9 +138,6 @@ store_attr_cont (void *cls, int32_t success, const char*emsg) { - GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, - "Store continuation\n"); - if (GNUNET_SYSERR == success) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s\n", emsg); @@ -166,8 +163,6 @@ iter_finished (void *cls) { struct GNUNET_IDENTITY_PROVIDER_Attribute *attr; - GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, - "Attribute collection finished!\n"); attr_iterator = NULL; if (list) { GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); @@ -187,9 +182,6 @@ iter_finished (void *cls) GNUNET_IDENTITY_PROVIDER_AT_STRING, attr_value, strlen (attr_value)); - GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, - "Adding attribute\n"); - idp_op = GNUNET_IDENTITY_PROVIDER_attribute_store (idp_handle, pkey, attr, diff --git a/src/identity-provider/gnunet-service-identity-provider.c b/src/identity-provider/gnunet-service-identity-provider.c index b481c00c0..0eb6599e6 100644 --- a/src/identity-provider/gnunet-service-identity-provider.c +++ b/src/identity-provider/gnunet-service-identity-provider.c @@ -620,7 +620,7 @@ bootstrap_store_task (void *cls) rd[0].data_size = GNUNET_CRYPTO_cpabe_serialize_master_key (abh->abe_key, (void**)&rd[0].data); rd[0].record_type = GNUNET_GNSRECORD_TYPE_ABE_MASTER; - rd[0].flags = GNUNET_GNSRECORD_RF_NONE | GNUNET_GNSRECORD_RF_PRIVATE; + rd[0].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION | GNUNET_GNSRECORD_RF_PRIVATE; rd[0].expiration_time = GNUNET_TIME_UNIT_HOURS.rel_value_us; //TODO sane? abh->ns_qe = GNUNET_NAMESTORE_records_store (ns_handle, &abh->identity, @@ -1869,7 +1869,7 @@ attr_store_cont (void *cls, return; } - GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending ATTRIBUTE_STORE_RESPONSE message\n"); env = GNUNET_MQ_msg (acr_msg, GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_ATTRIBUTE_STORE_RESPONSE); @@ -1888,7 +1888,7 @@ attr_store_task (void *cls) char* buf; size_t buf_size; - GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Storing attribute\n"); buf_size = attribute_serialize_get_size (as_handle->attribute); buf = GNUNET_malloc (buf_size); @@ -1924,7 +1924,7 @@ static void store_after_abe_bootstrap (void *cls, struct GNUNET_CRYPTO_AbeMasterKey *abe_key) { - GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Finished ABE bootstrap\n"); struct AttributeStoreHandle *ash = cls; ash->abe_key = abe_key; @@ -1969,7 +1969,7 @@ handle_attribute_store_message (void *cls, struct AttributeStoreHandle *as_handle; struct IdpClient *idp = cls; size_t data_len; - GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received ATTRIBUTE_STORE message\n"); data_len = ntohs (sam->attr_len); @@ -2059,7 +2059,7 @@ attr_iter_cb (void *cls, key, (void**)&attr_ser); GNUNET_CRYPTO_cpabe_delete_key (key); - GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found attribute: %s\n", label); env = GNUNET_MQ_msg_extra (arm, msg_extra_len, diff --git a/src/identity-provider/identity_provider.h b/src/identity-provider/identity_provider.h index 098885e3c..9b6fe6237 100644 --- a/src/identity-provider/identity_provider.h +++ b/src/identity-provider/identity_provider.h @@ -367,6 +367,31 @@ struct TicketResultMessage uint32_t id GNUNET_PACKED; }; + +/** + * Ticket consume message + */ +struct ConsumeTicketMessage +{ + /** + * Type will be #GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_TICKET_ISSUE + */ + struct GNUNET_MessageHeader header; + + /** + * Unique identifier for this request (for key collisions). + */ + uint32_t id GNUNET_PACKED; + + /** + * Identity. + */ + struct GNUNET_CRYPTO_EcdsaPrivateKey identity; + + //Followed by a serialized ticket +}; + + GNUNET_NETWORK_STRUCT_END #endif diff --git a/src/identity-provider/identity_provider_api.c b/src/identity-provider/identity_provider_api.c index 74d15bbe0..25c14793d 100644 --- a/src/identity-provider/identity_provider_api.c +++ b/src/identity-provider/identity_provider_api.c @@ -80,6 +80,11 @@ struct GNUNET_IDENTITY_PROVIDER_Operation */ GNUNET_IDENTITY_PROVIDER_ContinuationWithStatus as_cb; + /** + * Attribute result callback + */ + GNUNET_IDENTITY_PROVIDER_AttributeResult ar_cb; + /** * Ticket result callback */ @@ -1188,6 +1193,52 @@ GNUNET_IDENTITY_PROVIDER_idp_ticket_issue (struct GNUNET_IDENTITY_PROVIDER_Handl return op; } +/** + * Consumes an issued ticket. The ticket is persisted + * and used to retrieve identity information from the issuer + * + * @param id the identity provider to use + * @param identity the identity that is the subject of the issued ticket (the relying party) + * @param ticket the issued ticket to consume + * @param cb the callback to call + * @param cb_cls the callback closure + * @return handle to abort the operation + */ +struct GNUNET_IDENTITY_PROVIDER_Operation * +GNUNET_IDENTITY_PROVIDER_rp_ticket_consume (struct GNUNET_IDENTITY_PROVIDER_Handle *h, + const struct GNUNET_CRYPTO_EcdsaPrivateKey * identity, + const struct GNUNET_IDENTITY_PROVIDER_Ticket2 *ticket, + GNUNET_IDENTITY_PROVIDER_AttributeResult cb, + void *cb_cls) +{ + struct GNUNET_IDENTITY_PROVIDER_Operation *op; + struct ConsumeTicketMessage *ctm; + + op = GNUNET_new (struct GNUNET_IDENTITY_PROVIDER_Operation); + op->h = h; + op->ar_cb = cb; + op->cls = cb_cls; + op->r_id = h->r_id_gen++; + GNUNET_CONTAINER_DLL_insert_tail (h->op_head, + h->op_tail, + op); + op->env = GNUNET_MQ_msg_extra (ctm, + sizeof (const struct GNUNET_IDENTITY_PROVIDER_Ticket2), + GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_TICKET_ISSUE); + ctm->identity = *identity; + ctm->id = htonl (op->r_id); + + GNUNET_memcpy ((char*)&ctm[1], + ticket, + sizeof (const struct GNUNET_IDENTITY_PROVIDER_Ticket2)); + + if (NULL != h->mq) + GNUNET_MQ_send_copy (h->mq, + op->env); + return op; + +} + diff --git a/src/identity-provider/plugin_gnsrecord_identity_provider.c b/src/identity-provider/plugin_gnsrecord_identity_provider.c index 1f1973783..cee0a9506 100644 --- a/src/identity-provider/plugin_gnsrecord_identity_provider.c +++ b/src/identity-provider/plugin_gnsrecord_identity_provider.c @@ -175,6 +175,8 @@ static struct { } name_map[] = { { "ID_ATTR", GNUNET_GNSRECORD_TYPE_ID_ATTR }, { "ID_TOKEN", GNUNET_GNSRECORD_TYPE_ID_TOKEN }, + { "ABE_KEY", GNUNET_GNSRECORD_TYPE_ABE_KEY }, + { "ABE_MASTER", GNUNET_GNSRECORD_TYPE_ABE_MASTER }, { "ID_TOKEN_METADATA", GNUNET_GNSRECORD_TYPE_ID_TOKEN_METADATA }, { NULL, UINT32_MAX } }; @@ -229,7 +231,7 @@ number_to_typename (void *cls, * @return the exported block API */ void * -libgnunet_plugin_gnsrecord_identity_init (void *cls) +libgnunet_plugin_gnsrecord_identity_provider_init (void *cls) { struct GNUNET_GNSRECORD_PluginFunctions *api; @@ -249,7 +251,7 @@ libgnunet_plugin_gnsrecord_identity_init (void *cls) * @return NULL */ void * -libgnunet_plugin_gnsrecord_identity_done (void *cls) +libgnunet_plugin_gnsrecord_identity_provider_done (void *cls) { struct GNUNET_GNSRECORD_PluginFunctions *api = cls; diff --git a/src/include/gnunet_identity_provider_service.h b/src/include/gnunet_identity_provider_service.h index 7aaae2e85..4b1dcd641 100644 --- a/src/include/gnunet_identity_provider_service.h +++ b/src/include/gnunet_identity_provider_service.h @@ -403,7 +403,7 @@ GNUNET_IDENTITY_PROVIDER_idp_ticket_revoke (struct GNUNET_IDENTITY_PROVIDER_Hand struct GNUNET_IDENTITY_PROVIDER_Operation * GNUNET_IDENTITY_PROVIDER_rp_ticket_consume (struct GNUNET_IDENTITY_PROVIDER_Handle *id, const struct GNUNET_CRYPTO_EcdsaPrivateKey * identity, - const struct GNUNET_IDENTITY_PROVIDER_Ticket *ticket, + const struct GNUNET_IDENTITY_PROVIDER_Ticket2 *ticket, GNUNET_IDENTITY_PROVIDER_AttributeResult cb, void *cb_cls); -- 2.25.1