2 This file is part of GNUnet
3 Copyright (C) 2012-2014 GNUnet e.V.
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 * @author Martin Schanzenbach
23 * @author Adnan Husain
26 * API to the Credential service
28 * @defgroup credential Credential service
33 #ifndef GNUNET_CREDENTIAL_SERVICE_H
34 #define GNUNET_CREDENTIAL_SERVICE_H
36 #include "gnunet_util_lib.h"
37 #include "gnunet_gns_service.h"
38 #include "gnunet_identity_service.h"
43 #if 0 /* keep Emacsens' auto-indent happy */
50 * Connection to the Credential service.
52 struct GNUNET_CREDENTIAL_Handle;
55 * Handle to control a lookup operation.
57 struct GNUNET_CREDENTIAL_Request;
60 * Enum used for checking whether the issuer has the authority to issue credentials or is just a subject
62 enum GNUNET_CREDENTIAL_CredentialFlags {
64 //Subject had credentials before, but have been revoked now
65 GNUNET_CREDENTIAL_FLAG_REVOKED=0,
67 //Subject flag indicates that the subject is a holder of this credential and may present it as such
68 GNUNET_CREDENTIAL_FLAG_SUBJECT=1,
70 //Issuer flag is used to signify that the subject is allowed to issue this credential and delegate issuance
71 GNUNET_CREDENTIAL_FLAG_ISSUER=2
75 GNUNET_NETWORK_STRUCT_BEGIN
77 * The credential record
79 struct GNUNET_CREDENTIAL_CredentialRecordData {
82 * The signature for this credential by the issuer
84 struct GNUNET_CRYPTO_EcdsaSignature sig;
88 * Public key of the issuer
90 struct GNUNET_CRYPTO_EcdsaPublicKey issuer_key;
93 * Public key of the subject this credential was issued to
95 struct GNUNET_CRYPTO_EcdsaPublicKey subject_key;
98 * Expiration time of this credential
100 uint64_t expiration GNUNET_PACKED;
103 * Followed by the attribute string
109 * The attribute delegation record
111 struct GNUNET_CREDENTIAL_AttributeRecordData {
114 * Public key of the subject this attribute was delegated to
116 struct GNUNET_CRYPTO_EcdsaPublicKey subject_key;
119 * Followed by the attribute that was delegated to as string
126 GNUNET_NETWORK_STRUCT_END
131 * Initialize the connection with the Credential service.
133 * @param cfg configuration to use
134 * @return handle to the Credential service, or NULL on error
136 struct GNUNET_CREDENTIAL_Handle *
137 GNUNET_CREDENTIAL_connect (const struct GNUNET_CONFIGURATION_Handle *cfg);
141 * Shutdown connection with the Credentail service.
143 * @param handle connection to shut down
146 GNUNET_CREDENTIAL_disconnect (struct GNUNET_CREDENTIAL_Handle *handle);
150 * Iterator called on obtained result for an attribute verification.
153 * @param issuer the issuer of the attribute NULL if verification failed
154 * @param result the result of the verification
155 * @param rd the records in reply
157 typedef void (*GNUNET_CREDENTIAL_VerifyResultProcessor) (void *cls,
158 struct GNUNET_CRYPTO_EcdsaPublicKey *issuer,
162 * Iterator called on obtained result for an attribute delegation.
165 * @param success GNUNET_YES if successful
166 * @param result the record data that can be handed to the subject
168 typedef void (*GNUNET_CREDENTIAL_DelegateResultProcessor) (void *cls,
172 * Iterator called on obtained result for an attribute delegation removal.
175 * @param success GNUNET_YES if successful
176 * @param result the record data that can be handed to the subject
178 typedef void (*GNUNET_CREDENTIAL_RemoveDelegateResultProcessor) (void *cls,
185 * Performs attribute verification.
186 * Checks if there is a delegation chain from
187 * attribute ``issuer_attribute'' issued by the issuer
188 * with public key ``issuer_key'' maps to the attribute
189 * ``subject_attribute'' claimed by the subject with key
192 * @param handle handle to the Credential service
193 * @param issuer_key the issuer public key
194 * @param issuer_attribute the issuer attribute
195 * @param subject_key the subject public key
196 * @param subject_attribute the attribute claimed by the subject
197 * @param proc function to call on result
198 * @param proc_cls closure for processor
199 * @return handle to the queued request
201 struct GNUNET_CREDENTIAL_Request*
202 GNUNET_CREDENTIAL_verify (struct GNUNET_CREDENTIAL_Handle *handle,
203 const struct GNUNET_CRYPTO_EcdsaPublicKey *issuer_key,
204 const char *issuer_attribute,
205 const struct GNUNET_CRYPTO_EcdsaPublicKey *subject_key,
206 const char *subject_attribute,
207 GNUNET_CREDENTIAL_VerifyResultProcessor proc,
211 * Delegate an attribute
213 * @param handle handle to the Credential service
214 * @param issuer the ego that should be used to delegate the attribute
215 * @param attribute the name of the attribute to delegate
216 * @param subject the subject of the delegation
217 * @param delegated_attribute the name of the attribute that is delegated to
218 * @return handle to the queued request
220 struct GNUNET_CREDENTIAL_Request *
221 GNUNET_CREDENTIAL_add_delegation (struct GNUNET_CREDENTIAL_Handle *handle,
222 struct GNUNET_IDENTITY_Ego *issuer,
223 const char *attribute,
224 struct GNUNET_CRYPTO_EcdsaPublicKey *subject,
225 const char *delegated_attribute,
226 GNUNET_CREDENTIAL_DelegateResultProcessor proc,
230 * Remove a delegation
232 * @param handle handle to the Credential service
233 * @param issuer the ego that was used to delegate the attribute
234 * @param attribute the name of the attribute that is delegated
235 * @return handle to the queued request
237 struct GNUNET_CREDENTIAL_Request *
238 GNUNET_CREDENTIAL_remove_delegation (struct GNUNET_CREDENTIAL_Handle *handle,
239 struct GNUNET_IDENTITY_Ego *issuer,
240 const char *attribute,
241 GNUNET_CREDENTIAL_RemoveDelegateResultProcessor proc,
247 * Issue an attribute to a subject
249 * @param handle handle to the Credential service
250 * @param issuer the ego that should be used to issue the attribute
251 * @param subject the subject of the attribute
252 * @param attribute the name of the attribute
253 * @return handle to the queued request
255 struct GNUNET_CREDENTIAL_CredentialRecordData *
256 GNUNET_CREDENTIAL_issue (struct GNUNET_CREDENTIAL_Handle *handle,
257 const struct GNUNET_CRYPTO_EcdsaPrivateKey *issuer,
258 struct GNUNET_CRYPTO_EcdsaPublicKey *subject,
259 const char *attribute);
263 * Remove a credential
265 * @param handle handle to the Credential service
266 * @param issuer the identity that issued the credential
267 * @param subject the subject of the credential
268 * @param credential the name of the credential
269 * @return handle to the queued request
272 struct GNUNET_CREDENTIAL_IssueRequest *
273 GNUNET_CREDENTIAL_remove (struct GNUNET_CREDENTIAL_Handle *handle,
274 struct GNUNET_IDENTITY_Ego *issuer,
275 struct GNUNET_IDENTITY_Ego *subject,
276 const char *credential,
277 GNUNET_CREDENTIAL_IssueResultProcessor proc,
283 * Cancel pending lookup request
285 * @param lr the lookup request to cancel
288 GNUNET_CREDENTIAL_verify_cancel (struct GNUNET_CREDENTIAL_Request *vr);
291 #if 0 /* keep Emacsens' auto-indent happy */
300 /** @} */ /* end of group */