2 This file is part of GNUnet.
3 (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., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
22 * @file include/gnunet_identity_service.h
23 * @brief Identity service; implements identity management for GNUnet
24 * @author Christian Grothoff
26 * Identities in GNUnet are ECDSA keys. You assume an identity by
27 * using (signing with) a particular private key. As GNUnet users are
28 * expected to have many egos, we need an identity service to
29 * allow users to manage their egos. The identity service
30 * manages the egos (private keys) of the local user; it does
31 * NOT manage identities of other users (public keys). For giving
32 * names to other users and manage their public keys securely, we
35 #ifndef GNUNET_IDENTITY_SERVICE_H
36 #define GNUNET_IDENTITY_SERVICE_H
41 #if 0 /* keep Emacsens' auto-indent happy */
46 #include "gnunet_util_lib.h"
50 * Version number of GNUnet Identity API.
52 #define GNUNET_IDENTITY_VERSION 0x00000000
55 * Handle to access the identity service.
57 struct GNUNET_IDENTITY_Handle;
62 struct GNUNET_IDENTITY_Ego;
66 * Obtain the ECC key associated with a ego.
69 * @return associated ECC key, valid as long as the ego is valid
71 const struct GNUNET_CRYPTO_EccPrivateKey *
72 GNUNET_IDENTITY_ego_get_key (struct GNUNET_IDENTITY_Ego *ego);
76 * Method called to inform about the egos of
79 * When used with 'GNUNET_IDENTITY_connect', this function is
80 * initially called for all egos and then again whenever a
81 * ego's identifier changes or if it is deleted. At the end of
82 * the initial pass over all egos, the function is once called
83 * with 'NULL' for 'ego'. That does NOT mean that the callback won't
84 * be invoked in the future or that there was an error.
86 * When used with 'GNUNET_IDENTITY_create' or 'GNUNET_IDENTITY_get',
87 * this function is only called ONCE, and 'NULL' being passed in
88 * 'ego' does indicate an error (i.e. name is taken or no default
89 * value is known). If 'ego' is non-NULL and if '*ctx'
90 * is set in those callbacks, the value WILL be passed to a subsequent
91 * call to the identity callback of 'GNUNET_IDENTITY_connect' (if
92 * that one was not NULL).
94 * When an identity is renamed, this function is called with the
95 * (known) ego but the NEW identifier.
97 * When an identity is deleted, this function is called with the
98 * (known) ego and "NULL" for the 'identifier'. In this case,
99 * the 'ego' is henceforth invalid (and the 'ctx' should also be
103 * @param ego ego handle
104 * @param ego_ctx context for application to store data for this ego
105 * (during the lifetime of this process, initially NULL)
106 * @param identifier identifier assigned by the user for this ego,
107 * NULL if the user just deleted the ego and it
108 * must thus no longer be used
110 typedef void (*GNUNET_IDENTITY_Callback)(void *cls,
111 struct GNUNET_IDENTITY_Ego *ego,
113 const char *identifier);
117 * Connect to the identity service.
119 * @param cfg Configuration to contact the identity service.
120 * @param cb function to call on all identity events, can be NULL
121 * @param cb_cls closure for 'cb'
122 * @return handle to communicate with identity service
124 struct GNUNET_IDENTITY_Handle *
125 GNUNET_IDENTITY_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
126 GNUNET_IDENTITY_Callback cb,
131 * Obtain the identity that is currently preferred/default
134 * @param id identity service to query
135 * @param service_name for which service is an identity wanted
136 * @param cb function to call with the result (will only be called once)
137 * @param cb_cls closure for cb
138 * @return handle to abort the operation
140 struct GNUNET_IDENTITY_Operation *
141 GNUNET_IDENTITY_get (struct GNUNET_IDENTITY_Handle *id,
142 const char *service_name,
143 GNUNET_IDENTITY_Callback cb,
148 * Function called once the requested operation has
152 * @param emsg NULL on success, otherwise an error message
154 typedef void (*GNUNET_IDENTITY_Continuation)(void *cls,
159 * Set the preferred/default identity for a service.
161 * @param id identity service to inform
162 * @param service_name for which service is an identity set
163 * @param ego new default identity to be set for this service
164 * @param cont function to call once the operation finished
165 * @param cont_cls closure for cont
166 * @return handle to abort the operation
168 struct GNUNET_IDENTITY_Operation *
169 GNUNET_IDENTITY_set (struct GNUNET_IDENTITY_Handle *id,
170 const char *service_name,
171 struct GNUNET_IDENTITY_Ego *ego,
172 GNUNET_IDENTITY_Continuation cont,
177 * Disconnect from identity service.
179 * @param id identity service to disconnect
182 GNUNET_IDENTITY_disconnect (struct GNUNET_IDENTITY_Handle *id);
186 * Create a new identity with the given identifier.
188 * @param id identity service to use
189 * @param identifier desired identifier
190 * @param cb function to call with the result (will only be called once)
191 * @param cb_cls closure for cb
192 * @return handle to abort the operation
194 struct GNUNET_IDENTITY_Operation *
195 GNUNET_IDENTITY_create (struct GNUNET_IDENTITY_Handle *id,
196 const char *identifier,
197 GNUNET_IDENTITY_Callback cb,
202 * Renames an existing identity.
204 * @param id identity service to use
205 * @param old_identifier old identifier
206 * @param new_identifier desired new identifier
207 * @param cb function to call with the result (will only be called once)
208 * @param cb_cls closure for cb
209 * @return handle to abort the operation
211 struct GNUNET_IDENTITY_Operation *
212 GNUNET_IDENTITY_rename (struct GNUNET_IDENTITY_Handle *id,
213 const char *old_identifier,
214 const char *new_identifier,
215 GNUNET_IDENTITY_Continuation cb,
220 * Delete an existing identity.
222 * @param id identity service to use
223 * @param identifier identifier of the identity to delete
224 * @param cb function to call with the result (will only be called once)
225 * @param cb_cls closure for cb
226 * @return handle to abort the operation
228 struct GNUNET_IDENTITY_Operation *
229 GNUNET_IDENTITY_delete (struct GNUNET_IDENTITY_Handle *id,
230 const char *identifier,
231 GNUNET_IDENTITY_Continuation cb,
236 * Cancel an identity operation. Note that the operation MAY still
237 * be executed; this merely cancels the continuation; if the request
238 * was already transmitted, the service may still choose to complete
241 * @param op operation to cancel
244 GNUNET_IDENITY_cancel (struct GNUNET_IDENTITY_Operation *op);
247 #if 0 /* keep Emacsens' auto-indent happy */
254 /* ifndef GNUNET_IDENTITY_SERVICE_H */
256 /* end of gnunet_identity_service.h */