2 This file is part of GNUnet.
3 Copyright (C) 2016 GNUnet e.V.
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
18 SPDX-License-Identifier: AGPL3.0-or-later
22 * @author Martin Schanzenbach
25 * reclaim service; implements identity and personal data sharing
28 * @defgroup reclaim service
31 #ifndef GNUNET_RECLAIM_SERVICE_H
32 #define GNUNET_RECLAIM_SERVICE_H
36 #if 0 /* keep Emacsens' auto-indent happy */
41 #include "gnunet_reclaim_lib.h"
42 #include "gnunet_util_lib.h"
45 * Version number of the re:claimID API.
47 #define GNUNET_RECLAIM_VERSION 0x00000001
50 * Opaque handle to access the service.
52 struct GNUNET_RECLAIM_Handle;
56 * Opaque handle for an operation at the re:claimID service.
58 struct GNUNET_RECLAIM_Operation;
62 * The authorization ticket. This ticket is meant to be transferred
63 * out of band to a relying party.
64 * The contents of a ticket must be protected and should be treated as a
65 * shared secret between user and relying party.
67 struct GNUNET_RECLAIM_Ticket
70 * The ticket issuer (= the user)
72 struct GNUNET_CRYPTO_EcdsaPublicKey identity;
75 * The ticket audience (= relying party)
77 struct GNUNET_CRYPTO_EcdsaPublicKey audience;
80 * The ticket random identifier
82 struct GNUNET_RECLAIM_Identifier rnd;
87 * Method called when a token has been issued.
88 * On success returns a ticket that can be given to a relying party
89 * in order for it retrive identity attributes
92 * @param ticket the ticket
94 typedef void (*GNUNET_RECLAIM_TicketCallback) (
95 void *cls, const struct GNUNET_RECLAIM_Ticket *ticket);
99 * Continuation called to notify client about result of the
102 * @param cls The callback closure
103 * @param success #GNUNET_SYSERR on failure
104 * @param emsg NULL on success, otherwise an error message
106 typedef void (*GNUNET_RECLAIM_ContinuationWithStatus) (void *cls,
111 * Callback used to notify the client of attribute results.
113 * @param cls The callback closure
114 * @param identity The identity authoritative over the attributes
115 * @param attr The attribute
116 * @param attestation The attestation for the attribute (may be NULL)
118 typedef void (*GNUNET_RECLAIM_AttributeResult) (
119 void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
120 const struct GNUNET_RECLAIM_Attribute *attr);
123 * Callback used to notify the client of attribute results.
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)
130 typedef void (*GNUNET_RECLAIM_AttributeTicketResult) (
131 void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
132 const struct GNUNET_RECLAIM_Attribute *attr,
133 const struct GNUNET_RECLAIM_Attestation *attestation);
137 * Callback used to notify the client of attestation results.
139 * @param cls The callback closure
140 * @param identity The identity authoritative over the attributes
141 * @param attestation The attestation
142 * @param attributes the parsed attributes
144 typedef void (*GNUNET_RECLAIM_AttestationResult) (
145 void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
146 const struct GNUNET_RECLAIM_Attestation *attestation);
150 * Connect to the re:claimID service.
152 * @param cfg Configuration to contact the re:claimID service.
153 * @return handle to communicate with the service
155 struct GNUNET_RECLAIM_Handle *
156 GNUNET_RECLAIM_connect (const struct GNUNET_CONFIGURATION_Handle *cfg);
160 * Store an attribute. If the attribute is already present,
161 * it is replaced with the new attribute.
163 * @param h handle to the reclaim service
164 * @param pkey Private key of the identity to add an attribute to
165 * @param attr The attribute
166 * @param exp_interval The relative expiration interval for the attribute
167 * @param cont Continuation to call when done
168 * @param cont_cls Closure for @a cont
169 * @return handle Used to to abort the request
171 struct GNUNET_RECLAIM_Operation *
172 GNUNET_RECLAIM_attribute_store (
173 struct GNUNET_RECLAIM_Handle *h,
174 const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey,
175 const struct GNUNET_RECLAIM_Attribute *attr,
176 const struct GNUNET_TIME_Relative *exp_interval,
177 GNUNET_RECLAIM_ContinuationWithStatus cont, void *cont_cls);
181 * Store an attestation. If the attestation is already present,
182 * it is replaced with the new attestation.
184 * @param h handle to the re:claimID service
185 * @param pkey private key of the identity
186 * @param attr the attestation value
187 * @param exp_interval the relative expiration interval for the attestation
188 * @param cont continuation to call when done
189 * @param cont_cls closure for @a cont
190 * @return handle to abort the request
192 struct GNUNET_RECLAIM_Operation *
193 GNUNET_RECLAIM_attestation_store (
194 struct GNUNET_RECLAIM_Handle *h,
195 const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey,
196 const struct GNUNET_RECLAIM_Attestation *attestation,
197 const struct GNUNET_TIME_Relative *exp_interval,
198 GNUNET_RECLAIM_ContinuationWithStatus cont,
203 * Delete an attribute. Tickets used to share this attribute are updated
206 * @param h handle to the re:claimID service
207 * @param pkey Private key of the identity to add an attribute to
208 * @param attr The attribute
209 * @param cont Continuation to call when done
210 * @param cont_cls Closure for @a cont
211 * @return handle Used to to abort the request
213 struct GNUNET_RECLAIM_Operation *
214 GNUNET_RECLAIM_attribute_delete (
215 struct GNUNET_RECLAIM_Handle *h,
216 const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey,
217 const struct GNUNET_RECLAIM_Attribute *attr,
218 GNUNET_RECLAIM_ContinuationWithStatus cont, void *cont_cls);
221 * Delete an attestation. Tickets used to share this attestation are updated
224 * @param h handle to the re:claimID service
225 * @param pkey Private key of the identity to add an attribute to
226 * @param attr The attestation
227 * @param cont Continuation to call when done
228 * @param cont_cls Closure for @a cont
229 * @return handle Used to to abort the request
231 struct GNUNET_RECLAIM_Operation *
232 GNUNET_RECLAIM_attestation_delete (
233 struct GNUNET_RECLAIM_Handle *h,
234 const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey,
235 const struct GNUNET_RECLAIM_Attestation *attr,
236 GNUNET_RECLAIM_ContinuationWithStatus cont,
240 * List all attributes for a local identity.
241 * This MUST lock the `struct GNUNET_RECLAIM_Handle`
242 * for any other calls than #GNUNET_RECLAIM_get_attributes_next() and
243 * #GNUNET_RECLAIM_get_attributes_stop. @a proc will be called once
244 * immediately, and then again after
245 * #GNUNET_RECLAIM_get_attributes_next() is invoked.
247 * On error (disconnect), @a error_cb will be invoked.
248 * On normal completion, @a finish_cb proc will be
251 * @param h Handle to the re:claimID service
252 * @param identity Identity to iterate over
253 * @param error_cb Function to call on error (i.e. disconnect),
254 * the handle is afterwards invalid
255 * @param error_cb_cls Closure for @a error_cb
256 * @param proc Function to call on each attribute
257 * @param proc_cls Closure for @a proc
258 * @param finish_cb Function to call on completion
259 * the handle is afterwards invalid
260 * @param finish_cb_cls Closure for @a finish_cb
261 * @return an iterator Handle to use for iteration
263 struct GNUNET_RECLAIM_AttributeIterator *
264 GNUNET_RECLAIM_get_attributes_start (
265 struct GNUNET_RECLAIM_Handle *h,
266 const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity,
267 GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls,
268 GNUNET_RECLAIM_AttributeResult proc, void *proc_cls,
269 GNUNET_SCHEDULER_TaskCallback finish_cb, void *finish_cb_cls);
273 * Calls the record processor specified in #GNUNET_RECLAIM_get_attributes_start
274 * for the next record.
276 * @param it The iterator
279 GNUNET_RECLAIM_get_attributes_next (
280 struct GNUNET_RECLAIM_AttributeIterator *it);
284 * Stops iteration and releases the handle for further calls. Must
285 * be called on any iteration that has not yet completed prior to calling
286 * #GNUNET_RECLAIM_disconnect.
288 * @param it the iterator
291 GNUNET_RECLAIM_get_attributes_stop (
292 struct GNUNET_RECLAIM_AttributeIterator *it);
296 * List all attestations for a local identity.
297 * This MUST lock the `struct GNUNET_RECLAIM_Handle`
298 * for any other calls than #GNUNET_RECLAIM_get_attestations_next() and
299 * #GNUNET_RECLAIM_get_attestations_stop. @a proc will be called once
300 * immediately, and then again after
301 * #GNUNET_RECLAIM_get_attestations_next() is invoked.
303 * On error (disconnect), @a error_cb will be invoked.
304 * On normal completion, @a finish_cb proc will be
307 * @param h Handle to the re:claimID service
308 * @param identity Identity to iterate over
309 * @param error_cb Function to call on error (i.e. disconnect),
310 * the handle is afterwards invalid
311 * @param error_cb_cls Closure for @a error_cb
312 * @param proc Function to call on each attestation
313 * @param proc_cls Closure for @a proc
314 * @param finish_cb Function to call on completion
315 * the handle is afterwards invalid
316 * @param finish_cb_cls Closure for @a finish_cb
317 * @return an iterator Handle to use for iteration
319 struct GNUNET_RECLAIM_AttestationIterator *
320 GNUNET_RECLAIM_get_attestations_start (
321 struct GNUNET_RECLAIM_Handle *h,
322 const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity,
323 GNUNET_SCHEDULER_TaskCallback error_cb,
325 GNUNET_RECLAIM_AttestationResult proc,
327 GNUNET_SCHEDULER_TaskCallback finish_cb,
328 void *finish_cb_cls);
332 * Calls the record processor specified in #GNUNET_RECLAIM_get_attestation_start
333 * for the next record.
335 * @param it the iterator
338 GNUNET_RECLAIM_get_attestations_next (struct GNUNET_RECLAIM_AttestationIterator *ait);
342 * Stops iteration and releases the handle for further calls. Must
343 * be called on any iteration that has not yet completed prior to calling
344 * #GNUNET_RECLAIM_disconnect.
346 * @param it the iterator
349 GNUNET_RECLAIM_get_attestations_stop (struct GNUNET_RECLAIM_AttestationIterator *ait);
353 * Issues a ticket to a relying party. The identity may use
354 * GNUNET_RECLAIM_ticket_consume to consume the ticket
355 * and retrieve the attributes specified in the attribute list.
357 * @param h the identity provider to use
358 * @param iss the issuing identity (= the user)
359 * @param rp the subject of the ticket (= the relying party)
360 * @param attrs the attributes that the relying party is given access to
361 * @param cb the callback
362 * @param cb_cls the callback closure
363 * @return handle to abort the operation
365 struct GNUNET_RECLAIM_Operation *
366 GNUNET_RECLAIM_ticket_issue (
367 struct GNUNET_RECLAIM_Handle *h,
368 const struct GNUNET_CRYPTO_EcdsaPrivateKey *iss,
369 const struct GNUNET_CRYPTO_EcdsaPublicKey *rp,
370 const struct GNUNET_RECLAIM_AttributeList *attrs,
371 GNUNET_RECLAIM_TicketCallback cb, void *cb_cls);
375 * Revoked an issued ticket. The relying party will be unable to retrieve
376 * attributes. Other issued tickets remain unaffected.
377 * This includes tickets issued to other relying parties as well as to
378 * other tickets issued to the audience specified in this ticket.
380 * @param h the identity provider to use
381 * @param identity the issuing identity
382 * @param ticket the ticket to revoke
383 * @param cb the callback
384 * @param cb_cls the callback closure
385 * @return handle to abort the operation
387 struct GNUNET_RECLAIM_Operation *
388 GNUNET_RECLAIM_ticket_revoke (
389 struct GNUNET_RECLAIM_Handle *h,
390 const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity,
391 const struct GNUNET_RECLAIM_Ticket *ticket,
392 GNUNET_RECLAIM_ContinuationWithStatus cb, void *cb_cls);
396 * Consumes an issued ticket. The ticket is used to retrieve identity
397 * information from the issuer
399 * @param h the identity provider to use
400 * @param identity the identity that is the subject of the issued ticket (the
402 * @param ticket the issued ticket to consume
403 * @param cb the callback to call
404 * @param cb_cls the callback closure
405 * @return handle to abort the operation
407 struct GNUNET_RECLAIM_Operation *
408 GNUNET_RECLAIM_ticket_consume (
409 struct GNUNET_RECLAIM_Handle *h,
410 const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity,
411 const struct GNUNET_RECLAIM_Ticket *ticket,
412 GNUNET_RECLAIM_AttributeTicketResult cb, void *cb_cls);
416 * Lists all tickets that have been issued to remote
417 * identites (relying parties)
419 * @param h the identity provider to use
420 * @param identity the issuing identity
421 * @param error_cb function to call on error (i.e. disconnect),
422 * the handle is afterwards invalid
423 * @param error_cb_cls closure for @a error_cb
424 * @param proc function to call on each ticket; it
425 * will be called repeatedly with a value (if available)
426 * @param proc_cls closure for @a proc
427 * @param finish_cb function to call on completion
428 * the handle is afterwards invalid
429 * @param finish_cb_cls closure for @a finish_cb
430 * @return an iterator handle to use for iteration
432 struct GNUNET_RECLAIM_TicketIterator *
433 GNUNET_RECLAIM_ticket_iteration_start (
434 struct GNUNET_RECLAIM_Handle *h,
435 const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity,
436 GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls,
437 GNUNET_RECLAIM_TicketCallback proc, void *proc_cls,
438 GNUNET_SCHEDULER_TaskCallback finish_cb, void *finish_cb_cls);
442 * Calls the ticket processor specified in
443 * #GNUNET_RECLAIM_ticket_iteration_start for the next record.
445 * @param it the iterator
448 GNUNET_RECLAIM_ticket_iteration_next (struct GNUNET_RECLAIM_TicketIterator *it);
452 * Stops iteration and releases the handle for further calls. Must
453 * be called on any iteration that has not yet completed prior to calling
454 * #GNUNET_RECLAIM_disconnect.
456 * @param it the iterator
459 GNUNET_RECLAIM_ticket_iteration_stop (struct GNUNET_RECLAIM_TicketIterator *it);
463 * Disconnect from identity provider service.
465 * @param h identity provider service to disconnect
468 GNUNET_RECLAIM_disconnect (struct GNUNET_RECLAIM_Handle *h);
472 * Cancel an identity provider operation. Note that the operation MAY still
473 * be executed; this merely cancels the continuation; if the request
474 * was already transmitted, the service may still choose to complete
477 * @param op operation to cancel
480 GNUNET_RECLAIM_cancel (struct GNUNET_RECLAIM_Operation *op);
483 #if 0 /* keep Emacsens' auto-indent happy */
491 /* ifndef GNUNET_RECLAIM_SERVICE_H */
494 /** @} */ /* end of group reclaim */
496 /* end of gnunet_reclaim_service.h */