aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/include/gnunet_protocols.h17
-rw-r--r--src/include/gnunet_reclaim_service.h72
-rw-r--r--src/reclaim/gnunet-reclaim.c3
-rw-r--r--src/reclaim/gnunet-service-reclaim.c337
-rw-r--r--src/reclaim/plugin_rest_openid_connect.c85
-rw-r--r--src/reclaim/plugin_rest_reclaim.c91
-rw-r--r--src/reclaim/reclaim.h58
-rw-r--r--src/reclaim/reclaim_api.c139
8 files changed, 603 insertions, 199 deletions
diff --git a/src/include/gnunet_protocols.h b/src/include/gnunet_protocols.h
index 8091fb367..d92015787 100644
--- a/src/include/gnunet_protocols.h
+++ b/src/include/gnunet_protocols.h
@@ -2720,21 +2720,26 @@ extern "C" {
2720 2720
2721#define GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_RESULT 979 2721#define GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_RESULT 979
2722 2722
2723#define GNUNET_MESSAGE_TYPE_RECLAIM_REFERENCE_STORE 980 2723#define GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_ITERATION_START 963
2724
2725#define GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_ITERATION_STOP 964
2726
2727#define GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_ITERATION_NEXT 965
2728
2724 2729
2725/************************************************** 2730/**************************************************
2726 * 2731 *
2727 * ABD MESSAGE TYPES 2732 * ABD MESSAGE TYPES
2728 */ 2733 */
2729#define GNUNET_MESSAGE_TYPE_ABD_VERIFY 981 2734#define GNUNET_MESSAGE_TYPE_ABD_VERIFY 991
2730 2735
2731#define GNUNET_MESSAGE_TYPE_ABD_VERIFY_RESULT 982 2736#define GNUNET_MESSAGE_TYPE_ABD_VERIFY_RESULT 992
2732 2737
2733#define GNUNET_MESSAGE_TYPE_ABD_COLLECT 983 2738#define GNUNET_MESSAGE_TYPE_ABD_COLLECT 993
2734 2739
2735#define GNUNET_MESSAGE_TYPE_ABD_COLLECT_RESULT 984 2740#define GNUNET_MESSAGE_TYPE_ABD_COLLECT_RESULT 994
2736 2741
2737#define GNUNET_MESSAGE_TYPE_ABD_INTERMEDIATE_RESULT 985 2742#define GNUNET_MESSAGE_TYPE_ABD_INTERMEDIATE_RESULT 995
2738 2743
2739/******************************************************************************/ 2744/******************************************************************************/
2740 2745
diff --git a/src/include/gnunet_reclaim_service.h b/src/include/gnunet_reclaim_service.h
index 4ead87003..c9c4fa5d1 100644
--- a/src/include/gnunet_reclaim_service.h
+++ b/src/include/gnunet_reclaim_service.h
@@ -107,7 +107,6 @@ typedef void (*GNUNET_RECLAIM_ContinuationWithStatus) (void *cls,
107 int32_t success, 107 int32_t success,
108 const char *emsg); 108 const char *emsg);
109 109
110
111/** 110/**
112 * Callback used to notify the client of attribute results. 111 * Callback used to notify the client of attribute results.
113 * 112 *
@@ -118,6 +117,18 @@ typedef void (*GNUNET_RECLAIM_ContinuationWithStatus) (void *cls,
118 */ 117 */
119typedef void (*GNUNET_RECLAIM_AttributeResult) ( 118typedef void (*GNUNET_RECLAIM_AttributeResult) (
120 void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, 119 void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
120 const struct GNUNET_RECLAIM_Attribute *attr);
121
122/**
123 * Callback used to notify the client of attribute results.
124 *
125 * @param cls The callback closure
126 * @param identity The identity authoritative over the attributes
127 * @param attr The attribute
128 * @param attestation The attestation for the attribute (may be NULL)
129 */
130typedef void (*GNUNET_RECLAIM_AttributeTicketResult) (
131 void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
121 const struct GNUNET_RECLAIM_Attribute *attr, 132 const struct GNUNET_RECLAIM_Attribute *attr,
122 const struct GNUNET_RECLAIM_Attestation *attestation); 133 const struct GNUNET_RECLAIM_Attestation *attestation);
123 134
@@ -281,6 +292,63 @@ GNUNET_RECLAIM_get_attributes_stop (
281 292
282 293
283/** 294/**
295 * List all attestations for a local identity.
296 * This MUST lock the `struct GNUNET_RECLAIM_Handle`
297 * for any other calls than #GNUNET_RECLAIM_get_attestations_next() and
298 * #GNUNET_RECLAIM_get_attestations_stop. @a proc will be called once
299 * immediately, and then again after
300 * #GNUNET_RECLAIM_get_attestations_next() is invoked.
301 *
302 * On error (disconnect), @a error_cb will be invoked.
303 * On normal completion, @a finish_cb proc will be
304 * invoked.
305 *
306 * @param h Handle to the re:claimID service
307 * @param identity Identity to iterate over
308 * @param error_cb Function to call on error (i.e. disconnect),
309 * the handle is afterwards invalid
310 * @param error_cb_cls Closure for @a error_cb
311 * @param proc Function to call on each attestation
312 * @param proc_cls Closure for @a proc
313 * @param finish_cb Function to call on completion
314 * the handle is afterwards invalid
315 * @param finish_cb_cls Closure for @a finish_cb
316 * @return an iterator Handle to use for iteration
317 */
318struct GNUNET_RECLAIM_AttestationIterator *
319GNUNET_RECLAIM_get_attestations_start (
320 struct GNUNET_RECLAIM_Handle *h,
321 const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity,
322 GNUNET_SCHEDULER_TaskCallback error_cb,
323 void *error_cb_cls,
324 GNUNET_RECLAIM_AttestationResult proc,
325 void *proc_cls,
326 GNUNET_SCHEDULER_TaskCallback finish_cb,
327 void *finish_cb_cls);
328
329
330/**
331 * Calls the record processor specified in #GNUNET_RECLAIM_get_attestation_start
332 * for the next record.
333 *
334 * @param it the iterator
335 */
336void
337GNUNET_RECLAIM_get_attestations_next (struct GNUNET_RECLAIM_AttestationIterator *ait);
338
339
340/**
341 * Stops iteration and releases the handle for further calls. Must
342 * be called on any iteration that has not yet completed prior to calling
343 * #GNUNET_RECLAIM_disconnect.
344 *
345 * @param it the iterator
346 */
347void
348GNUNET_RECLAIM_get_attestations_stop (struct GNUNET_RECLAIM_AttestationIterator *ait);
349
350
351/**
284 * Issues a ticket to a relying party. The identity may use 352 * Issues a ticket to a relying party. The identity may use
285 * GNUNET_RECLAIM_ticket_consume to consume the ticket 353 * GNUNET_RECLAIM_ticket_consume to consume the ticket
286 * and retrieve the attributes specified in the attribute list. 354 * and retrieve the attributes specified in the attribute list.
@@ -340,7 +408,7 @@ GNUNET_RECLAIM_ticket_consume (
340 struct GNUNET_RECLAIM_Handle *h, 408 struct GNUNET_RECLAIM_Handle *h,
341 const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, 409 const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity,
342 const struct GNUNET_RECLAIM_Ticket *ticket, 410 const struct GNUNET_RECLAIM_Ticket *ticket,
343 GNUNET_RECLAIM_AttributeResult cb, void *cb_cls); 411 GNUNET_RECLAIM_AttributeTicketResult cb, void *cb_cls);
344 412
345 413
346/** 414/**
diff --git a/src/reclaim/gnunet-reclaim.c b/src/reclaim/gnunet-reclaim.c
index b72336907..93d9ee3df 100644
--- a/src/reclaim/gnunet-reclaim.c
+++ b/src/reclaim/gnunet-reclaim.c
@@ -447,8 +447,7 @@ iter_finished (void *cls)
447static void 447static void
448iter_cb (void *cls, 448iter_cb (void *cls,
449 const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, 449 const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
450 const struct GNUNET_RECLAIM_Attribute *attr, 450 const struct GNUNET_RECLAIM_Attribute *attr)
451 const struct GNUNET_RECLAIM_Attestation *attest)
452{ 451{
453 struct GNUNET_RECLAIM_AttributeListEntry *le; 452 struct GNUNET_RECLAIM_AttributeListEntry *le;
454 char *attrs_tmp; 453 char *attrs_tmp;
diff --git a/src/reclaim/gnunet-service-reclaim.c b/src/reclaim/gnunet-service-reclaim.c
index 15f9a8385..f6fd04eeb 100644
--- a/src/reclaim/gnunet-service-reclaim.c
+++ b/src/reclaim/gnunet-service-reclaim.c
@@ -90,17 +90,17 @@ struct TicketIteration
90/** 90/**
91 * An attribute iteration operation. 91 * An attribute iteration operation.
92 */ 92 */
93struct AttributeIterator 93struct Iterator
94{ 94{
95 /** 95 /**
96 * Next element in the DLL 96 * Next element in the DLL
97 */ 97 */
98 struct AttributeIterator *next; 98 struct Iterator *next;
99 99
100 /** 100 /**
101 * Previous element in the DLL 101 * Previous element in the DLL
102 */ 102 */
103 struct AttributeIterator *prev; 103 struct Iterator *prev;
104 104
105 /** 105 /**
106 * IDP client which intiated this zone iteration 106 * IDP client which intiated this zone iteration
@@ -121,6 +121,11 @@ struct AttributeIterator
121 * The operation id fot the zone iteration in the response for the client 121 * The operation id fot the zone iteration in the response for the client
122 */ 122 */
123 uint32_t request_id; 123 uint32_t request_id;
124
125 /**
126 * Context
127 */
128 void *ctx;
124}; 129};
125 130
126 131
@@ -154,14 +159,28 @@ struct IdpClient
154 * Attribute iteration operations in 159 * Attribute iteration operations in
155 * progress initiated by this client 160 * progress initiated by this client
156 */ 161 */
157 struct AttributeIterator *attr_iter_head; 162 struct Iterator *attr_iter_head;
163
164 /**
165 * Tail of the DLL of
166 * Attribute iteration operations
167 * in progress initiated by this client
168 */
169 struct Iterator *attr_iter_tail;
170
171 /**
172 * Head of the DLL of
173 * Attribute iteration operations in
174 * progress initiated by this client
175 */
176 struct Iterator *attest_iter_head;
158 177
159 /** 178 /**
160 * Tail of the DLL of 179 * Tail of the DLL of
161 * Attribute iteration operations 180 * Attribute iteration operations
162 * in progress initiated by this client 181 * in progress initiated by this client
163 */ 182 */
164 struct AttributeIterator *attr_iter_tail; 183 struct Iterator *attest_iter_tail;
165 184
166 /** 185 /**
167 * Head of DLL of ticket iteration ops 186 * Head of DLL of ticket iteration ops
@@ -512,7 +531,7 @@ cleanup_as_handle (struct AttributeStoreHandle *ash)
512static void 531static void
513cleanup_client (struct IdpClient *idp) 532cleanup_client (struct IdpClient *idp)
514{ 533{
515 struct AttributeIterator *ai; 534 struct Iterator *ai;
516 struct TicketIteration *ti; 535 struct TicketIteration *ti;
517 struct TicketRevocationOperation *rop; 536 struct TicketRevocationOperation *rop;
518 struct TicketIssueOperation *iss; 537 struct TicketIssueOperation *iss;
@@ -550,6 +569,13 @@ cleanup_client (struct IdpClient *idp)
550 GNUNET_CONTAINER_DLL_remove (idp->attr_iter_head, idp->attr_iter_tail, ai); 569 GNUNET_CONTAINER_DLL_remove (idp->attr_iter_head, idp->attr_iter_tail, ai);
551 GNUNET_free (ai); 570 GNUNET_free (ai);
552 } 571 }
572 while (NULL != (ai = idp->attest_iter_head))
573 {
574 GNUNET_CONTAINER_DLL_remove (idp->attest_iter_head, idp->attest_iter_tail,
575 ai);
576 GNUNET_free (ai);
577 }
578
553 while (NULL != (rop = idp->revoke_op_head)) 579 while (NULL != (rop = idp->revoke_op_head))
554 { 580 {
555 GNUNET_CONTAINER_DLL_remove (idp->revoke_op_head, idp->revoke_op_tail, rop); 581 GNUNET_CONTAINER_DLL_remove (idp->revoke_op_head, idp->revoke_op_tail, rop);
@@ -1641,7 +1667,7 @@ handle_attestation_delete_message (void *cls,
1641static void 1667static void
1642attr_iter_finished (void *cls) 1668attr_iter_finished (void *cls)
1643{ 1669{
1644 struct AttributeIterator *ai = cls; 1670 struct Iterator *ai = cls;
1645 struct GNUNET_MQ_Envelope *env; 1671 struct GNUNET_MQ_Envelope *env;
1646 struct AttributeResultMessage *arm; 1672 struct AttributeResultMessage *arm;
1647 1673
@@ -1665,7 +1691,7 @@ attr_iter_finished (void *cls)
1665static void 1691static void
1666attr_iter_error (void *cls) 1692attr_iter_error (void *cls)
1667{ 1693{
1668 struct AttributeIterator *ai = cls; 1694 struct Iterator *ai = cls;
1669 1695
1670 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to iterate over attributes\n"); 1696 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to iterate over attributes\n");
1671 attr_iter_finished (ai); 1697 attr_iter_finished (ai);
@@ -1688,7 +1714,7 @@ attr_iter_cb (void *cls,
1688 unsigned int rd_count, 1714 unsigned int rd_count,
1689 const struct GNUNET_GNSRECORD_Data *rd) 1715 const struct GNUNET_GNSRECORD_Data *rd)
1690{ 1716{
1691 struct AttributeIterator *ai = cls; 1717 struct Iterator *ai = cls;
1692 struct GNUNET_MQ_Envelope *env; 1718 struct GNUNET_MQ_Envelope *env;
1693 char *data_tmp; 1719 char *data_tmp;
1694 1720
@@ -1697,71 +1723,25 @@ attr_iter_cb (void *cls,
1697 GNUNET_NAMESTORE_zone_iterator_next (ai->ns_it, 1); 1723 GNUNET_NAMESTORE_zone_iterator_next (ai->ns_it, 1);
1698 return; 1724 return;
1699 } 1725 }
1700 if (rd_count > 1)
1701 {
1702 if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF == rd[0].record_type)
1703 {
1704 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1705 "Found Ticket. Ignoring.\n");
1706 GNUNET_NAMESTORE_zone_iterator_next (ai->ns_it, 1);
1707 return;
1708 }
1709 else if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION != rd[0].record_type)
1710 {
1711 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1712 "Non-Attestation record with multiple entries found: %u\n",
1713 rd[0].record_type);
1714 GNUNET_NAMESTORE_zone_iterator_next (ai->ns_it, 1);
1715 return;
1716 }
1717 }
1718 1726
1719 for (int i = 0; i<rd_count; i++) 1727 for (int i = 0; i<rd_count; i++)
1720 { 1728 {
1721 if ((GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE != rd[i].record_type) && 1729 if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE != rd[i].record_type)
1722 (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION != rd[i].record_type)) 1730 continue;
1723 { 1731 struct AttributeResultMessage *arm;
1724 GNUNET_NAMESTORE_zone_iterator_next (ai->ns_it, 1); 1732 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found attribute under: %s\n",
1725 return; 1733 label);
1726 } 1734 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1727 // FIXME Send attribute TOGETHER with respective attestation if applicable 1735 "Sending ATTRIBUTE_RESULT message\n");
1728 if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE == rd[i].record_type) 1736 env = GNUNET_MQ_msg_extra (arm,
1729 { 1737 rd[i].data_size,
1730 struct AttributeResultMessage *arm; 1738 GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT);
1731 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found attribute under: %s\n", 1739 arm->id = htonl (ai->request_id);
1732 label); 1740 arm->attr_len = htons (rd[i].data_size);
1733 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1741 GNUNET_CRYPTO_ecdsa_key_get_public (zone, &arm->identity);
1734 "Sending ATTRIBUTE_RESULT message\n"); 1742 data_tmp = (char *) &arm[1];
1735 env = GNUNET_MQ_msg_extra (arm, 1743 GNUNET_memcpy (data_tmp, rd[i].data, rd[i].data_size);
1736 rd[i].data_size, 1744 GNUNET_MQ_send (ai->client->mq, env);
1737 GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT);
1738 arm->id = htonl (ai->request_id);
1739 arm->attr_len = htons (rd[i].data_size);
1740 GNUNET_CRYPTO_ecdsa_key_get_public (zone, &arm->identity);
1741 data_tmp = (char *) &arm[1];
1742 GNUNET_memcpy (data_tmp, rd[i].data, rd[i].data_size);
1743 GNUNET_MQ_send (ai->client->mq, env);
1744 }
1745 else
1746 {
1747 if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION == rd[i].record_type)
1748 {
1749 struct AttributeResultMessage *arm;
1750 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found attestation under: %s\n",
1751 label);
1752 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1753 "Sending ATTESTATION_RESULT message\n");
1754 env = GNUNET_MQ_msg_extra (arm,
1755 rd[i].data_size,
1756 GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_RESULT);
1757 arm->id = htonl (ai->request_id);
1758 arm->attr_len = htons (rd[i].data_size);
1759 GNUNET_CRYPTO_ecdsa_key_get_public (zone, &arm->identity);
1760 data_tmp = (char *) &arm[1];
1761 GNUNET_memcpy (data_tmp, rd[i].data, rd[i].data_size);
1762 GNUNET_MQ_send (ai->client->mq, env);
1763 }
1764 }
1765 } 1745 }
1766} 1746}
1767 1747
@@ -1777,11 +1757,11 @@ handle_iteration_start (void *cls,
1777 const struct AttributeIterationStartMessage *ais_msg) 1757 const struct AttributeIterationStartMessage *ais_msg)
1778{ 1758{
1779 struct IdpClient *idp = cls; 1759 struct IdpClient *idp = cls;
1780 struct AttributeIterator *ai; 1760 struct Iterator *ai;
1781 1761
1782 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1762 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1783 "Received ATTRIBUTE_ITERATION_START message\n"); 1763 "Received ATTRIBUTE_ITERATION_START message\n");
1784 ai = GNUNET_new (struct AttributeIterator); 1764 ai = GNUNET_new (struct Iterator);
1785 ai->request_id = ntohl (ais_msg->id); 1765 ai->request_id = ntohl (ais_msg->id);
1786 ai->client = idp; 1766 ai->client = idp;
1787 ai->identity = ais_msg->identity; 1767 ai->identity = ais_msg->identity;
@@ -1810,7 +1790,7 @@ handle_iteration_stop (void *cls,
1810 const struct AttributeIterationStopMessage *ais_msg) 1790 const struct AttributeIterationStopMessage *ais_msg)
1811{ 1791{
1812 struct IdpClient *idp = cls; 1792 struct IdpClient *idp = cls;
1813 struct AttributeIterator *ai; 1793 struct Iterator *ai;
1814 uint32_t rid; 1794 uint32_t rid;
1815 1795
1816 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1796 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -1843,7 +1823,7 @@ handle_iteration_next (void *cls,
1843 const struct AttributeIterationNextMessage *ais_msg) 1823 const struct AttributeIterationNextMessage *ais_msg)
1844{ 1824{
1845 struct IdpClient *idp = cls; 1825 struct IdpClient *idp = cls;
1846 struct AttributeIterator *ai; 1826 struct Iterator *ai;
1847 uint32_t rid; 1827 uint32_t rid;
1848 1828
1849 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1829 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -1863,6 +1843,200 @@ handle_iteration_next (void *cls,
1863} 1843}
1864 1844
1865 1845
1846/*************************************************
1847* Attestation iteration
1848*************************************************/
1849
1850
1851/**
1852 * Done iterating over attestations
1853 *
1854 * @param cls our iterator handle
1855 */
1856static void
1857attest_iter_finished (void *cls)
1858{
1859 struct Iterator *ai = cls;
1860 struct GNUNET_MQ_Envelope *env;
1861 struct AttestationResultMessage *arm;
1862
1863 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending ATTESTATION_RESULT message\n");
1864 env = GNUNET_MQ_msg (arm, GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_RESULT);
1865 arm->id = htonl (ai->request_id);
1866 arm->attestation_len = htons (0);
1867 GNUNET_MQ_send (ai->client->mq, env);
1868 GNUNET_CONTAINER_DLL_remove (ai->client->attest_iter_head,
1869 ai->client->attest_iter_tail,
1870 ai);
1871 GNUNET_free (ai);
1872}
1873
1874
1875/**
1876 * Error iterating over attestations. Abort.
1877 *
1878 * @param cls our attribute iteration handle
1879 */
1880static void
1881attest_iter_error (void *cls)
1882{
1883 struct Iterator *ai = cls;
1884
1885 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to iterate over attestations\n");
1886 attest_iter_finished (ai);
1887}
1888
1889
1890/**
1891 * Got record. Return attestation.
1892 *
1893 * @param cls our attribute iterator
1894 * @param zone zone we are iterating
1895 * @param label label of the records
1896 * @param rd_count record count
1897 * @param rd records
1898 */
1899static void
1900attest_iter_cb (void *cls,
1901 const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
1902 const char *label,
1903 unsigned int rd_count,
1904 const struct GNUNET_GNSRECORD_Data *rd)
1905{
1906 struct Iterator *ai = cls;
1907 struct GNUNET_MQ_Envelope *env;
1908 char *data_tmp;
1909
1910 if (rd_count == 0)
1911 {
1912 GNUNET_NAMESTORE_zone_iterator_next (ai->ns_it, 1);
1913 return;
1914 }
1915
1916 for (int i = 0; i<rd_count; i++)
1917 {
1918 if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION != rd[i].record_type)
1919 continue;
1920 struct AttestationResultMessage *arm;
1921 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found attestation under: %s\n",
1922 label);
1923 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1924 "Sending ATTESTATION_RESULT message\n");
1925 env = GNUNET_MQ_msg_extra (arm,
1926 rd[i].data_size,
1927 GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_RESULT);
1928 arm->id = htonl (ai->request_id);
1929 arm->attestation_len = htons (rd[i].data_size);
1930 GNUNET_CRYPTO_ecdsa_key_get_public (zone, &arm->identity);
1931 data_tmp = (char *) &arm[1];
1932 GNUNET_memcpy (data_tmp, rd[i].data, rd[i].data_size);
1933 GNUNET_MQ_send (ai->client->mq, env);
1934 }
1935}
1936
1937
1938/**
1939 * Iterate over zone to get attributes
1940 *
1941 * @param cls our client
1942 * @param ais_msg the iteration message to start
1943 */
1944static void
1945handle_attestation_iteration_start (void *cls,
1946 const struct
1947 AttestationIterationStartMessage *ais_msg)
1948{
1949 struct IdpClient *idp = cls;
1950 struct Iterator *ai;
1951
1952 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1953 "Received ATTESTATION_ITERATION_START message\n");
1954 ai = GNUNET_new (struct Iterator);
1955 ai->request_id = ntohl (ais_msg->id);
1956 ai->client = idp;
1957 ai->identity = ais_msg->identity;
1958
1959 GNUNET_CONTAINER_DLL_insert (idp->attest_iter_head, idp->attest_iter_tail,
1960 ai);
1961 ai->ns_it = GNUNET_NAMESTORE_zone_iteration_start (nsh,
1962 &ai->identity,
1963 &attest_iter_error,
1964 ai,
1965 &attest_iter_cb,
1966 ai,
1967 &attest_iter_finished,
1968 ai);
1969 GNUNET_SERVICE_client_continue (idp->client);
1970}
1971
1972
1973/**
1974 * Handle iteration stop message from client
1975 *
1976 * @param cls the client
1977 * @param ais_msg the stop message
1978 */
1979static void
1980handle_attestation_iteration_stop (void *cls,
1981 const struct
1982 AttestationIterationStopMessage *ais_msg)
1983{
1984 struct IdpClient *idp = cls;
1985 struct Iterator *ai;
1986 uint32_t rid;
1987
1988 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1989 "Received `%s' message\n",
1990 "ATTESTATION_ITERATION_STOP");
1991 rid = ntohl (ais_msg->id);
1992 for (ai = idp->attest_iter_head; NULL != ai; ai = ai->next)
1993 if (ai->request_id == rid)
1994 break;
1995 if (NULL == ai)
1996 {
1997 GNUNET_break (0);
1998 GNUNET_SERVICE_client_drop (idp->client);
1999 return;
2000 }
2001 GNUNET_CONTAINER_DLL_remove (idp->attest_iter_head, idp->attest_iter_tail,
2002 ai);
2003 GNUNET_free (ai);
2004 GNUNET_SERVICE_client_continue (idp->client);
2005}
2006
2007
2008/**
2009 * Client requests next attestation from iterator
2010 *
2011 * @param cls the client
2012 * @param ais_msg the message
2013 */
2014static void
2015handle_attestation_iteration_next (void *cls,
2016 const struct
2017 AttestationIterationNextMessage *ais_msg)
2018{
2019 struct IdpClient *idp = cls;
2020 struct Iterator *ai;
2021 uint32_t rid;
2022
2023 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2024 "Received ATTESTATION_ITERATION_NEXT message\n");
2025 rid = ntohl (ais_msg->id);
2026 for (ai = idp->attest_iter_head; NULL != ai; ai = ai->next)
2027 if (ai->request_id == rid)
2028 break;
2029 if (NULL == ai)
2030 {
2031 GNUNET_break (0);
2032 GNUNET_SERVICE_client_drop (idp->client);
2033 return;
2034 }
2035 GNUNET_NAMESTORE_zone_iterator_next (ai->ns_it, 1);
2036 GNUNET_SERVICE_client_continue (idp->client);
2037}
2038
2039
1866/****************************************************** 2040/******************************************************
1867* Ticket iteration 2041* Ticket iteration
1868******************************************************/ 2042******************************************************/
@@ -2115,6 +2289,19 @@ GNUNET_SERVICE_MAIN (
2115 GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_STOP, 2289 GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_STOP,
2116 struct AttributeIterationStopMessage, 2290 struct AttributeIterationStopMessage,
2117 NULL), 2291 NULL),
2292 GNUNET_MQ_hd_fixed_size (attestation_iteration_start,
2293 GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_ITERATION_START,
2294 struct AttestationIterationStartMessage,
2295 NULL),
2296 GNUNET_MQ_hd_fixed_size (attestation_iteration_next,
2297 GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_ITERATION_NEXT,
2298 struct AttestationIterationNextMessage,
2299 NULL),
2300 GNUNET_MQ_hd_fixed_size (attestation_iteration_stop,
2301 GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_ITERATION_STOP,
2302 struct AttestationIterationStopMessage,
2303 NULL),
2304
2118 GNUNET_MQ_hd_var_size (issue_ticket_message, 2305 GNUNET_MQ_hd_var_size (issue_ticket_message,
2119 GNUNET_MESSAGE_TYPE_RECLAIM_ISSUE_TICKET, 2306 GNUNET_MESSAGE_TYPE_RECLAIM_ISSUE_TICKET,
2120 struct IssueTicketMessage, 2307 struct IssueTicketMessage,
diff --git a/src/reclaim/plugin_rest_openid_connect.c b/src/reclaim/plugin_rest_openid_connect.c
index 610f93dbe..345dbeed6 100644
--- a/src/reclaim/plugin_rest_openid_connect.c
+++ b/src/reclaim/plugin_rest_openid_connect.c
@@ -457,6 +457,12 @@ struct RequestHandle
457 struct GNUNET_RECLAIM_AttributeIterator *attr_it; 457 struct GNUNET_RECLAIM_AttributeIterator *attr_it;
458 458
459 /** 459 /**
460 * Attestation iterator
461 */
462 struct GNUNET_RECLAIM_AttestationIterator *attest_it;
463
464
465 /**
460 * Ticket iterator 466 * Ticket iterator
461 */ 467 */
462 struct GNUNET_RECLAIM_TicketIterator *ticket_it; 468 struct GNUNET_RECLAIM_TicketIterator *ticket_it;
@@ -529,7 +535,6 @@ struct RequestHandle
529static void 535static void
530cleanup_handle (struct RequestHandle *handle) 536cleanup_handle (struct RequestHandle *handle)
531{ 537{
532 struct GNUNET_RECLAIM_AttributeListEntry *claim_entry;
533 struct EgoEntry *ego_entry; 538 struct EgoEntry *ego_entry;
534 struct EgoEntry *ego_tmp; 539 struct EgoEntry *ego_tmp;
535 540
@@ -540,6 +545,8 @@ cleanup_handle (struct RequestHandle *handle)
540 GNUNET_IDENTITY_disconnect (handle->identity_handle); 545 GNUNET_IDENTITY_disconnect (handle->identity_handle);
541 if (NULL != handle->attr_it) 546 if (NULL != handle->attr_it)
542 GNUNET_RECLAIM_get_attributes_stop (handle->attr_it); 547 GNUNET_RECLAIM_get_attributes_stop (handle->attr_it);
548 if (NULL != handle->attest_it)
549 GNUNET_RECLAIM_get_attestations_stop (handle->attest_it);
543 if (NULL != handle->ticket_it) 550 if (NULL != handle->ticket_it)
544 GNUNET_RECLAIM_ticket_iteration_stop (handle->ticket_it); 551 GNUNET_RECLAIM_ticket_iteration_stop (handle->ticket_it);
545 if (NULL != handle->idp) 552 if (NULL != handle->idp)
@@ -961,7 +968,53 @@ oidc_ticket_issue_cb (void *cls, const struct GNUNET_RECLAIM_Ticket *ticket)
961 968
962 969
963static void 970static void
964oidc_collect_finished_cb (void *cls) 971oidc_attest_collect_finished_cb (void *cls)
972{
973 struct RequestHandle *handle = cls;
974
975 handle->attest_it = NULL;
976 handle->idp_op = GNUNET_RECLAIM_ticket_issue (handle->idp,
977 &handle->priv_key,
978 &handle->oidc->client_pkey,
979 handle->attr_list,
980 &oidc_ticket_issue_cb,
981 handle);
982}
983
984
985/**
986 * Collects all attributes for an ego if in scope parameter
987 */
988static void
989oidc_attest_collect (void *cls,
990 const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
991 const struct GNUNET_RECLAIM_Attestation *attest)
992{
993 struct RequestHandle *handle = cls;
994 struct GNUNET_RECLAIM_AttributeListEntry *le;
995
996 for (le = handle->attr_list->list_head; NULL != le; le = le->next)
997 {
998 if (GNUNET_NO == GNUNET_RECLAIM_id_is_equal (&le->attribute->attestation,
999 &attest->id))
1000 {
1001 struct GNUNET_RECLAIM_AttestationListEntry *ale;
1002 ale = GNUNET_new (struct GNUNET_RECLAIM_AttestationListEntry);
1003 ale->attestation = GNUNET_RECLAIM_attestation_new (attest->name,
1004 attest->type,
1005 attest->data,
1006 attest->data_size);
1007 GNUNET_CONTAINER_DLL_insert (handle->attests_list->list_head,
1008 handle->attests_list->list_tail,
1009 ale);
1010 }
1011 }
1012 GNUNET_RECLAIM_get_attestations_next (handle->attest_it);
1013}
1014
1015
1016static void
1017oidc_attr_collect_finished_cb (void *cls)
965{ 1018{
966 struct RequestHandle *handle = cls; 1019 struct RequestHandle *handle = cls;
967 1020
@@ -974,6 +1027,17 @@ oidc_collect_finished_cb (void *cls)
974 GNUNET_SCHEDULER_add_now (&do_redirect_error, handle); 1027 GNUNET_SCHEDULER_add_now (&do_redirect_error, handle);
975 return; 1028 return;
976 } 1029 }
1030 handle->attests_list = GNUNET_new (struct GNUNET_RECLAIM_AttestationList);
1031 handle->attest_it =
1032 GNUNET_RECLAIM_get_attestations_start (handle->idp,
1033 &handle->priv_key,
1034 &oidc_iteration_error,
1035 handle,
1036 &oidc_attest_collect,
1037 handle,
1038 &oidc_attest_collect_finished_cb,
1039 handle);
1040
977 handle->idp_op = GNUNET_RECLAIM_ticket_issue (handle->idp, 1041 handle->idp_op = GNUNET_RECLAIM_ticket_issue (handle->idp,
978 &handle->priv_key, 1042 &handle->priv_key,
979 &handle->oidc->client_pkey, 1043 &handle->oidc->client_pkey,
@@ -989,8 +1053,7 @@ oidc_collect_finished_cb (void *cls)
989static void 1053static void
990oidc_attr_collect (void *cls, 1054oidc_attr_collect (void *cls,
991 const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, 1055 const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
992 const struct GNUNET_RECLAIM_Attribute *attr, 1056 const struct GNUNET_RECLAIM_Attribute *attr)
993 const struct GNUNET_RECLAIM_Attestation *attest)
994{ 1057{
995 struct RequestHandle *handle = cls; 1058 struct RequestHandle *handle = cls;
996 struct GNUNET_RECLAIM_AttributeListEntry *le; 1059 struct GNUNET_RECLAIM_AttributeListEntry *le;
@@ -1026,18 +1089,6 @@ oidc_attr_collect (void *cls,
1026 GNUNET_CONTAINER_DLL_insert (handle->attr_list->list_head, 1089 GNUNET_CONTAINER_DLL_insert (handle->attr_list->list_head,
1027 handle->attr_list->list_tail, 1090 handle->attr_list->list_tail,
1028 le); 1091 le);
1029 if (GNUNET_NO == GNUNET_RECLAIM_id_is_zero (&attr->attestation))
1030 {
1031 struct GNUNET_RECLAIM_AttestationListEntry *ale;
1032 ale = GNUNET_new (struct GNUNET_RECLAIM_AttestationListEntry);
1033 ale->attestation = GNUNET_RECLAIM_attestation_new (attest->name,
1034 attest->type,
1035 attest->data,
1036 attest->data_size);
1037 GNUNET_CONTAINER_DLL_insert (handle->attests_list->list_head,
1038 handle->attests_list->list_tail,
1039 ale);
1040 }
1041 GNUNET_RECLAIM_get_attributes_next (handle->attr_it); 1092 GNUNET_RECLAIM_get_attributes_next (handle->attr_it);
1042} 1093}
1043 1094
@@ -1104,7 +1155,7 @@ code_redirect (void *cls)
1104 handle, 1155 handle,
1105 &oidc_attr_collect, 1156 &oidc_attr_collect,
1106 handle, 1157 handle,
1107 &oidc_collect_finished_cb, 1158 &oidc_attr_collect_finished_cb,
1108 handle); 1159 handle);
1109 return; 1160 return;
1110 } 1161 }
diff --git a/src/reclaim/plugin_rest_reclaim.c b/src/reclaim/plugin_rest_reclaim.c
index fcb34e11a..6f7a5987b 100644
--- a/src/reclaim/plugin_rest_reclaim.c
+++ b/src/reclaim/plugin_rest_reclaim.c
@@ -712,13 +712,14 @@ list_attestation_cont (struct GNUNET_REST_RequestHandle *con_handle,
712 priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego); 712 priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
713 handle->idp = GNUNET_RECLAIM_connect (cfg); 713 handle->idp = GNUNET_RECLAIM_connect (cfg);
714 handle->attest_it = GNUNET_RECLAIM_get_attestations_start (handle->idp, 714 handle->attest_it = GNUNET_RECLAIM_get_attestations_start (handle->idp,
715 priv_key, 715 priv_key,
716 &collect_error_cb, 716 &collect_error_cb,
717 handle, 717 handle,
718 &attest_collect, 718 &attest_collect,
719 handle, 719 handle,
720 &collect_finished_cb, 720 &
721 handle); 721 collect_finished_cb,
722 handle);
722} 723}
723 724
724 725
@@ -1000,67 +1001,33 @@ parse_jwt (const struct GNUNET_RECLAIM_Attestation *attest,
1000static void 1001static void
1001attr_collect (void *cls, 1002attr_collect (void *cls,
1002 const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, 1003 const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
1003 const struct GNUNET_RECLAIM_Attribute *attr, 1004 const struct GNUNET_RECLAIM_Attribute *attr)
1004 const struct GNUNET_RECLAIM_Attestation *attest)
1005{ 1005{
1006 struct RequestHandle *handle = cls; 1006 struct RequestHandle *handle = cls;
1007 json_t *attr_obj; 1007 json_t *attr_obj;
1008 const char *type; 1008 const char *type;
1009 char *id_str; 1009 char *id_str;
1010 1010
1011 if (GNUNET_NO == GNUNET_RECLAIM_id_is_zero (&attr->attestation)) 1011 char *tmp_value;
1012 { 1012 tmp_value = GNUNET_RECLAIM_attribute_value_to_string (attr->type,
1013 struct GNUNET_RECLAIM_Attribute *attr2; 1013 attr->data,
1014 attr2 = parse_jwt (attest, attr->data); 1014 attr->data_size);
1015 if (NULL == attr2) 1015 attr_obj = json_object ();
1016 { 1016 json_object_set_new (attr_obj, "value", json_string (tmp_value));
1017 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1017 json_object_set_new (attr_obj, "name", json_string (attr->name));
1018 "Attribute Collection with unparsed Attestation\n"); 1018
1019 return; 1019 json_object_set_new (attr_obj, "flag", json_string ("1"));
1020 } 1020 type = GNUNET_RECLAIM_attribute_number_to_typename (attr->type);
1021 attr2->name = attr->name; 1021 json_object_set_new (attr_obj, "type", json_string (type));
1022 char *tmp_value; 1022 id_str = GNUNET_STRINGS_data_to_string_alloc (&attr->id,
1023 tmp_value = GNUNET_RECLAIM_attribute_value_to_string (attr2->type, 1023 sizeof(attr->id));
1024 attr2->data, 1024 json_object_set_new (attr_obj, "id", json_string (id_str));
1025 attr2->data_size); 1025 id_str = GNUNET_STRINGS_data_to_string_alloc (&attr->attestation,
1026 attr_obj = json_object (); 1026 sizeof(attr->attestation));
1027 json_object_set_new (attr_obj, "value", json_string (tmp_value)); 1027 json_object_set_new (attr_obj, "attestation", json_string (id_str));
1028 json_object_set_new (attr_obj, "name", json_string (attr2->name)); 1028 json_array_append (handle->resp_object, attr_obj);
1029 json_object_set_new (attr_obj, "flag", json_string ("1")); 1029 json_decref (attr_obj);
1030 type = GNUNET_RECLAIM_attribute_number_to_typename (attr2->type); 1030 GNUNET_free (tmp_value);
1031 json_object_set_new (attr_obj, "type", json_string (type));
1032 id_str = GNUNET_STRINGS_data_to_string_alloc (&attr2->id,
1033 sizeof(attr2->id));
1034 json_object_set_new (attr_obj, "id", json_string (id_str));
1035 json_array_append (handle->resp_object, attr_obj);
1036 json_decref (attr_obj);
1037 GNUNET_free (tmp_value);
1038 }
1039 else
1040 {
1041 char *tmp_value;
1042 char *flag_str;
1043 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attribute: %s\n", attr->name);
1044
1045 tmp_value = GNUNET_RECLAIM_attribute_value_to_string (attr->type,
1046 attr->data,
1047 attr->data_size);
1048
1049 attr_obj = json_object ();
1050 json_object_set_new (attr_obj, "value", json_string (tmp_value));
1051 json_object_set_new (attr_obj, "name", json_string (attr->name));
1052 GNUNET_asprintf (&flag_str,"%d",attr->flag);
1053 json_object_set_new (attr_obj, "flag", json_string (flag_str));
1054 type = GNUNET_RECLAIM_attribute_number_to_typename (attr->type);
1055 json_object_set_new (attr_obj, "type", json_string (type));
1056 id_str = GNUNET_STRINGS_data_to_string_alloc (&attr->id,
1057 sizeof(attr->id));
1058 json_object_set_new (attr_obj, "id", json_string (id_str));
1059 json_array_append (handle->resp_object, attr_obj);
1060 json_decref (attr_obj);
1061 GNUNET_free (tmp_value);
1062 GNUNET_RECLAIM_get_attributes_next (handle->attr_it);
1063 }
1064} 1031}
1065 1032
1066 1033
diff --git a/src/reclaim/reclaim.h b/src/reclaim/reclaim.h
index 3da49fe7a..7b5d7ab19 100644
--- a/src/reclaim/reclaim.h
+++ b/src/reclaim/reclaim.h
@@ -195,12 +195,12 @@ struct AttestationResultMessage
195 195
196 196
197/** 197/**
198 * Reference plus Attestation is returned from the idp. 198 * Start a attribute iteration for the given identity
199 */ 199 */
200struct ReferenceResultMessage 200struct AttributeIterationStartMessage
201{ 201{
202 /** 202 /**
203 * Message header 203 * Message
204 */ 204 */
205 struct GNUNET_MessageHeader header; 205 struct GNUNET_MessageHeader header;
206 206
@@ -210,34 +210,33 @@ struct ReferenceResultMessage
210 uint32_t id GNUNET_PACKED; 210 uint32_t id GNUNET_PACKED;
211 211
212 /** 212 /**
213 * Length of serialized attestation data 213 * Identity.
214 */ 214 */
215 uint16_t attest_len GNUNET_PACKED; 215 struct GNUNET_CRYPTO_EcdsaPrivateKey identity;
216};
216 217
217 /**
218 * Length of serialized reference data
219 */
220 uint16_t ref_len GNUNET_PACKED;
221 218
219/**
220 * Ask for next result of attribute iteration for the given operation
221 */
222struct AttributeIterationNextMessage
223{
222 /** 224 /**
223 * always zero (for alignment) 225 * Type will be #GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_NEXT
224 */ 226 */
225 uint16_t reserved GNUNET_PACKED; 227 struct GNUNET_MessageHeader header;
226 228
227 /** 229 /**
228 * The public key of the identity. 230 * Unique identifier for this request (for key collisions).
229 */
230 struct GNUNET_CRYPTO_EcdsaPublicKey identity;
231
232 /* followed by:
233 * serialized reference data + attestation data
234 */ 231 */
232 uint32_t id GNUNET_PACKED;
235}; 233};
236 234
235
237/** 236/**
238 * Start a attribute iteration for the given identity 237 * Start a attestation iteration for the given identity
239 */ 238 */
240struct AttributeIterationStartMessage 239struct AttestationIterationStartMessage
241{ 240{
242 /** 241 /**
243 * Message 242 * Message
@@ -257,9 +256,9 @@ struct AttributeIterationStartMessage
257 256
258 257
259/** 258/**
260 * Ask for next result of attribute iteration for the given operation 259 * Ask for next result of attestation iteration for the given operation
261 */ 260 */
262struct AttributeIterationNextMessage 261struct AttestationIterationNextMessage
263{ 262{
264 /** 263 /**
265 * Type will be #GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_NEXT 264 * Type will be #GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_NEXT
@@ -274,6 +273,23 @@ struct AttributeIterationNextMessage
274 273
275 274
276/** 275/**
276 * Stop attestation iteration for the given operation
277 */
278struct AttestationIterationStopMessage
279{
280 /**
281 * Type will be #GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_STOP
282 */
283 struct GNUNET_MessageHeader header;
284
285 /**
286 * Unique identifier for this request (for key collisions).
287 */
288 uint32_t id GNUNET_PACKED;
289};
290
291
292/**
277 * Stop attribute iteration for the given operation 293 * Stop attribute iteration for the given operation
278 */ 294 */
279struct AttributeIterationStopMessage 295struct AttributeIterationStopMessage
diff --git a/src/reclaim/reclaim_api.c b/src/reclaim/reclaim_api.c
index 0fcf95ee3..89b9ea0f7 100644
--- a/src/reclaim/reclaim_api.c
+++ b/src/reclaim/reclaim_api.c
@@ -72,6 +72,11 @@ struct GNUNET_RECLAIM_Operation
72 GNUNET_RECLAIM_AttributeResult ar_cb; 72 GNUNET_RECLAIM_AttributeResult ar_cb;
73 73
74 /** 74 /**
75 * Attribute result callback
76 */
77 GNUNET_RECLAIM_AttributeTicketResult atr_cb;
78
79 /**
75 * Attestation result callback 80 * Attestation result callback
76 */ 81 */
77 GNUNET_RECLAIM_AttestationResult at_cb; 82 GNUNET_RECLAIM_AttestationResult at_cb;
@@ -607,11 +612,11 @@ handle_consume_ticket_result (void *cls,
607 read_ptr = ((char *) &msg[1]) + attrs_len; 612 read_ptr = ((char *) &msg[1]) + attrs_len;
608 attests = 613 attests =
609 GNUNET_RECLAIM_attestation_list_deserialize (read_ptr, attests_len); 614 GNUNET_RECLAIM_attestation_list_deserialize (read_ptr, attests_len);
610 if (NULL != op->ar_cb) 615 if (NULL != op->atr_cb)
611 { 616 {
612 if (NULL == attrs) 617 if (NULL == attrs)
613 { 618 {
614 op->ar_cb (op->cls, &msg->identity, NULL, NULL); 619 op->atr_cb (op->cls, &msg->identity, NULL, NULL);
615 } 620 }
616 else 621 else
617 { 622 {
@@ -626,7 +631,7 @@ handle_consume_ticket_result (void *cls,
626 GNUNET_RECLAIM_id_is_equal (&le->attribute->id, 631 GNUNET_RECLAIM_id_is_equal (&le->attribute->id,
627 &ale->attestation->id)) 632 &ale->attestation->id))
628 { 633 {
629 op->ar_cb (op->cls, &msg->identity, 634 op->atr_cb (op->cls, &msg->identity,
630 le->attribute, ale->attestation); 635 le->attribute, ale->attestation);
631 break; 636 break;
632 } 637 }
@@ -635,7 +640,7 @@ handle_consume_ticket_result (void *cls,
635 } 640 }
636 else // No attestations 641 else // No attestations
637 { 642 {
638 op->ar_cb (op->cls, &msg->identity, 643 op->atr_cb (op->cls, &msg->identity,
639 le->attribute, NULL); 644 le->attribute, NULL);
640 } 645 }
641 } 646 }
@@ -644,7 +649,7 @@ handle_consume_ticket_result (void *cls,
644 attrs = NULL; 649 attrs = NULL;
645 attests = NULL; 650 attests = NULL;
646 } 651 }
647 op->ar_cb (op->cls, NULL, NULL, NULL); 652 op->atr_cb (op->cls, NULL, NULL, NULL);
648 } 653 }
649 GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op); 654 GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op);
650 free_op (op); 655 free_op (op);
@@ -730,7 +735,7 @@ handle_attribute_result (void *cls, const struct AttributeResultMessage *msg)
730 if (NULL != op) 735 if (NULL != op)
731 { 736 {
732 if (NULL != op->ar_cb) 737 if (NULL != op->ar_cb)
733 op->ar_cb (op->cls, NULL, NULL, NULL); 738 op->ar_cb (op->cls, NULL, NULL);
734 GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op); 739 GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op);
735 free_op (op); 740 free_op (op);
736 } 741 }
@@ -739,20 +744,16 @@ handle_attribute_result (void *cls, const struct AttributeResultMessage *msg)
739 744
740 { 745 {
741 struct GNUNET_RECLAIM_Attribute *attr; 746 struct GNUNET_RECLAIM_Attribute *attr;
742 struct GNUNET_RECLAIM_Attestation *attest;
743 char *read_ptr;
744 attr = GNUNET_RECLAIM_attribute_deserialize ((char *) &msg[1], attr_len); 747 attr = GNUNET_RECLAIM_attribute_deserialize ((char *) &msg[1], attr_len);
745 read_ptr = ((char *) &msg[1]) + attr_len;
746 attest = GNUNET_RECLAIM_attestation_deserialize (read_ptr, attest_len);
747 if (NULL != it) 748 if (NULL != it)
748 { 749 {
749 if (NULL != it->proc) 750 if (NULL != it->proc)
750 it->proc (it->proc_cls, &msg->identity, attr, attest); 751 it->proc (it->proc_cls, &msg->identity, attr);
751 } 752 }
752 else if (NULL != op) 753 else if (NULL != op)
753 { 754 {
754 if (NULL != op->ar_cb) 755 if (NULL != op->ar_cb)
755 op->ar_cb (op->cls, &msg->identity, attr, attest); 756 op->ar_cb (op->cls, &msg->identity, attr);
756 } 757 }
757 GNUNET_free (attr); 758 GNUNET_free (attr);
758 return; 759 return;
@@ -1370,6 +1371,116 @@ GNUNET_RECLAIM_get_attributes_stop (struct GNUNET_RECLAIM_AttributeIterator *it)
1370 1371
1371 1372
1372/** 1373/**
1374 * List all attestations for a local identity.
1375 * This MUST lock the `struct GNUNET_RECLAIM_Handle`
1376 * for any other calls than #GNUNET_RECLAIM_get_attestations_next() and
1377 * #GNUNET_RECLAIM_get_attestations_stop. @a proc will be called once
1378 * immediately, and then again after
1379 * #GNUNET_RECLAIM_get_attestations_next() is invoked.
1380 *
1381 * On error (disconnect), @a error_cb will be invoked.
1382 * On normal completion, @a finish_cb proc will be
1383 * invoked.
1384 *
1385 * @param h Handle to the re:claimID service
1386 * @param identity Identity to iterate over
1387 * @param error_cb Function to call on error (i.e. disconnect),
1388 * the handle is afterwards invalid
1389 * @param error_cb_cls Closure for @a error_cb
1390 * @param proc Function to call on each attestation
1391 * @param proc_cls Closure for @a proc
1392 * @param finish_cb Function to call on completion
1393 * the handle is afterwards invalid
1394 * @param finish_cb_cls Closure for @a finish_cb
1395 * @return an iterator Handle to use for iteration
1396 */
1397struct GNUNET_RECLAIM_AttestationIterator *
1398GNUNET_RECLAIM_get_attestations_start (
1399 struct GNUNET_RECLAIM_Handle *h,
1400 const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity,
1401 GNUNET_SCHEDULER_TaskCallback error_cb,
1402 void *error_cb_cls,
1403 GNUNET_RECLAIM_AttestationResult proc,
1404 void *proc_cls,
1405 GNUNET_SCHEDULER_TaskCallback finish_cb,
1406 void *finish_cb_cls)
1407{
1408 struct GNUNET_RECLAIM_AttestationIterator *ait;
1409 struct GNUNET_MQ_Envelope *env;
1410 struct AttestationIterationStartMessage *msg;
1411 uint32_t rid;
1412
1413 rid = h->r_id_gen++;
1414 ait = GNUNET_new (struct GNUNET_RECLAIM_AttestationIterator);
1415 ait->h = h;
1416 ait->error_cb = error_cb;
1417 ait->error_cb_cls = error_cb_cls;
1418 ait->finish_cb = finish_cb;
1419 ait->finish_cb_cls = finish_cb_cls;
1420 ait->proc = proc;
1421 ait->proc_cls = proc_cls;
1422 ait->r_id = rid;
1423 ait->identity = *identity;
1424 GNUNET_CONTAINER_DLL_insert_tail (h->ait_head, h->ait_tail, ait);
1425 env =
1426 GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_START);
1427 msg->id = htonl (rid);
1428 msg->identity = *identity;
1429 if (NULL == h->mq)
1430 ait->env = env;
1431 else
1432 GNUNET_MQ_send (h->mq, env);
1433 return ait;
1434}
1435
1436
1437/**
1438 * Calls the record processor specified in #GNUNET_RECLAIM_get_attestation_start
1439 * for the next record.
1440 *
1441 * @param it the iterator
1442 */
1443void
1444GNUNET_RECLAIM_get_attestations_next (struct GNUNET_RECLAIM_AttestationIterator *ait)
1445{
1446 struct GNUNET_RECLAIM_Handle *h = ait->h;
1447 struct AttestationIterationNextMessage *msg;
1448 struct GNUNET_MQ_Envelope *env;
1449
1450 env =
1451 GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_ITERATION_NEXT);
1452 msg->id = htonl (ait->r_id);
1453 GNUNET_MQ_send (h->mq, env);
1454}
1455
1456
1457/**
1458 * Stops iteration and releases the handle for further calls. Must
1459 * be called on any iteration that has not yet completed prior to calling
1460 * #GNUNET_RECLAIM_disconnect.
1461 *
1462 * @param it the iterator
1463 */
1464void
1465GNUNET_RECLAIM_get_attestations_stop (struct GNUNET_RECLAIM_AttestationIterator *ait)
1466{
1467 struct GNUNET_RECLAIM_Handle *h = ait->h;
1468 struct GNUNET_MQ_Envelope *env;
1469 struct AttestationIterationStopMessage *msg;
1470
1471 if (NULL != h->mq)
1472 {
1473 env =
1474 GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_ITERATION_STOP);
1475 msg->id = htonl (ait->r_id);
1476 GNUNET_MQ_send (h->mq, env);
1477 }
1478 free_ait (ait);
1479}
1480
1481
1482
1483/**
1373 * Issues a ticket to another relying party. The identity may use 1484 * Issues a ticket to another relying party. The identity may use
1374 * @GNUNET_RECLAIM_ticket_consume to consume the ticket 1485 * @GNUNET_RECLAIM_ticket_consume to consume the ticket
1375 * and retrieve the attributes specified in the attribute list. 1486 * and retrieve the attributes specified in the attribute list.
@@ -1436,7 +1547,7 @@ GNUNET_RECLAIM_ticket_consume (
1436 struct GNUNET_RECLAIM_Handle *h, 1547 struct GNUNET_RECLAIM_Handle *h,
1437 const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, 1548 const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity,
1438 const struct GNUNET_RECLAIM_Ticket *ticket, 1549 const struct GNUNET_RECLAIM_Ticket *ticket,
1439 GNUNET_RECLAIM_AttributeResult cb, 1550 GNUNET_RECLAIM_AttributeTicketResult cb,
1440 void *cb_cls) 1551 void *cb_cls)
1441{ 1552{
1442 struct GNUNET_RECLAIM_Operation *op; 1553 struct GNUNET_RECLAIM_Operation *op;
@@ -1444,7 +1555,7 @@ GNUNET_RECLAIM_ticket_consume (
1444 1555
1445 op = GNUNET_new (struct GNUNET_RECLAIM_Operation); 1556 op = GNUNET_new (struct GNUNET_RECLAIM_Operation);
1446 op->h = h; 1557 op->h = h;
1447 op->ar_cb = cb; 1558 op->atr_cb = cb;
1448 op->cls = cb_cls; 1559 op->cls = cb_cls;
1449 op->r_id = h->r_id_gen++; 1560 op->r_id = h->r_id_gen++;
1450 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op); 1561 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op);