2 This file is part of GNUnet.
3 Copyright (C) 2013 Christian Grothoff (and other contributing authors)
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 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 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
22 * @file include/gnunet_identity_service.h
23 * @brief Identity service; implements identity management for GNUnet
24 * @author Christian Grothoff
26 * Egos in GNUnet are ECDSA keys. You assume an ego by using (signing
27 * with) a particular private key. As GNUnet users are expected to
28 * have many egos, we need an identity service to allow users to
29 * manage their egos. The identity service manages the egos (private
30 * keys) of the local user; it does NOT manage egos of other users
31 * (public keys). For giving names to other users and manage their
32 * public keys securely, we use GNS.
34 * @defgroup identity identity management service
37 #ifndef GNUNET_IDENTITY_SERVICE_H
38 #define GNUNET_IDENTITY_SERVICE_H
43 #if 0 /* keep Emacsens' auto-indent happy */
48 #include "gnunet_util_lib.h"
52 * Version number of GNUnet Identity API.
54 #define GNUNET_IDENTITY_VERSION 0x00000000
57 * Handle to access the identity service.
59 struct GNUNET_IDENTITY_Handle;
64 struct GNUNET_IDENTITY_Ego;
67 * Handle for an operation with the identity service.
69 struct GNUNET_IDENTITY_Operation;
73 * Obtain the ECC key associated with a ego.
76 * @return associated ECC key, valid as long as the ego is valid
78 const struct GNUNET_CRYPTO_EcdsaPrivateKey *
79 GNUNET_IDENTITY_ego_get_private_key (const struct GNUNET_IDENTITY_Ego *ego);
83 * Obtain the ego representing 'anonymous' users.
85 * @return handle for the anonymous user, must not be freed
87 const struct GNUNET_IDENTITY_Ego *
88 GNUNET_IDENTITY_ego_get_anonymous (void);
92 * Get the identifier (public key) of an ego.
94 * @param ego identity handle with the private key
95 * @param pk set to ego's public key
98 GNUNET_IDENTITY_ego_get_public_key (const struct GNUNET_IDENTITY_Ego *ego,
99 struct GNUNET_CRYPTO_EcdsaPublicKey *pk);
103 * Method called to inform about the egos of
106 * When used with #GNUNET_IDENTITY_connect, this function is
107 * initially called for all egos and then again whenever a
108 * ego's name changes or if it is deleted. At the end of
109 * the initial pass over all egos, the function is once called
110 * with 'NULL' for @a ego. That does NOT mean that the callback won't
111 * be invoked in the future or that there was an error.
113 * When used with #GNUNET_IDENTITY_create or #GNUNET_IDENTITY_get,
114 * this function is only called ONCE, and 'NULL' being passed in
115 * @a ego does indicate an error (i.e. name is taken or no default
116 * value is known). If @a ego is non-NULL and if '*ctx'
117 * is set in those callbacks, the value WILL be passed to a subsequent
118 * call to the identity callback of #GNUNET_IDENTITY_connect (if
119 * that one was not NULL).
121 * When an identity is renamed, this function is called with the
122 * (known) @a ego but the NEW @a name.
124 * When an identity is deleted, this function is called with the
125 * (known) ego and "NULL" for the @a name. In this case,
126 * the @a ego is henceforth invalid (and the @a ctx should also be
130 * @param ego ego handle
131 * @param ctx context for application to store data for this ego
132 * (during the lifetime of this process, initially NULL)
133 * @param name name assigned by the user for this ego,
134 * NULL if the user just deleted the ego and it
135 * must thus no longer be used
138 (*GNUNET_IDENTITY_Callback)(void *cls,
139 struct GNUNET_IDENTITY_Ego *ego,
145 * Connect to the identity service.
147 * @param cfg Configuration to contact the identity service.
148 * @param cb function to call on all identity events, can be NULL
149 * @param cb_cls closure for @a cb
150 * @return handle to communicate with identity service
152 struct GNUNET_IDENTITY_Handle *
153 GNUNET_IDENTITY_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
154 GNUNET_IDENTITY_Callback cb,
159 * Obtain the ego that is currently preferred/default
162 * @param id identity service to query
163 * @param service_name for which service is an identity wanted
164 * @param cb function to call with the result (will only be called once)
165 * @param cb_cls closure for @a cb
166 * @return handle to abort the operation
168 struct GNUNET_IDENTITY_Operation *
169 GNUNET_IDENTITY_get (struct GNUNET_IDENTITY_Handle *id,
170 const char *service_name,
171 GNUNET_IDENTITY_Callback cb,
176 * Function called once the requested operation has
180 * @param emsg NULL on success, otherwise an error message
183 (*GNUNET_IDENTITY_Continuation)(void *cls,
188 * Set the preferred/default ego for a service.
190 * @param id identity service to inform
191 * @param service_name for which service is an identity set
192 * @param ego new default identity to be set for this service
193 * @param cont function to call once the operation finished
194 * @param cont_cls closure for @a cont
195 * @return handle to abort the operation
197 struct GNUNET_IDENTITY_Operation *
198 GNUNET_IDENTITY_set (struct GNUNET_IDENTITY_Handle *id,
199 const char *service_name,
200 struct GNUNET_IDENTITY_Ego *ego,
201 GNUNET_IDENTITY_Continuation cont,
206 * Disconnect from identity service.
208 * @param h identity service to disconnect
211 GNUNET_IDENTITY_disconnect (struct GNUNET_IDENTITY_Handle *h);
215 * Create a new ego with the given name.
217 * @param id identity service to use
218 * @param name desired name
219 * @param cont function to call with the result (will only be called once)
220 * @param cont_cls closure for @a cont
221 * @return handle to abort the operation
223 struct GNUNET_IDENTITY_Operation *
224 GNUNET_IDENTITY_create (struct GNUNET_IDENTITY_Handle *id,
226 GNUNET_IDENTITY_Continuation cont,
231 * Renames an existing ego.
233 * @param id identity service to use
234 * @param old_name old name
235 * @param new_name desired new name
236 * @param cb function to call with the result (will only be called once)
237 * @param cb_cls closure for @a cb
238 * @return handle to abort the operation
240 struct GNUNET_IDENTITY_Operation *
241 GNUNET_IDENTITY_rename (struct GNUNET_IDENTITY_Handle *id,
242 const char *old_name,
243 const char *new_name,
244 GNUNET_IDENTITY_Continuation cb,
249 * Delete an existing ego.
251 * @param id identity service to use
252 * @param name name of the identity to delete
253 * @param cb function to call with the result (will only be called once)
254 * @param cb_cls closure for @a cb
255 * @return handle to abort the operation
257 struct GNUNET_IDENTITY_Operation *
258 GNUNET_IDENTITY_delete (struct GNUNET_IDENTITY_Handle *id,
260 GNUNET_IDENTITY_Continuation cb,
265 * Cancel an identity operation. Note that the operation MAY still
266 * be executed; this merely cancels the continuation; if the request
267 * was already transmitted, the service may still choose to complete
270 * @param op operation to cancel
273 GNUNET_IDENTITY_cancel (struct GNUNET_IDENTITY_Operation *op);
276 /* ************* convenience API to lookup an ego ***************** */
279 * Function called with the result.
282 * @param ego NULL on error / ego not found
285 (*GNUNET_IDENTITY_EgoCallback)(void *cls,
286 const struct GNUNET_IDENTITY_Ego *ego);
289 * Handle for ego lookup.
291 struct GNUNET_IDENTITY_EgoLookup;
295 * Lookup an ego by name.
297 * @param cfg configuration to use
298 * @param name name to look up
299 * @param cb callback to invoke with the result
300 * @param cb_cls closure for @a cb
301 * @return NULL on error
303 struct GNUNET_IDENTITY_EgoLookup *
304 GNUNET_IDENTITY_ego_lookup (const struct GNUNET_CONFIGURATION_Handle *cfg,
306 GNUNET_IDENTITY_EgoCallback cb,
311 * Abort ego lookup attempt.
313 * @param el handle for lookup to abort
316 GNUNET_IDENTITY_ego_lookup_cancel (struct GNUNET_IDENTITY_EgoLookup *el);
319 #if 0 /* keep Emacsens' auto-indent happy */
326 /** @} */ /* end of group identity */
328 /* ifndef GNUNET_IDENTITY_SERVICE_H */
330 /* end of gnunet_identity_service.h */