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
25 * API to the Credential service
27 * @defgroup credential Credential service
32 #ifndef GNUNET_CREDENTIAL_SERVICE_H
33 #define GNUNET_CREDENTIAL_SERVICE_H
35 #include "gnunet_util_lib.h"
36 #include "gnunet_gns_service.h"
37 #include "gnunet_identity_service.h"
42 #if 0 /* keep Emacsens' auto-indent happy */
49 * Connection to the Credential service.
51 struct GNUNET_CREDENTIAL_Handle;
54 * Handle to control a lookup operation.
56 struct GNUNET_CREDENTIAL_LookupRequest;
59 * Enum used for checking whether the issuer has the authority to issue credentials or is just a subject
61 enum GNUNET_CREDENTIAL_CredentialFlags {
63 //Subject had credentials before, but have been revoked now
64 GNUNET_CREDENTIAL_FLAG_REVOKED=0,
66 //Subject flag indicates that the subject is a holder of this credential and may present it as such
67 GNUNET_CREDENTIAL_FLAG_SUBJECT=1,
69 //Issuer flag is used to signify that the subject is allowed to issue this credential and delegate issuance
70 GNUNET_CREDENTIAL_FLAG_ISSUER=2
74 GNUNET_NETWORK_STRUCT_BEGIN
76 * Data stored in the credential record
78 struct GNUNET_CREDENTIAL_RecordData {
83 struct GNUNET_CRYPTO_EcdsaPublicKey subject_key;
85 struct GNUNET_CRYPTO_EcdsaPublicKey issuer_key;
88 uint32_t credential_flags GNUNET_PACKED;
90 uint32_t max_delegation_depth GNUNET_PACKED;
93 GNUNET_NETWORK_STRUCT_END
98 * Initialize the connection with the Credential service.
100 * @param cfg configuration to use
101 * @return handle to the Credential service, or NULL on error
103 struct GNUNET_CREDENTIAL_Handle *
104 GNUNET_CREDENTIAL_connect (const struct GNUNET_CONFIGURATION_Handle *cfg);
108 * Shutdown connection with the Credentail service.
110 * @param handle connection to shut down
113 GNUNET_CREDENTIAL_disconnect (struct GNUNET_CREDENTIAL_Handle *handle);
117 * Iterator called on obtained result for a Credential lookup.
120 * @param issuer the issuer chain
121 * @param issuer_len length of issuer chain
122 * @param rd the records in reply
124 typedef void (*GNUNET_CREDENTIAL_LookupResultProcessor) (void *cls,
125 struct GNUNET_IDENTITY_Ego *issuer,
127 const struct GNUNET_CREDENTIAL_RecordData *data);
131 * Perform an asynchronous lookup operation for a credential.
133 * @param handle handle to the Credential service
134 * @param credential the credential to look up
135 * @param subject Ego to check the credential for
136 * @param proc function to call on result
137 * @param proc_cls closure for processor
138 * @return handle to the queued request
140 struct GNUNET_CREDENTIAL_LookupRequest *
141 GNUNET_CREDENTIAL_lookup (struct GNUNET_CREDENTIAL_Handle *handle,
142 const char *credential,
143 const struct GNUNET_IDENTITY_Ego *subject,
144 const struct GNUNET_CRYPTO_EcdsaPublicKey *subject_key,
145 const struct GNUNET_CRYPTO_EcdsaPublicKey *issuer_key,
146 uint32_t credential_flags,
147 uint32_t max_delegation_depth,
148 GNUNET_CREDENTIAL_LookupResultProcessor proc,
153 * Issue a credential to an identity
155 * @param handle handle to the Credential service
156 * @param issuer the identity that issues the credential
157 * @param subject the subject of the credential
158 * @param credential the name of the credential
159 * @param data the data of the credential
160 * @return handle to the queued request
162 /**struct GNUNET_CREDENTIAL_IssueRequest *
163 GNUNET_CREDENTIAL_issue (struct GNUNET_CREDENTIAL_Handle *handle,
164 struct GNUNET_IDENTITY_Ego *issuer,
165 struct GNUNET_IDENTITY_Ego *subject,
166 const char *credential,
167 struct GNUNET_CREDENTIAL_Data *data,
168 GNUNET_CREDENTIAL_IssueResultProcessor proc,
172 * Remove a credential
174 * @param handle handle to the Credential service
175 * @param issuer the identity that issued the credential
176 * @param subject the subject of the credential
177 * @param credential the name of the credential
178 * @return handle to the queued request
181 struct GNUNET_CREDENTIAL_IssueRequest *
182 GNUNET_CREDENTIAL_remove (struct GNUNET_CREDENTIAL_Handle *handle,
183 struct GNUNET_IDENTITY_Ego *issuer,
184 struct GNUNET_IDENTITY_Ego *subject,
185 const char *credential,
186 GNUNET_CREDENTIAL_IssueResultProcessor proc,
192 * Cancel pending lookup request
194 * @param lr the lookup request to cancel
197 GNUNET_CREDENTIAL_lookup_cancel (struct GNUNET_CREDENTIAL_LookupRequest *lr);
200 #if 0 /* keep Emacsens' auto-indent happy */
209 /** @} */ /* end of group */