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 * Identity provider service; implements identity provider for GNUnet
27 * @defgroup reclaim Identity Provider service
30 #ifndef GNUNET_RECLAIM_SERVICE_H
31 #define GNUNET_RECLAIM_SERVICE_H
35 #if 0 /* keep Emacsens' auto-indent happy */
40 #include "gnunet_reclaim_attribute_lib.h"
41 #include "gnunet_util_lib.h"
44 * Version number of the re:claimID API.
46 #define GNUNET_RECLAIM_VERSION 0x00000000
49 * Opaque handle to access the service.
51 struct GNUNET_RECLAIM_Handle;
55 * Opaque handle for an operation at the re:claimID service.
57 struct GNUNET_RECLAIM_Operation;
61 * The an authorization ticket. This ticket is meant to be transferred
62 * out of band the a relying party.
63 * The contents of a ticket must be protected and should be treated as a
64 * SHARED SECRET between user and relying party.
66 struct GNUNET_RECLAIM_Ticket
69 * The ticket issuer (= the user)
71 struct GNUNET_CRYPTO_EcdsaPublicKey identity;
74 * The ticket audience (= relying party)
76 struct GNUNET_CRYPTO_EcdsaPublicKey audience;
79 * The ticket random (NBO)
86 * Method called when a token has been issued.
87 * On success returns a ticket that can be given to the relying party to retrive
91 * @param ticket the ticket
93 typedef void (*GNUNET_RECLAIM_TicketCallback) (
94 void *cls, const struct GNUNET_RECLAIM_Ticket *ticket);
98 * Continuation called to notify client about result of the
101 * @param cls The callback closure
102 * @param success #GNUNET_SYSERR on failure
103 * @param emsg NULL on success, otherwise an error message
105 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
117 typedef void (*GNUNET_RECLAIM_AttributeResult) (
118 void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
119 const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr);
123 * Connect to the re:claimID service.
125 * @param cfg Configuration to contact the re:claimID service.
126 * @return handle to communicate with the service
128 struct GNUNET_RECLAIM_Handle *
129 GNUNET_RECLAIM_connect (const struct GNUNET_CONFIGURATION_Handle *cfg);
133 * Store an attribute. If the attribute is already present,
134 * it is replaced with the new attribute.
136 * @param h handle to the re:claimID service
137 * @param pkey Private key of the identity to add an attribute to
138 * @param attr The attribute
139 * @param exp_interval The relative expiration interval for the attribute
140 * @param cont Continuation to call when done
141 * @param cont_cls Closure for @a cont
142 * @return handle Used to to abort the request
144 struct GNUNET_RECLAIM_Operation *
145 GNUNET_RECLAIM_attribute_store (
146 struct GNUNET_RECLAIM_Handle *h,
147 const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey,
148 const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr,
149 const struct GNUNET_TIME_Relative *exp_interval,
150 GNUNET_RECLAIM_ContinuationWithStatus cont, void *cont_cls);
154 * List all attributes for a local identity.
155 * This MUST lock the `struct GNUNET_RECLAIM_Handle`
156 * for any other calls than #GNUNET_RECLAIM_get_attributes_next() and
157 * #GNUNET_RECLAIM_get_attributes_stop. @a proc will be called once
158 * immediately, and then again after
159 * #GNUNET_RECLAIM_get_attributes_next() is invoked.
161 * On error (disconnect), @a error_cb will be invoked.
162 * On normal completion, @a finish_cb proc will be
165 * @param h Handle to the re:claimID service
166 * @param identity Identity to iterate over
167 * @param error_cb Function to call on error (i.e. disconnect),
168 * the handle is afterwards invalid
169 * @param error_cb_cls Closure for @a error_cb
170 * @param proc Function to call on each attribute
171 * @param proc_cls Closure for @a proc
172 * @param finish_cb Function to call on completion
173 * the handle is afterwards invalid
174 * @param finish_cb_cls Closure for @a finish_cb
175 * @return an iterator Handle to use for iteration
177 struct GNUNET_RECLAIM_AttributeIterator *
178 GNUNET_RECLAIM_get_attributes_start (
179 struct GNUNET_RECLAIM_Handle *h,
180 const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity,
181 GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls,
182 GNUNET_RECLAIM_AttributeResult proc, void *proc_cls,
183 GNUNET_SCHEDULER_TaskCallback finish_cb, void *finish_cb_cls);
187 * Calls the record processor specified in #GNUNET_RECLAIM_get_attributes_start
188 * for the next record.
190 * @param it The iterator
193 GNUNET_RECLAIM_get_attributes_next (
194 struct GNUNET_RECLAIM_AttributeIterator *it);
198 * Stops iteration and releases the handle for further calls. Must
199 * be called on any iteration that has not yet completed prior to calling
200 * #GNUNET_RECLAIM_disconnect.
202 * @param it the iterator
205 GNUNET_RECLAIM_get_attributes_stop (
206 struct GNUNET_RECLAIM_AttributeIterator *it);
210 * Issues a ticket to a relying party. The identity may use
211 * GNUNET_RECLAIM_ticket_consume to consume the ticket
212 * and retrieve the attributes specified in the attribute list.
214 * @param h the identity provider to use
215 * @param iss the issuing identity (= the user)
216 * @param rp the subject of the ticket (= the relying party)
217 * @param attrs the attributes that the relying party is given access to
218 * @param cb the callback
219 * @param cb_cls the callback closure
220 * @return handle to abort the operation
222 struct GNUNET_RECLAIM_Operation *
223 GNUNET_RECLAIM_ticket_issue (
224 struct GNUNET_RECLAIM_Handle *h,
225 const struct GNUNET_CRYPTO_EcdsaPrivateKey *iss,
226 const struct GNUNET_CRYPTO_EcdsaPublicKey *rp,
227 const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs,
228 GNUNET_RECLAIM_TicketCallback cb, void *cb_cls);
231 * Revoked an issued ticket. The relying party will be unable to retrieve
232 * attributes. Other issued tickets remain unaffected.
233 * This includes tickets issued to other relying parties as well as to
234 * other tickets issued to the audience specified in this ticket.
236 * @param h the identity provider to use
237 * @param identity the issuing identity
238 * @param ticket the ticket to revoke
239 * @param cb the callback
240 * @param cb_cls the callback closure
241 * @return handle to abort the operation
243 struct GNUNET_RECLAIM_Operation *
244 GNUNET_RECLAIM_ticket_revoke (
245 struct GNUNET_RECLAIM_Handle *h,
246 const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity,
247 const struct GNUNET_RECLAIM_Ticket *ticket,
248 GNUNET_RECLAIM_ContinuationWithStatus cb, void *cb_cls);
252 * Consumes an issued ticket. The ticket is used to retrieve identity
253 * information from the issuer
255 * @param h the identity provider to use
256 * @param identity the identity that is the subject of the issued ticket (the
258 * @param ticket the issued ticket to consume
259 * @param cb the callback to call
260 * @param cb_cls the callback closure
261 * @return handle to abort the operation
263 struct GNUNET_RECLAIM_Operation *
264 GNUNET_RECLAIM_ticket_consume (
265 struct GNUNET_RECLAIM_Handle *h,
266 const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity,
267 const struct GNUNET_RECLAIM_Ticket *ticket,
268 GNUNET_RECLAIM_AttributeResult cb, void *cb_cls);
271 * Lists all tickets that have been issued to remote
272 * identites (relying parties)
274 * @param h the identity provider to use
275 * @param identity the issuing identity
276 * @param error_cb function to call on error (i.e. disconnect),
277 * the handle is afterwards invalid
278 * @param error_cb_cls closure for @a error_cb
279 * @param proc function to call on each ticket; it
280 * will be called repeatedly with a value (if available)
281 * @param proc_cls closure for @a proc
282 * @param finish_cb function to call on completion
283 * the handle is afterwards invalid
284 * @param finish_cb_cls closure for @a finish_cb
285 * @return an iterator handle to use for iteration
287 struct GNUNET_RECLAIM_TicketIterator *
288 GNUNET_RECLAIM_ticket_iteration_start (
289 struct GNUNET_RECLAIM_Handle *h,
290 const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity,
291 GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls,
292 GNUNET_RECLAIM_TicketCallback proc, void *proc_cls,
293 GNUNET_SCHEDULER_TaskCallback finish_cb, void *finish_cb_cls);
297 * Calls the ticket processor specified in
298 * #GNUNET_RECLAIM_ticket_iteration_start for the next record.
300 * @param it the iterator
303 GNUNET_RECLAIM_ticket_iteration_next (struct GNUNET_RECLAIM_TicketIterator *it);
306 * Stops iteration and releases the handle for further calls. Must
307 * be called on any iteration that has not yet completed prior to calling
308 * #GNUNET_RECLAIM_disconnect.
310 * @param it the iterator
313 GNUNET_RECLAIM_ticket_iteration_stop (struct GNUNET_RECLAIM_TicketIterator *it);
316 * Disconnect from identity provider service.
318 * @param h identity provider service to disconnect
321 GNUNET_RECLAIM_disconnect (struct GNUNET_RECLAIM_Handle *h);
325 * Cancel an identity provider operation. Note that the operation MAY still
326 * be executed; this merely cancels the continuation; if the request
327 * was already transmitted, the service may still choose to complete
330 * @param op operation to cancel
333 GNUNET_RECLAIM_cancel (struct GNUNET_RECLAIM_Operation *op);
335 #if 0 /* keep Emacsens' auto-indent happy */
343 /* ifndef GNUNET_RECLAIM_SERVICE_H */
346 /** @} */ /* end of group identity */
348 /* end of gnunet_reclaim_service.h */