2
0

gnunet-service-reclaim_tickets.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. /*
  2. This file is part of GNUnet.
  3. Copyright (C) 2012-2015 GNUnet e.V.
  4. GNUnet is free software: you can redistribute it and/or modify it
  5. under the terms of the GNU Affero General Public License as published
  6. by the Free Software Foundation, either version 3 of the License,
  7. or (at your option) any later version.
  8. GNUnet is distributed in the hope that it will be useful, but
  9. WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Affero General Public License for more details.
  12. You should have received a copy of the GNU Affero General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>.
  14. SPDX-License-Identifier: AGPL3.0-or-later
  15. */
  16. /**
  17. * @author Martin Schanzenbach
  18. * @file src/reclaim/gnunet-service-reclaim_tickets.h
  19. * @brief reclaim tickets
  20. *
  21. */
  22. #ifndef GNUNET_SERVICE_RECLAIM_TICKETS_H
  23. #define GNUNET_SERVICE_RECLAIM_TICKETS_H
  24. #include "platform.h"
  25. #include "gnunet_util_lib.h"
  26. #include "gnunet_constants.h"
  27. #include "gnunet_gns_service.h"
  28. #include "gnunet_gnsrecord_lib.h"
  29. #include "gnunet_protocols.h"
  30. #include "gnunet_reclaim_attribute_lib.h"
  31. #include "gnunet_reclaim_service.h"
  32. #include "gnunet_signatures.h"
  33. #include "gnunet_statistics_service.h"
  34. #include "reclaim.h"
  35. /**
  36. * Ticket iterator
  37. */
  38. struct RECLAIM_TICKETS_Iterator;
  39. /**
  40. * Handle to a consume operation
  41. */
  42. struct RECLAIM_TICKETS_ConsumeHandle;
  43. /**
  44. * Ticket revocation request handle
  45. */
  46. struct RECLAIM_TICKETS_RevokeHandle;
  47. /**
  48. * List of tickets
  49. */
  50. struct TicketRecordsEntry
  51. {
  52. /**
  53. * DLL
  54. */
  55. struct TicketRecordsEntry *next;
  56. /**
  57. * DLL
  58. */
  59. struct TicketRecordsEntry *prev;
  60. /**
  61. * Record count
  62. */
  63. unsigned int rd_count;
  64. /**
  65. * Data
  66. */
  67. char *data;
  68. /**
  69. * Data size
  70. */
  71. size_t data_size;
  72. /**
  73. * Label
  74. */
  75. char *label;
  76. };
  77. /**
  78. * Continuation called with ticket.
  79. *
  80. * @param cls closure
  81. * @param ticket the ticket
  82. */
  83. typedef void (*RECLAIM_TICKETS_TicketIter) (
  84. void *cls,
  85. struct GNUNET_RECLAIM_Ticket *ticket);
  86. /**
  87. * Continuation called with ticket.
  88. *
  89. * @param cls closure
  90. * @param ticket the ticket
  91. * @param success #GNUNET_SYSERR on failure (including timeout/queue
  92. * drop/failure to validate) #GNUNET_OK on success
  93. * @param emsg NULL on success, otherwise an error message
  94. */
  95. typedef void (*RECLAIM_TICKETS_TicketResult) (
  96. void *cls,
  97. struct GNUNET_RECLAIM_Ticket *ticket,
  98. int32_t success,
  99. const char *emsg);
  100. /**
  101. * Consume callback.
  102. *
  103. * @param cls closure
  104. * @param identity the issuer of the ticket/attributes
  105. * @param l attribute list retrieved through ticket
  106. * @param success GNUNET_OK on success
  107. * @param emsg error message (NULL on success)
  108. */
  109. typedef void (*RECLAIM_TICKETS_ConsumeCallback) (
  110. void *cls,
  111. const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
  112. const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *l,
  113. int32_t success,
  114. const char *emsg);
  115. /**
  116. * Revocation callback.
  117. *
  118. * @param cls closure
  119. * @param success GNUNET_OK on success
  120. */
  121. typedef void (*RECLAIM_TICKETS_RevokeCallback) (void *cls, int32_t success);
  122. /**
  123. * Revoke a ticket.
  124. * We start by looking up attribute references in order
  125. * to change attribute IDs.
  126. *
  127. * @param ticket ticket to revoke
  128. * @param identity private key of issuer
  129. * @param cb revocation status callback
  130. * @param cb_cls callback closure
  131. * @return handle to the operation
  132. */
  133. struct RECLAIM_TICKETS_RevokeHandle *
  134. RECLAIM_TICKETS_revoke (const struct GNUNET_RECLAIM_Ticket *ticket,
  135. const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity,
  136. RECLAIM_TICKETS_RevokeCallback cb,
  137. void *cb_cls);
  138. /**
  139. * Cancel a revocation.
  140. *
  141. * @param rh handle to the operation
  142. */
  143. void
  144. RECLAIM_TICKETS_revoke_cancel (struct RECLAIM_TICKETS_RevokeHandle *rh);
  145. /**
  146. * Consume a ticket.
  147. * We first looking attribute references under the label
  148. * ticket.rnd in GNS.
  149. *
  150. * @param id the audience of the ticket
  151. * @param ticket the ticket to consume
  152. * @param cb callback to call with attributes of ticket
  153. * @param cb_cls callback closure
  154. * @return handle to the operation
  155. */
  156. struct RECLAIM_TICKETS_ConsumeHandle *
  157. RECLAIM_TICKETS_consume (const struct GNUNET_CRYPTO_EcdsaPrivateKey *id,
  158. const struct GNUNET_RECLAIM_Ticket *ticket,
  159. RECLAIM_TICKETS_ConsumeCallback cb,
  160. void *cb_cls);
  161. /**
  162. * Cancel a consume operation
  163. *
  164. * @param cth the operation to cancel
  165. */
  166. void
  167. RECLAIM_TICKETS_consume_cancel (struct RECLAIM_TICKETS_ConsumeHandle *cth);
  168. /**
  169. * Issue a new reclaim ticket, thereby authorizing
  170. * the audience to access the set of provided attributes.
  171. *
  172. * @param identity the issuer
  173. * @param attrs the attributes to share
  174. * @param audience the audience to share the attributes with
  175. * @param cb the callback to call with the ticket result
  176. * @param cb_cls the callback closure
  177. * FIXME: Return handle??
  178. */
  179. void
  180. RECLAIM_TICKETS_issue (const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity,
  181. const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs,
  182. const struct GNUNET_CRYPTO_EcdsaPublicKey *audience,
  183. RECLAIM_TICKETS_TicketResult cb,
  184. void *cb_cls);
  185. /**
  186. * Continue ticket iteration
  187. *
  188. * @param iter the iteration to continue
  189. */
  190. void
  191. RECLAIM_TICKETS_iteration_next (struct RECLAIM_TICKETS_Iterator *iter);
  192. /**
  193. * Stop a running ticket iteration
  194. *
  195. * @param iter iteration to cancel
  196. */
  197. void
  198. RECLAIM_TICKETS_iteration_stop (struct RECLAIM_TICKETS_Iterator *iter);
  199. /**
  200. * Iterate over all tickets issued by an identity
  201. *
  202. * @param identity the issuing identity
  203. * @param cb ticket callback function
  204. * @param cb_cls callback closure
  205. * @return a handle to the iteration
  206. */
  207. struct RECLAIM_TICKETS_Iterator *
  208. RECLAIM_TICKETS_iteration_start (
  209. const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity,
  210. RECLAIM_TICKETS_TicketIter cb,
  211. void *cb_cls);
  212. /**
  213. * Initialize tickets component
  214. *
  215. * @param c the configuration
  216. * @return GNUNET_SYSERR on error
  217. */
  218. int
  219. RECLAIM_TICKETS_init (const struct GNUNET_CONFIGURATION_Handle *c);
  220. /**
  221. * Close handles and clean up.
  222. * FIXME: cancel all pending operations (gns, ns etc)
  223. */
  224. void
  225. RECLAIM_TICKETS_deinit (void);
  226. #endif