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_attribute_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 attr The attribute
143 typedef void (*GNUNET_RECLAIM_AttestationResult) (
144 void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
145 const struct GNUNET_RECLAIM_Attestation *attestation);
149 * Connect to the re:claimID service.
151 * @param cfg Configuration to contact the re:claimID service.
152 * @return handle to communicate with the service
154 struct GNUNET_RECLAIM_Handle *
155 GNUNET_RECLAIM_connect (const struct GNUNET_CONFIGURATION_Handle *cfg);
159 * Store an attribute. If the attribute is already present,
160 * it is replaced with the new attribute.
162 * @param h handle to the reclaim service
163 * @param pkey Private key of the identity to add an attribute to
164 * @param attr The attribute
165 * @param exp_interval The relative expiration interval for the attribute
166 * @param cont Continuation to call when done
167 * @param cont_cls Closure for @a cont
168 * @return handle Used to to abort the request
170 struct GNUNET_RECLAIM_Operation *
171 GNUNET_RECLAIM_attribute_store (
172 struct GNUNET_RECLAIM_Handle *h,
173 const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey,
174 const struct GNUNET_RECLAIM_Attribute *attr,
175 const struct GNUNET_TIME_Relative *exp_interval,
176 GNUNET_RECLAIM_ContinuationWithStatus cont, void *cont_cls);
180 * Store an attestation. If the attestation is already present,
181 * it is replaced with the new attestation.
183 * @param h handle to the re:claimID service
184 * @param pkey private key of the identity
185 * @param attr the attestation value
186 * @param exp_interval the relative expiration interval for the attestation
187 * @param cont continuation to call when done
188 * @param cont_cls closure for @a cont
189 * @return handle to abort the request
191 struct GNUNET_RECLAIM_Operation *
192 GNUNET_RECLAIM_attestation_store (
193 struct GNUNET_RECLAIM_Handle *h,
194 const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey,
195 const struct GNUNET_RECLAIM_Attestation *attestation,
196 const struct GNUNET_TIME_Relative *exp_interval,
197 GNUNET_RECLAIM_ContinuationWithStatus cont,
202 * Delete an attribute. Tickets used to share this attribute are updated
205 * @param h handle to the re:claimID service
206 * @param pkey Private key of the identity to add an attribute to
207 * @param attr The attribute
208 * @param cont Continuation to call when done
209 * @param cont_cls Closure for @a cont
210 * @return handle Used to to abort the request
212 struct GNUNET_RECLAIM_Operation *
213 GNUNET_RECLAIM_attribute_delete (
214 struct GNUNET_RECLAIM_Handle *h,
215 const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey,
216 const struct GNUNET_RECLAIM_Attribute *attr,
217 GNUNET_RECLAIM_ContinuationWithStatus cont, void *cont_cls);
220 * Delete an attestation. Tickets used to share this attestation are updated
223 * @param h handle to the re:claimID service
224 * @param pkey Private key of the identity to add an attribute to
225 * @param attr The attestation
226 * @param cont Continuation to call when done
227 * @param cont_cls Closure for @a cont
228 * @return handle Used to to abort the request
230 struct GNUNET_RECLAIM_Operation *
231 GNUNET_RECLAIM_attestation_delete (
232 struct GNUNET_RECLAIM_Handle *h,
233 const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey,
234 const struct GNUNET_RECLAIM_Attestation *attr,
235 GNUNET_RECLAIM_ContinuationWithStatus cont,
239 * List all attributes for a local identity.
240 * This MUST lock the `struct GNUNET_RECLAIM_Handle`
241 * for any other calls than #GNUNET_RECLAIM_get_attributes_next() and
242 * #GNUNET_RECLAIM_get_attributes_stop. @a proc will be called once
243 * immediately, and then again after
244 * #GNUNET_RECLAIM_get_attributes_next() is invoked.
246 * On error (disconnect), @a error_cb will be invoked.
247 * On normal completion, @a finish_cb proc will be
250 * @param h Handle to the re:claimID service
251 * @param identity Identity to iterate over
252 * @param error_cb Function to call on error (i.e. disconnect),
253 * the handle is afterwards invalid
254 * @param error_cb_cls Closure for @a error_cb
255 * @param proc Function to call on each attribute
256 * @param proc_cls Closure for @a proc
257 * @param finish_cb Function to call on completion
258 * the handle is afterwards invalid
259 * @param finish_cb_cls Closure for @a finish_cb
260 * @return an iterator Handle to use for iteration
262 struct GNUNET_RECLAIM_AttributeIterator *
263 GNUNET_RECLAIM_get_attributes_start (
264 struct GNUNET_RECLAIM_Handle *h,
265 const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity,
266 GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls,
267 GNUNET_RECLAIM_AttributeResult proc, void *proc_cls,
268 GNUNET_SCHEDULER_TaskCallback finish_cb, void *finish_cb_cls);
272 * Calls the record processor specified in #GNUNET_RECLAIM_get_attributes_start
273 * for the next record.
275 * @param it The iterator
278 GNUNET_RECLAIM_get_attributes_next (
279 struct GNUNET_RECLAIM_AttributeIterator *it);
283 * Stops iteration and releases the handle for further calls. Must
284 * be called on any iteration that has not yet completed prior to calling
285 * #GNUNET_RECLAIM_disconnect.
287 * @param it the iterator
290 GNUNET_RECLAIM_get_attributes_stop (
291 struct GNUNET_RECLAIM_AttributeIterator *it);
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.
302 * On error (disconnect), @a error_cb will be invoked.
303 * On normal completion, @a finish_cb proc will be
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
318 struct GNUNET_RECLAIM_AttestationIterator *
319 GNUNET_RECLAIM_get_attestations_start (
320 struct GNUNET_RECLAIM_Handle *h,
321 const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity,
322 GNUNET_SCHEDULER_TaskCallback error_cb,
324 GNUNET_RECLAIM_AttestationResult proc,
326 GNUNET_SCHEDULER_TaskCallback finish_cb,
327 void *finish_cb_cls);
331 * Calls the record processor specified in #GNUNET_RECLAIM_get_attestation_start
332 * for the next record.
334 * @param it the iterator
337 GNUNET_RECLAIM_get_attestations_next (struct GNUNET_RECLAIM_AttestationIterator *ait);
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.
345 * @param it the iterator
348 GNUNET_RECLAIM_get_attestations_stop (struct GNUNET_RECLAIM_AttestationIterator *ait);
352 * Issues a ticket to a relying party. The identity may use
353 * GNUNET_RECLAIM_ticket_consume to consume the ticket
354 * and retrieve the attributes specified in the attribute list.
356 * @param h the identity provider to use
357 * @param iss the issuing identity (= the user)
358 * @param rp the subject of the ticket (= the relying party)
359 * @param attrs the attributes that the relying party is given access to
360 * @param cb the callback
361 * @param cb_cls the callback closure
362 * @return handle to abort the operation
364 struct GNUNET_RECLAIM_Operation *
365 GNUNET_RECLAIM_ticket_issue (
366 struct GNUNET_RECLAIM_Handle *h,
367 const struct GNUNET_CRYPTO_EcdsaPrivateKey *iss,
368 const struct GNUNET_CRYPTO_EcdsaPublicKey *rp,
369 const struct GNUNET_RECLAIM_AttributeList *attrs,
370 GNUNET_RECLAIM_TicketCallback cb, void *cb_cls);
374 * Revoked an issued ticket. The relying party will be unable to retrieve
375 * attributes. Other issued tickets remain unaffected.
376 * This includes tickets issued to other relying parties as well as to
377 * other tickets issued to the audience specified in this ticket.
379 * @param h the identity provider to use
380 * @param identity the issuing identity
381 * @param ticket the ticket to revoke
382 * @param cb the callback
383 * @param cb_cls the callback closure
384 * @return handle to abort the operation
386 struct GNUNET_RECLAIM_Operation *
387 GNUNET_RECLAIM_ticket_revoke (
388 struct GNUNET_RECLAIM_Handle *h,
389 const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity,
390 const struct GNUNET_RECLAIM_Ticket *ticket,
391 GNUNET_RECLAIM_ContinuationWithStatus cb, void *cb_cls);
395 * Consumes an issued ticket. The ticket is used to retrieve identity
396 * information from the issuer
398 * @param h the identity provider to use
399 * @param identity the identity that is the subject of the issued ticket (the
401 * @param ticket the issued ticket to consume
402 * @param cb the callback to call
403 * @param cb_cls the callback closure
404 * @return handle to abort the operation
406 struct GNUNET_RECLAIM_Operation *
407 GNUNET_RECLAIM_ticket_consume (
408 struct GNUNET_RECLAIM_Handle *h,
409 const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity,
410 const struct GNUNET_RECLAIM_Ticket *ticket,
411 GNUNET_RECLAIM_AttributeTicketResult cb, void *cb_cls);
415 * Lists all tickets that have been issued to remote
416 * identites (relying parties)
418 * @param h the identity provider to use
419 * @param identity the issuing identity
420 * @param error_cb function to call on error (i.e. disconnect),
421 * the handle is afterwards invalid
422 * @param error_cb_cls closure for @a error_cb
423 * @param proc function to call on each ticket; it
424 * will be called repeatedly with a value (if available)
425 * @param proc_cls closure for @a proc
426 * @param finish_cb function to call on completion
427 * the handle is afterwards invalid
428 * @param finish_cb_cls closure for @a finish_cb
429 * @return an iterator handle to use for iteration
431 struct GNUNET_RECLAIM_TicketIterator *
432 GNUNET_RECLAIM_ticket_iteration_start (
433 struct GNUNET_RECLAIM_Handle *h,
434 const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity,
435 GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls,
436 GNUNET_RECLAIM_TicketCallback proc, void *proc_cls,
437 GNUNET_SCHEDULER_TaskCallback finish_cb, void *finish_cb_cls);
441 * Calls the ticket processor specified in
442 * #GNUNET_RECLAIM_ticket_iteration_start for the next record.
444 * @param it the iterator
447 GNUNET_RECLAIM_ticket_iteration_next (struct GNUNET_RECLAIM_TicketIterator *it);
451 * Stops iteration and releases the handle for further calls. Must
452 * be called on any iteration that has not yet completed prior to calling
453 * #GNUNET_RECLAIM_disconnect.
455 * @param it the iterator
458 GNUNET_RECLAIM_ticket_iteration_stop (struct GNUNET_RECLAIM_TicketIterator *it);
462 * Disconnect from identity provider service.
464 * @param h identity provider service to disconnect
467 GNUNET_RECLAIM_disconnect (struct GNUNET_RECLAIM_Handle *h);
471 * Cancel an identity provider operation. Note that the operation MAY still
472 * be executed; this merely cancels the continuation; if the request
473 * was already transmitted, the service may still choose to complete
476 * @param op operation to cancel
479 GNUNET_RECLAIM_cancel (struct GNUNET_RECLAIM_Operation *op);
482 #if 0 /* keep Emacsens' auto-indent happy */
490 /* ifndef GNUNET_RECLAIM_SERVICE_H */
493 /** @} */ /* end of group reclaim */
495 /* end of gnunet_reclaim_service.h */